This is the pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>heroku-webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>heroku-webapp</name>

<properties>
<jersey.version>3.0.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>11.0.1</jetty.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>11.0.2</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>

<!-- uncomment this to get JSON support -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>11.0.2</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<version>11.0.0</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0-alpha0</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-bundle</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>heroku-webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<inherited>true</inherited>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<contextPath>/</contextPath>
<webApp>
<contextPath>/</contextPath>
<webInfIncludeJarPattern>.*/.*jersey-[^/]\.jar$</webInfIncludeJarPattern>
</webApp>
<war>${project.build.directory}/${project.build.finalName}.war</war>
</configuration>
</plugin>
</plugins>
</build>

</project>
<http://www.backbutton.co.uk/>



On Mon, 5 Apr 2021, 06:29 Som Lima, <somplastic...@gmail.com> wrote:

> A reminder this is the Main function I am working with for jetty 11.
>
>
> import org.eclipse.jetty.server.Server;
> import org.eclipse.jetty.webapp.WebAppContext;
>
> /**
>  *  This class launches the web application in an embedded Jetty container.
>  *  This is the entry point to your application. The Java
>  *  command that is used for launching should fire this main method.
>  */
>
> public class Main {
>
>     public static void main(String[] args) throws Exception{
>         // The port that we should run on can be set into an environment
> variable
>         // Look for that variable and default to 8080 if it isn't there.
>         String webPort = System.getenv("PORT");
>         if (webPort == null || webPort.isEmpty()) {
>             webPort = "8080";
>         }
>
>         final Server server = new Server(Integer.valueOf(webPort));
>         final WebAppContext root = new WebAppContext();
>
>         root.setContextPath("/");
>         root.setParentLoaderPriority(true);
>
>         final String webappDirLocation = "src/main/webapp/";
>         root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
>         root.setResourceBase(webappDirLocation);
>
>         server.setHandler(root);
>
>         server.start();
>         server.join();
>     }
> }
> <http://www.backbutton.co.uk/>
>
>
> On Mon, 5 Apr 2021, 01:31 Som Lima, <somplastic...@gmail.com> wrote:
>
>> Thank you I also agree that is the correct jetty  reponse.
>>
>> I am using embedded  jetty 11.
>> Using webAppContext for configuration.
>> we also have agreed that
>>  " in jetty 11 there is indeed no ClassList, so that part is "broken".
>> ".
>>
>> What  other method of configuration I  have available  for  adding
>> features as and when I need them
>> to the embedded jetty 11  org.eclipse.jetty.server.Server object  apart
>> from using ServletContextHandler   ?
>>
>> Please send me  link showing the instructions.
>>
>>
>>
>>
>>
>> On Sun, 4 Apr 2021, 23:23 Greg Wilkins, <gr...@webtide.com> wrote:
>>
>>> Som,
>>>
>>> Without a web.xml, the Jersey servlet is not setup to handle requests.
>>> Without Jersey, there is nothing in Jetty to map any request to
>>> MyResource.
>>>
>>> Unless there is something annotated or in a discovered webfragment, then
>>> Jetty has no handler for that request and 404 is the correct response.
>>>
>>> regards
>>>
>>>
>>>
>>> On Mon, 5 Apr 2021 at 00:10, Som Lima <somplastic...@gmail.com> wrote:
>>>
>>>> Let me put it another way.
>>>> If I remove web.xml why does the following code  give me 404  in jetty
>>>> 11 ?
>>>>
>>>>
>>>> import jakarta.ws.rs.GET;
>>>> import jakarta.ws.rs.Path;
>>>> import jakarta.ws.rs.Produces;
>>>> import jakarta.ws.rs.core.MediaType;
>>>>
>>>> /**
>>>>  * Root resource (exposed at "myresource" path)
>>>>  */
>>>> @Path("myresource")
>>>> public class MyResource {
>>>>
>>>>     /**
>>>>      * Method handling HTTP GET requests. The returned object will be
>>>> sent
>>>>      * to the client as "text/plain" media type.
>>>>      *
>>>>      * @return String that will be returned as a text/plain response.
>>>>      */
>>>>     @GET
>>>>     @Produces(MediaType.TEXT_PLAIN)
>>>>     public String getIt() {
>>>>         return "got, it!";
>>>>     }
>>>> }
>>>>
>>>> On Sun, 4 Apr 2021, 15:03 Joakim Erdfelt, <joa...@webtide.com> wrote:
>>>>
>>>>> <welcome-file-list> is only used when Jetty is in charge of serving
>>>>> static content.
>>>>> Or said another way, when there is a request for a resource that
>>>>> doesn't match a url-pattern that the webapp has specified, then the 
>>>>> servlet
>>>>> spec Default Servlet kicks in and determines static content, 
>>>>> welcome-files,
>>>>> etc ...
>>>>>
>>>>> You have jersey setup with <url-pattern>/*</url-pattern>, which means
>>>>> Jersey is responsible for 100% of content served.
>>>>> Jetty is not involved in much with that configuration.
>>>>>
>>>>> I don't understand this kind of configuration, Jersey usage should be
>>>>> focused, only on REST api resources, not 100% of content, including static
>>>>> and default servlet.
>>>>> I would recommend that you specify jersey on a narrow focused
>>>>> url-pattern, like `/api/*` and leave the other requests for resources to
>>>>> Jetty (it can serve static content WAY BETTER than Jersey can).
>>>>>
>>>>> Joakim Erdfelt / joa...@webtide.com
>>>>>
>>>>>
>>>>> On Sat, Apr 3, 2021 at 1:55 AM Som Lima <somplastic...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>>
>>>>>> IF I have the web.xml then localhost:8080/myresource  works fine
>>>>>> BUT the index.jsp is not picked  with localhost:8080 or
>>>>>> http://localhost/index.jsp
>>>>>> I got an 404.
>>>>>> URI: /
>>>>>> STATUS: 404
>>>>>>
>>>>>> IF I remove the web.xml then the index.jsp is picked up which is what
>>>>>> is meant to happen with jetty because it's built in functionality
>>>>>> assumes an index.jsp file is there and will pick it and publish it.
>>>>>> But the I get a 404 with localhost:8080/myresource  now.
>>>>>> I want both index.jsp to be picked up and have the jersey
>>>>>> functionality localhost:8080/myresource with the web.xml
>>>>>> but I can only have one or the other.
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"; xmlns:xsi="
>>>>>> http://www.w3.org/2001/XMLSchema-instance";
>>>>>>         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
>>>>>> https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd";
>>>>>>         version="5.0">
>>>>>>
>>>>>>     <servlet>
>>>>>>         <servlet-name>Jersey Web Application</servlet-name>
>>>>>>
>>>>>> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
>>>>>>         <init-param>
>>>>>>
>>>>>> <param-name>jersey.config.server.provider.packages</param-name>
>>>>>>             <param-value>com.example</param-value>
>>>>>>         </init-param>
>>>>>>         <load-on-startup>1</load-on-startup>
>>>>>>     </servlet>
>>>>>>     <servlet-mapping>
>>>>>>         <servlet-name>Jersey Web Application</servlet-name>
>>>>>>         <url-pattern>/*</url-pattern>
>>>>>>     </servlet-mapping>
>>>>>>
>>>>>>    <!-- no effect  -->
>>>>>>     <welcome-file-list>
>>>>>>     <welcome-file>index.jsp</welcome-file>
>>>>>>     </welcome-file-list>
>>>>>>
>>>>>> </web-app>
>>>>>>
>>>>>>
>>>>>> import jakarta.ws.rs.GET;
>>>>>> import jakarta.ws.rs.Path;
>>>>>> import jakarta.ws.rs.Produces;
>>>>>> import jakarta.ws.rs.core.MediaType;
>>>>>>
>>>>>> /**
>>>>>>  * Root resource (exposed at "myresource" path)
>>>>>>  */
>>>>>> @Path("myresource")
>>>>>> public class MyResource {
>>>>>>
>>>>>>     /**
>>>>>>      * Method handling HTTP GET requests. The returned object will be
>>>>>> sent
>>>>>>      * to the client as "text/plain" media type.
>>>>>>      *
>>>>>>      * @return String that will be returned as a text/plain response.
>>>>>>      */
>>>>>>     @GET
>>>>>>     @Produces(MediaType.TEXT_PLAIN)
>>>>>>     public String getIt() {
>>>>>>         return "got, it!";
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> Preferably I also want the Rest API Config to work as well as the
>>>>>> index.jsp so that I can call the resource localhost:8080/v1/myresource
>>>>>>
>>>>>> import jakarta.ws.rs.ApplicationPath;
>>>>>> import jakarta.ws.rs.core.Application;
>>>>>>
>>>>>> @ApplicationPath("v1")
>>>>>> public class RestAppConfig extends Application{
>>>>>> }
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> jetty-users mailing list
>>>>>> jetty-users@eclipse.org
>>>>>> To unsubscribe from this list, visit
>>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>>>>
>>>>> _______________________________________________
>>>>> jetty-users mailing list
>>>>> jetty-users@eclipse.org
>>>>> To unsubscribe from this list, visit
>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>>>
>>>> _______________________________________________
>>>> jetty-users mailing list
>>>> jetty-users@eclipse.org
>>>> To unsubscribe from this list, visit
>>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>>
>>>
>>>
>>> --
>>> Greg Wilkins <gr...@webtide.com> CTO http://webtide.com
>>> _______________________________________________
>>> jetty-users mailing list
>>> jetty-users@eclipse.org
>>> To unsubscribe from this list, visit
>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>
>>
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to