Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] My CORS proxy using Jersey (for JAX-RS) with Jetty 9.4.31 doesn't respond

Thank you for your help, I've just found the solution. Using @ApplicationPath while declaring the javax.ws.rs.Application implementation in web.xml without setting the servlet mapping in the same file was a bad idea. I thought about that when you suggested to add a "/" at the beginnging of the path:

 

diff --git a/src/main/java/fr/gouesse/julien/jaxrs/RedFeedAggregatorApplication.java b/src/main/java/fr/gouesse/julien/jaxrs/RedFeedAggregatorApplication.java
index 0af216b..e4322e5 100644
--- a/src/main/java/fr/gouesse/julien/jaxrs/RedFeedAggregatorApplication.java
+++ b/src/main/java/fr/gouesse/julien/jaxrs/RedFeedAggregatorApplication.java
@@ -5,7 +5,6 @@ import java.util.Set;
 import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.core.Application;
 
-@ApplicationPath("webresources")
 public class RedFeedAggregatorApplication extends Application {
 
     @Override
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index a0ba8a8..a386c83 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -418,13 +418,18 @@
 
   <!-- servlet for the web services -->
   <servlet>
-    <servlet-name>fr.gouesse.julien.jaxrs.RedFeedAggregatorApplication</servlet-name>
+    <servlet-name>jersey</servlet-name>
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
     <init-param>
-        <param-name>jersey.config.server.provider.packages</param-name>
-        <param-value>fr.gouesse.julien.jaxrs</param-value>
+        <param-name>javax.ws.rs.Application</param-name>
+        <param-value>fr.gouesse.julien.jaxrs.RedFeedAggregatorApplication</param-value>
     </init-param>
     <load-on-startup>1</load-on-startup>
   </servlet>
+
+  <servlet-mapping>
+    <servlet-name>jersey</servlet-name>
+    <url-pattern>/webresources/*</url-pattern>
+  </servlet-mapping>
 </web-app>

 

 

> Message du 07/08/20 08:56
> De : "Simone Bordet" <sbordet@xxxxxxxxxxx>
> A : gouessej@xxxxxxxxx
> Copie à : "Simone Bordet" <sbordet@xxxxxxxxxxx>, "JETTY user mailing list" <jetty-users@xxxxxxxxxxx>
> Objet : Re: [jetty-users] My CORS proxy using Jersey (for JAX-RS) with Jetty 9.4.31 doesn't respond
>
> Hi,
>
> On Fri, Aug 7, 2020 at 6:57 AM <gouessej@xxxxxxxxx> wrote:
> >
> > I still get an HTTP error 404 with your suggestion.
> >
> >
> >
> > diff --git a/src/main/java/fr/gouesse/julien/jaxrs/CorsProxyResource.java b/src/main/java/fr/gouesse/julien/jaxrs/CorsProxyResource.java
> > index 1e0c09c..ee0f4f0 100644
> > --- a/src/main/java/fr/gouesse/julien/jaxrs/CorsProxyResource.java
> > +++ b/src/main/java/fr/gouesse/julien/jaxrs/CorsProxyResource.java
> > @@ -20,7 +20,7 @@ import javax.ws.rs.core.MediaType;
> >
> > import javax.ws.rs.core.Response;
> > import javax.ws.rs.core.Response.Status;
> >
> > -@Path("corsproxy")
> > +@Path("webresources/corsproxy")
>
> Don't you need a "/" at the beginning of the path?
>
> --
> Simone Bordet
> ----
> http://cometd.org
> http://webtide.com
> Developer advice, training, services and support
> from the Jetty & CometD experts.
>

Back to the top