Hi Gabo

By the way, a WebApplicationException instance which is thrown in this case 
contains Response object with the message.
Perhaps you might want to provide both RuntimeException and WebApplicationException mappers or explicitly check in the RuntimeException mapper if it's WebApplicationException or not. There's a default WebApplicationException mapper there your RuntimeException one is chosen instead of it.

Cheers, Sergey

----- Original Message ----- From: "Sergey Beryozkin" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 25, 2009 11:13 AM
Subject: Re: [CXF2.2] Runtime exception with no message


Hi Gabo

Just to add, the exception does not have a cause. fault.getCause() returns 
null. :(

I think it's because in this case (no appropriate constructor or factory nethod is available) the RuntimeException you get is the original WebApplicationException and thus there's no cause is available.

But I'd likr to clarify a bit what is it in the error reporting procedure that 
you'd like us to enhance.

The JAXRSInInterceptor in the stacktrace led me to somewhere useful in checking 
where it failed. I saw this log earlier up:

[25/Mar/2009:04:33:33] failure (24718): for host 222.127.215.98 trying to GET /some/domain/MyObjects/search, service-j2ee reports: Parameter Class some.domain.SearchObject has no constructor with single String parameter, static valueOf(String) or fromString(String) methods

So the log is available which is good. By the way, you may also want to try CXF 
JAXRS ParameterHandler  extensions
if neither of the above conditions can be satisfied and when the code 
modification is not an option...


I am going to modify my code to include all the cause exceptions when available. But would it be possible to echo the message up the stream? I mean, it seems unnecessary to include all the causes when a message from the root cause echoed at the latest exception could easily give an idea of what caused the problem.

I'm sorry - can you clarify this bit ?

Thanks, Sergey

----- Original Message ----- From: "Gabo Manuel" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 25, 2009 5:35 AM
Subject: Re: [CXF2.2] Runtime exception with no message


Hi All,

Just to add, the exception does not have a cause. fault.getCause() returns 
null. :(

Gabo

Gabo Manuel wrote:
Hi All,

I encountered this during one of my test:

Service.java:
   @GET
   @Path("/search/")
   @WebMethod
   public MyObjects getMyObjects(
           @HeaderParam("uri")
           @WebParam(name="searchObject")
           SearchObject so) {
   }

SearchObject.java:
@XmlRootElement
@XmlType(name="SearchObject")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class SearchObject {
   public SearchObject(){
   }
   //important point here is that there is no other constructor other than 
default.
}

I accessed the said method and encountered the following exception:
javax.ws.rs.WebApplicationException
at 
org.apache.cxf.jaxrs.utils.InjectionUtils.reportServerError(InjectionUtils.java:237)
at 
org.apache.cxf.jaxrs.utils.InjectionUtils.handleParameter(InjectionUtils.java:224)
at 
org.apache.cxf.jaxrs.utils.InjectionUtils.createParameterObject(InjectionUtils.java:404)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processHeaderParam(JAXRSUtils.java:594)
at 
org.apache.cxf.jaxrs.utils.JAXRSUtils.createHttpParameterValue(JAXRSUtils.java:495)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:442)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:397)
at 
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:182)
at 
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:65)
at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at 
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
at 
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
at 
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:337)
at 
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:145)
at 
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
at 
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:145)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at 
org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at 
com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)

The above print out is generated as:

//this is registered as a provider.
RuntimeExceptionMapper.java:
   private String generateMessage(RuntimeException fault, String subject){
       String appDir = new File(".").getAbsolutePath();

       //TODO: turn this to html for better viewing.
       StringBuffer sb = new StringBuffer();
       sb.append("\r\n");
       sb.append("\r\nApplication location: ").append(appDir);
       sb.append("\r\n");
sb.append("\r\nProblem encountered: ").append((fault.getMessage()==null || fault.getMessage().length()<1)?"No message":fault.getMessage());
       sb.append("\r\n");
       sb.append("\r\nStack trace: ");
             for(StackTraceElement ste : fault.getStackTrace()){
           sb.append("\t").append(ste.toString()).append("\r\n");
       }

       return sb.toString();
   }

The JAXRSInInterceptor in the stacktrace led me to somewhere useful in checking 
where it failed. I saw this log earlier up:

[25/Mar/2009:04:33:33] failure (24718): for host 222.127.215.98 trying to GET /some/domain/MyObjects/search, service-j2ee reports: Parameter Class some.domain.SearchObject has no constructor with single String parameter, static valueOf(String) or fromString(String) methods

I am going to modify my code to include all the cause exceptions when available. But would it be possible to echo the message up the stream? I mean, it seems unnecessary to include all the causes when a message from the root cause echoed at the latest exception could easily give an idea of what caused the problem.

Thanks.

Gabo
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.0.238 / Virus Database: 270.11.25/2019 
- Release Date: 03/23/09 18:51:00




Reply via email to