Some background:
I'm trying to use SSL mutual authentication for some Axis2 services we're exposing. The problem is that Axis2 built-in server doesn't support that. So I want to use embedded Jetty to achieve that and deploy the AxisServlet in it.
Problem:
There seems to be no way of passing the AxisConfiguration (containing the definition of all the available services) to the servlet directly.
How I'm trying to do it:
ConfigurationContext context = ConfigurationContextFactory.createDefaultConfigurationContext();
File serviceArchiveFile = new File("<path to my aar file which is loaded properly>");
AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(serviceArchiveFile, context);
AxisConfiguration axiConfiguration = context.getAxisConfiguration();
axiConfiguration.addServiceGroup(serviceGroup);
AxisServlet axisServlet = new AxisServlet();
Server server = new Server(8080);
org.mortbay.jetty.servlet.Context root = new org.mortbay.jetty.servlet.Context(server,"/",org.mortbay.jetty.servlet.Context.SESSIONS);
ServletHolder holder=new ServletHolder(axisServlet);
// Trying to pass the Config context via the parameters map
Map parameters = new HashMap();
parameters.put(AxisServlet.CONFIGURATION_CONTEXT, context);
holder.setInitParameters(parameters);
root.addServlet(holder,"/services/*");
server.start();
The problem with that approach is that the init(ServletConfig) method of the AxisServlet is never call so I get a nullPointer exception whenever I try to call the service on 8080:
java.lang.NullPointerException
at org.apache.axis2.transport.http.AxisServlet.initContextRoot(AxisServlet.java:586)
at org.apache.axis2.transport.http.AxisServlet.preprocessRequest(AxisServlet.java:605)
at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:442)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:356)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:226)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:615)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:141)
at org.mortbay.jetty.Server.handle(Server.java:265)
at org.mortbay.jetty.HttpConnection.handlerRequest(HttpConnection.java:420)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:666)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:487)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:197)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:336)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:183)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
According to Axis2 source code, this happens because the config context is never set in the AxisServlet. So now the big questions are:
1) Is that possible to set the config context directly in AxisServlet? I didn't find any way of doing so
2) Why is Jetty not sending the init paremeters and not calling the init(ServletConfig config) method on the servlet? I confirmed with debugger that it is never called.