1 Reply Latest reply on Jan 21, 2011 6:40 AM by Timo Wiedenmann

    Custom exception not thrown

    Timo Wiedenmann Newbie

      Hello,

       

      i have a problem throwing a custom exception in a web method - the stacktrace lead me to a NPE in

      I use JBoss 4.2.2 GA and JBossWS 3.0.5 native.

       

      In the web service class i defined 2 methods, which are just throwing a custom exception -

      one method without parameters and one with 1 input parameter:

       

       

      {code}

      @Stateless

      @WebService

      @WebContext(contextRoot = ConfigConstants.CONTEXT_ROOT,

                  authMethod = ConfigConstants.AUTH_METHOD,

                  transportGuarantee = ConfigConstants.TRANSPORT_GUARANTEE,

                  secureWSDLAccess = ConfigConstants.SECURE_WSDL_ACCESS)

      @SOAPBinding(style= SOAPBinding.Style.RPC)

      @RolesAllowed({ConfigConstants.ROLE_USI_USER})

      @SecurityDomain(ConfigConstants.SECURITY_DOMAIN)

      public class TestServer

      {

        @WebMethod

        @WebResult(name = "companyList")

        public CompanyList getAvailabeCompanyList() throws SystemException

        {

          if(true) throw new SystemException("getAvailabeCompanyList ");

          return null;

        }

       

        @WebMethod

        @WebResult(name = "companyList2")

        public CompanyList getAvailabeCompanyList2(

          @WebParam(name = "str") String str

        ) throws SystemException

        {

          if(true) throw new SystemException("getAvailabeCompanyList2 " + str);

          return null;

        }

      }

      {code}

       

       

      When i call the methods, the one with an input parameter (getAvailabeCompanyList2) correctly throws the exception,

      but the method without input parameter fails with the following stacktrace:

       

       

      {noformat}

      20:42:41,707 ERROR [SOAPFaultHelperJAXWS] SOAP request exception

      com.creados.gksst.base.transferobject.SystemException: getAvailabeCompanyList

      ...

      20:42:41,719 DEBUG [JAXBSerializer] serialize: [xmlName={http://impl.facade.gksst.creados.com/}SystemException,xmlType={http://impl.facade.gksst.creados.com/}SystemException]

      20:42:41,720 WARN  [ServiceEndpointInvoker] Exception while processing handleFault:

      com.creados.gksst.base.transferobject.SystemException: getAvailabeCompanyList

              at com.creados.gksst.facade.impl.GkSstServer.getAvailabeCompanyList(GkSstServer.java:115)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)

              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)

              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)

              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)

              at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:115)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)

              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)

              at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:219)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)

              at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.hyperic.hq.product.servlet.filter.JMXFilter.doFilter(JMXFilter.java:324)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)

              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

              at java.lang.Thread.run(Thread.java:619)

      20:42:41,720 ERROR [SOAPFaultHelperJAXWS] SOAP request exception

      javax.xml.ws.WebServiceException: java.lang.NullPointerException

              at org.jboss.ws.core.jaxws.JAXBSerializer.handleMarshallException(JAXBSerializer.java:143)

              at org.jboss.ws.core.jaxws.JAXBSerializer.serialize(JAXBSerializer.java:86)

              at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toDetailEntry(SOAPFaultHelperJAXWS.java:359)

              at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:277)

              at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:187)

              at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:102)

              at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:671)

              at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:277)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)

              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)

              at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.hyperic.hq.product.servlet.filter.JMXFilter.doFilter(JMXFilter.java:324)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)

              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

              at java.lang.Thread.run(Thread.java:619)

      Caused by: java.lang.NullPointerException

              at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)

              at java.util.Arrays.asList(Arrays.java:3343)

              at org.jboss.ws.core.jaxws.JAXBSerializer.getClassesForContextCreation(JAXBSerializer.java:108)

              at org.jboss.ws.core.jaxws.JAXBSerializer.serialize(JAXBSerializer.java:68)

              ... 34 more

      20:42:41,722 DEBUG [SOAPFaultHelperJAXWS] Cannot obtain fault meta data for: class javax.xml.ws.WebServiceException

      ...

       

      {noformat}

       

      The client recieves

       

      {noformat}

           [java] javax.xml.ws.soap.SOAPFaultException: java.lang.NullPointerException

           [java]     at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:188)

           [java]     at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)

           [java]     at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

           [java]     at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

           [java]     at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

           [java]     at $Proxy29.getAvailabeCompanyList(Unknown Source)

      {noformat}

      instead of the custom exception.

       

      For the other method, its the supposed one:

       

      {noformat}

           [java] com.creados.gksst.testclient.delegate.facade.SystemException_Exception: getAvailabeCompanyList2 teststring

           [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

           [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

           [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

           [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

           [java]     at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:127)

           [java]     at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

           [java]     at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

           [java]     at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

           [java]     at $Proxy29.getAvailabeCompanyList2(Unknown Source)

      {noformat}

       

       

      So here the questions:

      - Do i have an error in the code ?

      - Is this a bug ?

      - If yes, is it known or even fixed ?

       

      Any hint or solution is welcome.

      Best regards,

      Timo