Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] 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.

 

 


Back to the top