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, <[email protected]> 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 <[email protected]> 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, <[email protected]> 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 / [email protected]
>>>
>>>
>>> On Sat, Apr 3, 2021 at 1:55 AM Som Lima <[email protected]> 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
>>>> [email protected]
>>>> To unsubscribe from this list, visit
>>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>>
>>> _______________________________________________
>>> jetty-users mailing list
>>> [email protected]
>>> To unsubscribe from this list, visit
>>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>>
>> _______________________________________________
>> jetty-users mailing list
>> [email protected]
>> To unsubscribe from this list, visit
>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>
>
>
> --
> Greg Wilkins <[email protected]> CTO http://webtide.com
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to