Re: [jetty-users] Either OR but not Both.

2021-04-05 Thread Som Lima
I have the  jsp  +  jaxrs jersey  2.33 using  jetty 9.

https://lit-taiga-52898.herokuapp.com/


If you guys decide to have a working example using jetty 11 and  jersey
3.0.1
on github  please send me a link.

I think there are quite a  few bugs need fixing for that to happen.

Even with jetty 9 there were compatibility issues amongst  jetty 9
variations.




On Mon, 5 Apr 2021, 06:31 Som Lima,  wrote:

> This is the pom.xml
>
>
> 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;>
>
> 4.0.0
>
> com.example
> heroku-webapp
> war
> 1.0-SNAPSHOT
> heroku-webapp
>
> 
> 3.0.1
> UTF-8
> 11.0.1
> false
> 
>
> 
> 
> 
> org.glassfish.jersey
> jersey-bom
> ${jersey.version}
> pom
> import
> 
> 
> 
>
> 
> 
> org.eclipse.jetty
> jetty-annotations
> 11.0.2
> 
>
> 
> org.glassfish.jersey.containers
> jersey-container-servlet
> 
> 
> org.glassfish.jersey.inject
> jersey-hk2
> 
>
> 
> 
> org.glassfish.jersey.media
> jersey-media-json-binding
> 
> 
> org.glassfish.jaxb
> jaxb-runtime
> 3.0.0
> 
>
> 
> org.eclipse.jetty
> jetty-servlet
> ${jetty.version}
> provided
> 
> 
> org.eclipse.jetty
> jetty-webapp
> ${jetty.version}
> provided
> 
> 
> org.eclipse.jetty
> apache-jsp
> 11.0.2
> 
>
> 
> org.eclipse.jetty
> apache-jstl
> 11.0.0
> 
>
> 
> org.slf4j
> slf4j-simple
> 2.0.0-alpha0
> 
>
> 
> org.glassfish.jersey.test-framework.providers
> jersey-test-framework-provider-bundle
> pom
> test
> 
> 
>
> 
> heroku-webapp
> 
> 
> org.apache.maven.plugins
> maven-compiler-plugin
> 3.8.0
> true
> 
> 11
> 11
> 
> 
> 
> org.apache.maven.plugins
> maven-dependency-plugin
> 2.8
> 
> 
> copy-dependencies
> package
> 
> copy-dependencies
> 
> 
> compile
> 
> 
> 
> 
> 
> org.eclipse.jetty
> jetty-maven-plugin
> ${jetty.version}
> 
> /
> 
> /
> .*/.*jersey-[^/]\.jar$
> 
> ${project.build.directory}/${project.build.finalName}.war
> 
> 
> 
> 
>
> 
> 
>
>
>
> On Mon, 5 Apr 2021, 06:29 Som Lima,  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();
>> }
>> }
>> 
>>
>>
>> On Mon, 5 Apr 2021, 01:31 Som Lima,  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,  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  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 

Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Som Lima
This is the pom.xml


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;>

4.0.0

com.example
heroku-webapp
war
1.0-SNAPSHOT
heroku-webapp


3.0.1
UTF-8
11.0.1
false





org.glassfish.jersey
jersey-bom
${jersey.version}
pom
import






org.eclipse.jetty
jetty-annotations
11.0.2



org.glassfish.jersey.containers
jersey-container-servlet


org.glassfish.jersey.inject
jersey-hk2




org.glassfish.jersey.media
jersey-media-json-binding


org.glassfish.jaxb
jaxb-runtime
3.0.0



org.eclipse.jetty
jetty-servlet
${jetty.version}
provided


org.eclipse.jetty
jetty-webapp
${jetty.version}
provided


org.eclipse.jetty
apache-jsp
11.0.2



org.eclipse.jetty
apache-jstl
11.0.0



org.slf4j
slf4j-simple
2.0.0-alpha0



org.glassfish.jersey.test-framework.providers
jersey-test-framework-provider-bundle
pom
test




heroku-webapp


org.apache.maven.plugins
maven-compiler-plugin
3.8.0
true

11
11



org.apache.maven.plugins
maven-dependency-plugin
2.8


copy-dependencies
package

copy-dependencies


compile





org.eclipse.jetty
jetty-maven-plugin
${jetty.version}

/

/
.*/.*jersey-[^/]\.jar$

${project.build.directory}/${project.build.finalName}.war










On Mon, 5 Apr 2021, 06:29 Som Lima,  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();
> }
> }
> 
>
>
> On Mon, 5 Apr 2021, 01:31 Som Lima,  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,  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  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,  wrote:

>  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 /*, 

Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Som Lima
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();
}
}



On Mon, 5 Apr 2021, 01:31 Som Lima,  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,  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  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,  wrote:
>>>
  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 /*, 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 
 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.
>
> 
> https://jakarta.ee/xml/ns/jakartaee; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance;
> xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
> 

Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Som Lima
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,  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  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,  wrote:
>>
>>>  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 /*, 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  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.

 
 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">

 
 Jersey Web Application

 org.glassfish.jersey.servlet.ServletContainer
 

 jersey.config.server.provider.packages
 com.example
 
 1
 
 
 Jersey Web Application
 /*
 


 
 index.jsp
 

 


 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 

Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Greg Wilkins
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  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,  wrote:
>
>>  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 /*, 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  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.
>>>
>>> 
>>> 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">
>>>
>>> 
>>> Jersey Web Application
>>>
>>> org.glassfish.jersey.servlet.ServletContainer
>>> 
>>>
>>> jersey.config.server.provider.packages
>>> com.example
>>> 
>>> 1
>>> 
>>> 
>>> Jersey Web Application
>>> /*
>>> 
>>>
>>>
>>> 
>>> index.jsp
>>> 
>>>
>>> 
>>>
>>>
>>> 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  CTO http://webtide.com

Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Som Lima
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,  wrote:

>  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 /*, 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  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.
>>
>> 
>> 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">
>>
>> 
>> Jersey Web Application
>>
>> org.glassfish.jersey.servlet.ServletContainer
>> 
>>
>> jersey.config.server.provider.packages
>> com.example
>> 
>> 1
>> 
>> 
>> Jersey Web Application
>> /*
>> 
>>
>>
>> 
>> index.jsp
>> 
>>
>> 
>>
>>
>> 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


Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Joakim Erdfelt
 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 /*, 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  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.
>
> 
> 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">
>
> 
> Jersey Web Application
>
> org.glassfish.jersey.servlet.ServletContainer
> 
> jersey.config.server.provider.packages
> com.example
> 
> 1
> 
> 
> Jersey Web Application
> /*
> 
>
>
> 
> index.jsp
> 
>
> 
>
>
> 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


Re: [jetty-users] Either OR but not Both.

2021-04-04 Thread Som Lima
How can I achieve the same with embedded  jetty.



{
"Instance Configuration": {
"Host": "192.168.100.50",
"Http Port(s)": "9090",
"Https Port(s)": "",
"Instance Name": "Proud-Sablefish",
"Instance Group": "MicroShoal",
"Hazelcast Member UUID": "c17b5ccd-b495-4a92-b9ff-dd1f48c6f44d",
"Deployed": [
{
"Name": "jaxrs-service-webapp",
"Type": "war",
"Context Root": "/jaxrs-service-webapp"
}
]
}
}]]

[2021-04-04T04:07:47.417+0100] [] [INFO] [] [PayaraMicro] [tid: _ThreadID=1
_ThreadName=main] [timeMillis: 1617505667417] [levelValue: 800] [[

Payara Micro URLs:
http://192.168.100.50:9090/jaxrs-service-webapp

'jaxrs-service-webapp' REST Endpoints:
GET /jaxrs-service-webapp/v1/application.wadl
GET /jaxrs-service-webapp/v1/myresource
GET /jaxrs-service-webapp/webapi/application.wadl
GET /jaxrs-service-webapp/webapi/myresource


WADL


http://wadl.dev.java.net/2009/02;>
http://jersey.java.net/; jersey:generatedBy="Jersey:
2.30.payara-p4 2021-02-01 14:07:34"/>
http://jersey.java.net/; jersey:hint="This is simplified
WADL with user and core resources only. To get full WADL with extended
resources use the query parameter detail. Link:
http://192.168.0.38:9090/jaxrs-service-webapp/webapi/application.wadl?detail=true
"/>

http://192.168.100.50:9090/jaxrs-service-webapp/webapi/;>











index.jsp
Jersey RESTful Web Application!

Jersey resource


Visit Project Jersey website  for more information
on Jersey!



On Sat, 3 Apr 2021, 07:55 Som Lima,  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.
>
> 
> 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">
>
> 
> Jersey Web Application
>
> org.glassfish.jersey.servlet.ServletContainer
> 
> jersey.config.server.provider.packages
> com.example
> 
> 1
> 
> 
> Jersey Web Application
> /*
> 
>
>
> 
> index.jsp
> 
>
> 
>
>
> 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