It would be useful if you could provide either a pointer to your project or a minimum reproducible example. The exact stacktrace you get would also be useful.
Jan On Tue, 8 Feb 2022 at 09:29, <ch...@chrisnewland.com> wrote: > Hi, > > I'm having trouble migrating a Jersey/Jetty project (2.25) to Jersey 3 / > Jetty 11. > > The Jersey part is working fine and I can serve requests using > jersey-container-simple-http with a ResourceConfig to specify the > service and filter classes. > > When I try to use a Jetty 11 jersey-container-jetty-http container to > add static resources and HttpServletRequest session handling I'm unable > to work out the correct steps to convert the code below to use the > latest APIs. > > The HttpServletRequest injected by @Context is always null and I think > I'm hitting the same problem as this post: > > https://stackoverflow.com/questions/68623182/cant-inject-httpservletrequest-into-containerrequestfilter-with-javal-11-jetty > > My pom dependencies are: > > <jersey.version>3.0.3</jersey.version> > > <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> > > <dependency> > <groupId>org.glassfish.jersey.containers</groupId> > <artifactId>jersey-container-jetty-http</artifactId> > </dependency> > > <dependency> > <groupId>org.glassfish.jersey.inject</groupId> > <artifactId>jersey-hk2</artifactId> > </dependency> > > <dependency> > <groupId>jakarta.servlet</groupId> > <artifactId>jakarta.servlet-api</artifactId> > <version>5.0.0</version> > </dependency> > > <dependency> > <groupId>org.glassfish.jersey.media</groupId> > <artifactId>jersey-media-json-jackson</artifactId> > </dependency> > > > And advice would be greatly appreciated please. > > Many thanks, > > Chris > > > > ResourceConfig config = new ResourceConfig(); > > config.packages(stuff); > > Server server = new Server(new InetSocketAddress("0.0.0.0", port)); > > ServletContextHandler context = new ServletContextHandler(server, "/", > ServletContextHandler.SESSIONS); > > SessionHandler sessions = context.getSessionHandler(); > > SessionCache cache = new DefaultSessionCache(sessions); > > cache.setSessionDataStore(new NullSessionDataStore()); > > sessions.setSessionCache(cache); > > Path staticResourcePath = resourcesPath.resolve("static"); > > ServletHolder holderHome = new ServletHolder("static-home", > DefaultServlet.class); > > holderHome.setInitParameter("resourceBase", > staticResourcePath.toString()); > holderHome.setInitParameter("dirAllowed", "true"); > holderHome.setInitParameter("pathInfoOnly", "true"); > > context.addServlet(holderHome, "/static/*"); > > ServletHolder holderDefault = new ServletHolder("default", > DefaultServlet.class); > context.addServlet(holderDefault, "/"); > > ServletHolder servletHolder = new ServletHolder(new > ServletContainer(config)); > > context.addServlet(servletHolder, "/*"); > > try > { > server.start(); > server.join(); > } > catch (Throwable t) > { > t.printStackTrace(); > } > finally > { > server.destroy(); > } > _______________________________________________ > jetty-users mailing list > jetty-users@eclipse.org > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users > -- Jan Bartel <j...@webtide.com> www.webtide.com *Expert assistance from the creators of Jetty and CometD*
_______________________________________________ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users