4 Replies Latest reply on May 16, 2007 5:53 AM by heiko.braun

    Server-side NullpointerException when using ws-security

    openyourmind

      Hello,

      I have some problems using ws-security.

      My WS runs correctly without wssecurity, but when I activate it I get an strange server-side NullPointerException.

      My config is :
      - jboss 4.0.5.GA EJB3 config
      - jbossws-1.2.0.GA
      - jdk 1.5_08

      This is what we get in the server log from the server start up until the exception.

      
      2007-03-19 22:21:38,895 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)] Started in 48s:327ms
      2007-03-19 22:29:00,239 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
      2007-03-19 22:29:01,749 DEBUG [org.jboss.ws.core.server.ServiceEndpoint] WSDL request, using host: chaponniere-linux
      2007-03-19 22:29:01,791 DEBUG [org.jboss.ws.core.server.ServiceEndpoint] WSDL request, using host: chaponniere-linux
      2007-03-19 22:29:05,181 DEBUG [org.jboss.ws.core.server.AbstractServiceEndpointServlet] doPost: /procedures-beans/PstProcedureManager
      2007-03-19 22:29:05,189 DEBUG [org.jboss.ws.core.soap.MessageContextAssociation] pushMessageContext: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@1757322 (Thread http-0.0.0.0-8080-1)
      2007-03-19 22:29:05,190 DEBUG [org.jboss.ws.core.server.ServiceEndpoint] BEGIN handleRequest: jboss.ws:context=procedures-beans,endpoint=PstProcedureManager
      2007-03-19 22:29:05,220 DEBUG [org.jboss.ws.core.soap.MessageFactoryImpl] createMessage: [contentType=text/xml; charset=UTF-8]
      2007-03-19 22:29:05,245 DEBUG [javax.xml.soap.FactoryLoader] Load from Service API META-INF/services/javax.xml.soap.SOAPFactory: org.jboss.ws.core.soap.SOAPFactoryImpl
      2007-03-19 22:29:05,245 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@12c4d8f, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@c6948c{ url=null ,addedOrder=0}
      2007-03-19 22:29:05,265 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS] callRequestHandlerChain: PRE
      2007-03-19 22:29:05,266 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] initHandlerChain: PRE
      2007-03-19 22:29:05,266 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] Clear handler map: {}
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] addHandler: [service=null,port=null,binding=http://schemas.xmlsoap.org/wsdl/soap/http]:WSSecurity Handler
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] initHandlerChain: ENDPOINT
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] Clear handler map: {}
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] initHandlerChain: POST
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] Clear handler map: {}
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] getHandlerChain: [type=PRE,info=[service={http://procedure.procedures/}PstProcedureManagerService,port={http://procedure.procedures/}PstProcedureManagerPort,binding=http://schemas.xmlsoap.org/wsdl/soap/http]]
      2007-03-19 22:29:05,268 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl] add protocol handlers: [WSSecurity Handler]
      2007-03-19 22:29:05,274 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Create a handler executor: [WSSecurity Handler]
      2007-03-19 22:29:05,274 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Enter: handleRequest
      2007-03-19 22:29:05,279 DEBUG [org.jboss.ws.core.soap.SOAPMessageDispatcher] getDispatchDestination: null
      2007-03-19 22:29:05,279 ERROR [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Exception during handler processing
      java.lang.NullPointerException
       at org.jboss.ws.extensions.security.WSSecurityDispatcher.handleInbound(WSSecurityDispatcher.java:130)
       at org.jboss.ws.extensions.security.jaxws.WSSecurityHandler.handleInboundSecurity(WSSecurityHandler.java:59)
       at org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer.handleInbound(WSSecurityHandlerServer.java:41)
       at org.jboss.ws.core.jaxws.handler.GenericHandler.handleMessage(GenericHandler.java:55)
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:276)
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleRequest(HandlerChainExecutor.java:112)
       at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callRequestHandlerChain(HandlerDelegateJAXWS.java:65)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.callRequestHandlerChain(AbstractServiceEndpointInvoker.java:106)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:140)
       at org.jboss.ws.core.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:204)
       at org.jboss.ws.core.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:440)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      2007-03-19 22:29:05,280 DEBUG [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Exit: handleRequest with status: false
      2007-03-19 22:29:05,282 ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
      javax.xml.ws.WebServiceException: java.lang.NullPointerException
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.processHandlerFailure(HandlerChainExecutor.java:262)
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleRequest(HandlerChainExecutor.java:124)
       at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callRequestHandlerChain(HandlerDelegateJAXWS.java:65)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.callRequestHandlerChain(AbstractServiceEndpointInvoker.java:106)
       at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:140)
       at org.jboss.ws.core.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:204)
       at org.jboss.ws.core.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:440)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NullPointerException
       at org.jboss.ws.extensions.security.WSSecurityDispatcher.handleInbound(WSSecurityDispatcher.java:130)
       at org.jboss.ws.extensions.security.jaxws.WSSecurityHandler.handleInboundSecurity(WSSecurityHandler.java:59)
       at org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer.handleInbound(WSSecurityHandlerServer.java:41)
       at org.jboss.ws.core.jaxws.handler.GenericHandler.handleMessage(GenericHandler.java:55)
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:276)
       at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleRequest(HandlerChainExecutor.java:112)
       ... 28 more
      
      



      My client-side code

      
      wsdlURL = new URL("http://chaponniere-linux:8080/procedures-beans/PstProcedureManager?wsdl");
       URL securityURL = new File("jboss-wsse-client.xml").toURL();
       QName serviceName = new QName("http://procedure.procedures/", "PstProcedureManagerService");
      
       Service service = Service.create(wsdlURL, serviceName);
       ((ServiceExt)service).setSecurityConfig(securityURL.toExternalForm());
      
       PstProcedureManager port = (PstProcedureManager)service.getPort(PstProcedureManager.class);
       //Hello port = (Hello)service.getPort(Hello.class);
       ((StubExt)port).setConfigName("Standard WSSecurity Client");
      
      
       Map<String, Object> reqContext = ((BindingProvider)port).getRequestContext();
       //reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/jaxws-samples-wssecurity-encrypt");
       reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://chaponniere-linux:8080/procedures-beans/PstProcedureManager?wsdl");
      
       String procedureNumber = port.getProcedure(1).getNumber();
       System.out.println(procedureNumber);
      
      


      And finally my WS.

      
      @WebService
      @EndpointConfig(configName = "Standard WSSecurity Endpoint")
      public class PstProcedureManager implements PstProcedureInterface {
      
       @PersistenceContext
       protected EntityManager em;
      
       @WebMethod
       public PstProcedureBean getProcedure(int pId) {
       Collection procedureCol =
       em.createQuery("from PstProcedureBean procedureBean where procedureBean.id = :id")
       .setParameter ("id", pId)
       .getResultList();
      
      
       return (PstProcedureBean)procedureCol.iterator().next();
       }
      }
      
      


      I cannot see where the problem might come from and I would greatly appreciate your help with this issue.

      Thanks in advance
      M.

        • 1. Re: Server-side NullpointerException when using ws-security
          jason.greene

          This looks like a bug. Thanks for the thorough report
          http://jira.jboss.com/jira/browse/JBWS-1592

          • 2. Re: Server-side NullpointerException when using ws-security
            peterj

            I got this error before. It was either because I did not make the META-INF/standard-jaxws-client-config.xml, or I did not remove the configurations other than Standard WSSecurity Client from that file, or because I did not reference the truststores in either the jboss-wsse-clsient.xml or jboss-wsse-server.xml files. (It's been several days and several millions errors since that happened, but if the above suggestions don't solve the problem let me know and I will see if I can reproduce it.)

            • 3. It works now
              openyourmind

              Hi all,

              It works now!!! Thanks for your answers.

              This is what we did to correct our issue:

              BEFORE we used the following command to generate the keys

              keytool -genkey -alias procedure_key -keystore wsse_procedure.keystore
              

              NOW, we use the following command where we explicitly set RSA as the key algorithm
              keytool -genkey -alias procedure_key -keystore wsse_procedure.keystore -keyalg RSA
              

              I have to say that the exception message or logs didn't help us much to find our issue. So I guess we were pretty lucky.

              Thanks again for your suggestions and see you soon
              OYM


              • 4. Re: Server-side NullpointerException when using ws-security
                heiko.braun

                Could you provide me with the SOAP messages in transit that have been causing this error?
                I am unable to reproduce the exception. But I am pretty sure it's a client side configuration problem.
                The messages send from the client have to plain SOAP messages, lacking security headers. But in order to verify i'll need some example requests.