cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Franken (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CXF-1858) JAXRSOutInterceptor throws NullPointerException for unknown requests when using exception mapper
Date Wed, 05 Nov 2008 17:57:44 GMT

    [ https://issues.apache.org/jira/browse/CXF-1858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645270#action_12645270
] 

Alex Franken commented on CXF-1858:
-----------------------------------

I have also updated to 2.1.3.  The following ExceptionMapper throws an exception.  I have
also included the skeleton of the service class.  My use case is sending a "PUT" request to
the expandPatient service.

@Provider
public class FaultExceptionMapper implements ExceptionMapper<Fault> {
	protected final Log log = LogFactory.getLog(getClass());

	@Override
	public Response toResponse(Fault fault) {
		log.debug("Fault thrown:"+fault.getCode()+":"+fault.getMessage());
		log.error(fault.getMessage(),fault);
		/* works
		 * return Response.status(Response.Status.NOT_FOUND).build();
		 */
		 return Response.status(Response.Status.NOT_FOUND)
		 	.type("text/plain;charset=utf-8")
		 	.entity("THIS IS A TEST ENTITY-BODY").build();        
	}
}

@Path("/PatientService")
@ProduceMime("application/xml")
public class RESTfulPatientServiceImpl extends AbstractRESTfulService implements PatientService
{

       ....

	@GET
	@Path("/expandPatient/{institutionID}/{medicalRecordNumber}")
	public DOMSource expandPatient(@PathParam("institutionID")String institutionID, @PathParam("medicalRecordNumber")String
medicalRecordNumber){

        }
}

Stack Trace:
Nov 5, 2008 12:52:05 PM org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
----------------------------
Encoding: UTF-8
Headers: {cache-control=[max-age=0], connection=[keep-alive], accept-language=[en-us,en;q=0.5],
host=[localhost:8180], keep-alive=[300], user-agent=[Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.9.0.3) Gecko/2008092510 Ubuntu/8.04 (hardy) Firefox/3.0.3], accept-encoding=[gzip,deflate],
Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7]}
Messages: 
Message:

Payload: 
--------------------------------------
Nov 5, 2008 12:52:05 PM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor processRequest
SEVERE: .No operation matching request path /PatientService/expandPatient/1/9/1/ is found,
ContentType : */*, Accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
2008/11/05 12:52:05:446 EST [DEBUG] FaultExceptionMapper - Fault thrown:NO_OP_EXC:.No operation
matching request path /PatientService/expandPatient/1/9/1/ is found, ContentType : */*, Accept
: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
2008/11/05 12:52:05:447 EST [ERROR] FaultExceptionMapper - .No operation matching request
path /PatientService/expandPatient/1/9/1/ is found, ContentType : */*, Accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
<org.apache.cxf.interceptor.Fault: .No operation matching request path /PatientService/expandPatient/1/9/1/
is found, ContentType : */*, Accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.>org.apache.cxf.interceptor.Fault:
.No operation matching request path /PatientService/expandPatient/1/9/1/ is found, ContentType
: */*, Accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:195)
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:65)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
	at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:285)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:131)
	at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:175)
	at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:157)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	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:151)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	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:619)

Nov 5, 2008 12:52:05 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:150)
	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:61)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
	at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:285)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:131)
	at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:175)
	at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:157)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	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:151)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	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:619)
Nov 5, 2008 12:52:05 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
Encoding: UTF-8
Headers: {Content-Type=[text/plain;charset=utf-8]}
Messages: 
Payload: <ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring
xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.NullPointerException</ns1:faultstring></ns1:XMLFault>
--------------------------------------

> JAXRSOutInterceptor throws NullPointerException for unknown requests when using exception
mapper
> ------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1858
>                 URL: https://issues.apache.org/jira/browse/CXF-1858
>             Project: CXF
>          Issue Type: Bug
>          Components: REST
>    Affects Versions: 2.1.2
>         Environment: windows XP, jdk1.6.0_07, tomcat 6.0.18
>            Reporter: david
>
> JAX-RS webservice
> When a client requests URL that isnt a valid service endpoint and using an Exeption mapper
to return more detailed error, if you add an entity in the response the JAXRSOutInterceptor
throws a NPE.
> java.lang.NullPointerException
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:150)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:61)
>    .....
> The exception mapper:
> public class MyExceptionMapper implements ExceptionMapper<Exception>
> {
> 	
> 	private static Logger LOG = LogUtils.getL7dLogger(MyExceptionMapper.class);
> 	
> 	@Override
> 	public Response toResponse(Exception ex) 
> 	{
> 		LOG.logp(Level.WARNING, "MyExceptionMapper", "toResponse","Caught Exception:", ex);
> 		return Response.status(503).type("text/html").entity("Myexception error description").build();
> 	}
> }
> If I dont put the entity in the response it works, but with an entity in the response
it causes a NullPointerException.
> currently in SVN and 2.1.2 JAXRSOutInterceptor.java line 150 is :
> writer.writeTo(responseObj, targetType, invoked.getGenericReturnType(), 
>                                invoked != null ? invoked.getAnnotations() : new Annotation[]{},

>                                responseType, 
>                                response.getMetadata(), 
>                                out);
>                 
> perhaps should be  this :
> writer.writeTo(responseObj, targetType, 
>                                invoked != null ? invoked.getGenericReturnType() : null,

>                                invoked != null ? invoked.getAnnotations() : new Annotation[]{},

>                                responseType, 
>                                response.getMetadata(), 
>                                out);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message