views:

712

answers:

2

I'm developing a webservice with Axis2 1.4.1 on JBoss 4.2.3/Tomcat 5.5.27 and Java 1.5.0 (15-b04). It works flawlessly but when an exception happens I get a JBoss error 500 HTML page instead of an Axis2 XML/SOAP fault.

This behavoir is vexing, because it difficults to handle errors in the webservice client or in SoapUI while developing.

Can I change this to get the SOAP fault? Maybe it's just an Axis2 or JBoss parameter, but I didn't find any clue about.

EDIT: Here goes the new stacktrace:

[ERROR] WSDoAllReceiver: security processing failed
org.apache.axis2.AxisFault: WSDoAllReceiver: security processing failed
    at org.apache.rampart.handler.WSDoAllReceiver.processBasic(WSDoAllReceiver.java:214)
    at org.apache.rampart.handler.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:86)
    at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:317)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized
    at org.apache.ws.security.processor.UsernameTokenProcessor.handleUsernameToken(UsernameTokenProcessor.java:155)
    at org.apache.ws.security.processor.UsernameTokenProcessor.handleToken(UsernameTokenProcessor.java:53)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:311)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:228)
    at org.apache.rampart.handler.WSDoAllReceiver.processBasic(WSDoAllReceiver.java:211)
    ... 23 more
[ERROR] Servlet.service() para servlet AxisServlet lanzó excepción
java.lang.NullPointerException
    at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:308)
    at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:317)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
    at org.apache.axis2.engine.AxisEngine.sendFault(AxisEngine.java:520)
    at org.apache.axis2.transport.http.AxisServlet.handleFault(AxisServlet.java:416)
    at org.apache.axis2.transport.http.AxisServlet.processAxisFault(AxisServlet.java:379)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:167)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

EDIT 2: After giving the bounty I found that I was wrong about 1.2.9-SNAPSHOT version of Axiom. I built it again, made sure the jars where correctly copied to lib directory and it worked!

Finally, it was an Axiom bug, as said in the links provided by Vineet.

Thanks!

+1  A: 

Without details of the exception, I can only speculate that the web service implementation is throwing a runtime exception that is not an instance of the SOAPFault or AxisFault classes (or their children). The default behavior in JBoss, in a such a case, would be to deliver the error page in the response, since web services are servlets after all.

That usually indicates that the web service must handle the exceptions appropriately and throw an appropriate SOAP fault, to prevent the exception from trickling up the call stack.

Update

A stacktrace would help in establishing the root cause of this issue. But I'm going to shoot in the dark anyway :)

You can refer to the issue RAMPART-164 and see if that is the actual cause of the problem. To put it briefly, from the information available, one can use SOAP 1.2. I'm not sure about the fix having been propagated to AXIOM 1.2.8 though, since I did not see any reference to WSCOMMONS-343.

Vineet Reynolds
Sorry for the big delay but I was working on other projects. Four months ago I meant about the HTML page returned by JBoss/Tomcat in 500 errors.I tried to throw an AxisFault instead, but it does the same.I'm working with an Axis2 webservice with Rampart module and this last throws an exception if the client doesn't authenticate.
Dario
By the way, there is an excellent post about Rampart and the correct way to authenticate users: http://blog.sweetxml.org/2007/12/rampart-basic-examples-how-you-add-ws.html
Dario
Looks like you're not the only one : http://www.mail-archive.com/[email protected]/msg47665.html
Vineet Reynolds
I tried to upgrade to AXIOM 1.2.8, but it fails in the same way. Tomcat returns its standard 500 error HTML page instead of SOAP fault response.
Dario
I'm going to give a try to AXIOM trunk, as said in http://markmail.org/message/lg4iuc7yiogwiqh3
Dario
I didn't work too. Anyway, Vineet helped me a lot with the reference, so I give to him the current bounty.Maybe I'm doing something wrong with the compiled jars I get with Maven, but today I can't take more time around this.
Dario
Suprisingly, I changed my IDE (from Eclipse Galileo to Netbeans 6.7), download again Axis 1.4.1 and Rampart 1.4 and it works.The other thing changed is Tomcat, now working with 6.0, but I don't think it is the cause!Vineet, anyway, thanks a lot for your help!
Dario
That's surprising. Nice to know that it works. It could possibly be a classloader related issue or it could be the JARs obtained from Maven.
Vineet Reynolds
A: 

There is a bug in rampart-core jar file. MessageBuilder in RampartSender is expecting AxisService in message context while sending the response back to the client. In this case it is null which throwsa NUllpointer exception. Add a null check in the RampartMessageData and rebuild the rampart core jar and use it. The application should work fine.

AxisService service = msgCtx.getAxisService(); if (service != null) { this.customClassLoader = msgCtx.getAxisService() .getClassLoader(); }

-Mahesh Yarasi