Topic
  • 1 reply
  • Latest Post - ‏2008-05-13T19:20:22Z by SystemAdmin
SystemAdmin
SystemAdmin
2233 Posts

Pinned topic Creating WebFault in WASCE

‏2008-04-28T17:58:36Z |
I can't make WebFault to work properly.
Here is the method from the calculator WS that throws it:




public 

int sumFault(

int a, 

int b) 

throws MyException 
{ 

if(a>10) 

throw 

new MyException(); 

return 0; 
}


Here is MyException class:


@WebFault(faultBean = 
"MyExceptionFault", name = 
"MyFault") 

public 

class MyException 

extends Exception 
{ 
}

And Here is the Fault bean:


@XmlRootElement(name = 
"MyExceptionFault", namespace = 
"http://ejb.br/") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name=
"br.ejb.MyException") 

public 

class MyFaultBean 
{ 
}


And unfortunately i'm getting the following NPE:


17:59:27,332 ERROR [Axis2WebServiceContainer] Exception occurred 

while trying to invoke service method doService() org.apache.axis2.AxisFault at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:131) at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:172) at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:113) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275) at org.apache.geronimo.axis2.pojo.POJOWebServiceContainer.processPOSTRequest(POJOWebServiceContainer.java:120) at org.apache.geronimo.axis2.Axis2WebServiceContainer.doService2(Axis2WebServiceContainer.java:265) at org.apache.geronimo.axis2.Axis2WebServiceContainer.doService(Axis2WebServiceContainer.java:204) at org.apache.geronimo.axis2.Axis2WebServiceContainer.invoke(Axis2WebServiceContainer.java:167) at org.apache.geronimo.webservices.WebServiceContainerInvoker.service(WebServiceContainerInvoker.java:84) at org.apache.geronimo.webservices.POJOWebServiceServlet.service(POJOWebServiceServlet.java:79) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56) at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:396) at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:810) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invokeService(JavaBeanDispatcher.java:163) at org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:90) ... 26 more Caused by: br.ejb.MyException at br.ejb.CalculatorBean.sumFault(CalculatorBean.java:27) ... 32 more 17:59:27,352 ERROR [[TestWS]] Servlet.service() 

for servlet TestWS threw exception javax.xml.ws.soap.SOAPFaultException: java.lang.NullPointerException at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1192) at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:943) at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalFaultResponse(DocLitWrappedMethodMarshaller.java:515) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:386) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:362) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:284) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:141) at $Proxy65.sumFault(Unknown Source) at br.client.TestWS.doGet(TestWS.java:63) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56) at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:396) at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:810)


By the stack trace it looks like it's being correctly initially thrown, however then it throws a NullPointerException in the Axis2 stack.

It seems to be related to the Complex Types issue:
Complex types forum entry

Message was edited by: Rafael Coutinho(Rcouto)

Message was edited by: Rafael Coutinho(Rcouto)
Updated on 2008-05-13T19:20:22Z at 2008-05-13T19:20:22Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2233 Posts

    Re: Creating WebFault in WASCE

    ‏2008-05-13T19:20:22Z  
    Actually the problem was with my code. Jax-ws specifies that that any webfault class must implement the method getFaultInfo() and I was not implementing it.

    The JAX-WS 2.0 specification demands that the exception annotated with @WebFault must have two constructors and one method:
    WrapperException(String message, FaultBean faultInfo)
    WrapperException(String message, FaultBean faultInfo, Throwable cause)
    FaultBean getFaultInfo()
    The WrapperException is replaced by the name of the exception, and FaultBean is replaced by the class name that implements the fault bean. The fault bean is a Java bean that contains the information of the fault and is used by the Web service client to know the cause for the fault.

    It works fine now.