@Override public void contextInitialized(ServletContextEvent servletContextEvent){
  super.contextInitialized(servletContextEvent);
  ServletContext servletContext=servletContextEvent.getServletContext();
  RemotingServlet remotingServlet=new RemotingServlet();
  try {
    remotingServlet.init(new CubaServletConfig("remoting",servletContext));
  }
 catch (  ServletException e) {
    throw new RuntimeException("An error occurred while initializing remoting servlet",e);
  }
  ServletRegistration.Dynamic remotingReg=servletContext.addServlet("remoting",remotingServlet);
  remotingReg.addMapping("/remoting/*");
  remotingReg.setLoadOnStartup(0);
  FilterRegistration.Dynamic filterReg=servletContext.addFilter("CoreSingleWarHttpFilter",new SetClassLoaderFilter());
  filterReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),false,"/remoting/*");
}

@ Override public void contextInitialized ( ServletContextEvent servletContextEvent ) { super . contextInitialized ( servletContextEvent ) ; ServletContext servletContext = servletContextEvent . getServletContext ( ) ; RemotingServlet remotingServlet = new RemotingServlet ( ) ; try { remotingServlet . init ( new CubaServletConfig ( "remoting" , servletContext ) ) ; } catch ( ServletException e ) { throw new RuntimeException ( "An error occurred while initializing remoting servlet" , e ) ; } ServletRegistration . Dynamic remotingReg = servletContext . addServlet ( "remoting" , remotingServlet ) ; remotingReg . addMapping ( "/remoting/*" ) ; remotingReg . setLoadOnStartup ( 0 ) ; FilterRegistration . Dynamic filterReg = servletContext . addFilter ( "CoreSingleWarHttpFilter" , new SetClassLoaderFilter ( ) ) ; filterReg . addMappingForUrlPatterns ( EnumSet . of ( DispatcherType . REQUEST ) , false , "/remoting/*" ) ; }
here we create servlets and filters manually , to make sure the classes would be loaded using necessary classloader .
