Sorry, It is because I create singleton Sessionhandler and share it across multiple WebAppContext as a way of sharing sessions among them.
This method worked fine in Jetty 9.3 but doesn't seem to work with new Session Management. Are there any other alternatives and/or workaround for this issue? Eg) MyCustomSessionHandler h = new MyCustomSessionHandler(); context1.setSessionHandler(h); context2.setSessionhandler(h); From: Raghavan, Aravind Sent: Friday, September 08, 2017 5:39 PM To: '[email protected]' <[email protected]> Subject: RE: jetty 9.4.6 - getting null servletcontext in servlets Upon further trouble shooting I found out it is related to new changes to 9.4.x session management changes. As long as I use the default session handler everything works fine. But when I attach a custom session handler the WebAppContext the servlets are not initialized with servletcontext. //offending code Context.setSessionHandler(new MyCustomSessionHandler()); Public class MyCustomSessionHandler extends Sessionhandler { Public MyCustomSessionHandler() { Super(); } } From: Raghavan, Aravind Sent: Friday, September 08, 2017 11:05 AM To: '[email protected]' <[email protected]<mailto:[email protected]>> Subject: jetty 9.4.6 - getting null servletcontext in servlets Hi All, I recently upgraded from jetty 9.3.11 to 9.4.6 . And after upgrade none of my servlets are able to get servlet context. getServletContext() always returns null. Can you please help me figure out what I am doing wrong? Relevant section of code: handlers_ = new HandlerCollection(true); chc_ = new ContextHandlerCollection(); for(WebAppConfig wap: webAppConfigs) //webappconfig a POJO from where I am getting webapp configs { String path = wap.getPath(); String warFile = wap.getWarFile(); WebAppContext context = new WebAppContext(chc_, warFile, path); chc_.addHandler(context); context.setContextPath(path); for (ServletConfig servletConfig: wap.getServletConfigs()) //ServletConfig is another POJO to get servlet configs { String servletName = servletConfig.getName(); String servletPath = servletConfig.getPath(); Servlet servlet = servletConfig.getServlet(); ServletHolder servletHolder = new ServletHolder(servlet); context.addServlet(servletHolder, servletPath); } } handlers_.setHandlers(new Handler[] { chc_, new DefaultHandler()}); server_.setHandler(handlers_); Note the same code worked fined with 9.3.11. Getting null context only after upgrading to 9.4.6. I am not sure what has changed in 9.4.x to cause this issue. I can't find any changes (other than Session Management) in documentation. Thanks, Aravind.
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
