Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7A7801173D for ; Mon, 25 Aug 2014 23:10:58 +0000 (UTC) Received: (qmail 76847 invoked by uid 500); 25 Aug 2014 23:10:58 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 76799 invoked by uid 500); 25 Aug 2014 23:10:58 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 76548 invoked by uid 99); 25 Aug 2014 23:10:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Aug 2014 23:10:58 +0000 Date: Mon, 25 Aug 2014 23:10:58 +0000 (UTC) From: "Matt Parker (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-5966) NPE in MessageContextImpl when setting ResponseBuilder entity in an ExceptionMapper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14109941#comment-14109941 ] Matt Parker commented on CXF-5966: ---------------------------------- I have tried the workaround you suggested--I registered org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor as a provider, and removed org.apache.cxf.validation.BeanValidationInInterceptor as an inInterceptor--but it still fails in the same way. I see that you added a fix in 3.0.x-fixes. Will that fix make its way into 3.0.2-SNAPSHOT, or do I need to do something else to get it for early testing? A side note: to use JAXRSBeanValidationInInterceptor, I needed to add javax.annotation-api-1.2.jar to my project for the @Priority annotation. I didn't see this in the migration guide, it might be worth mentioning (for those of us unfortunate enough to have to chase down dependencies manually). Thanks > NPE in MessageContextImpl when setting ResponseBuilder entity in an ExceptionMapper > ----------------------------------------------------------------------------------- > > Key: CXF-5966 > URL: https://issues.apache.org/jira/browse/CXF-5966 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.0.1 > Environment: CXF 3.0.1 with custom ExceptionMapper, JAXBElementProvider, MessageContextImpl > Reporter: Matt Parker > Assignee: Sergey Beryozkin > Fix For: 3.0.2, 3.1.0 > > > I hope that this description is complete enough. I think creating a test case for this ticket will be more trouble than it's worth, but please let me know if you need me to. > I have added BeanValidationInInterceptor to my JAX-RS service which uses JAXB-annotated entities. > I have created an ExceptionMapper to capture and write out the validation errors into my JAXB-annotated object's 'description' field. > In my exception mapper, I populate MyObject (which is JAXB-annotated), and then set it as the entity: > responseBuilder.entity(myObject); > it results in an NPE as the JAXBElementProvider attempts to get any attachments from the MessageContext, which dereferences a null OutboundMessage from its Exchange. > Line 83 in MessageContextImpl contains: > {code} > return m.getExchange().getOutMessage().get(Message.ATTACHMENTS); > {code} > The javadoc for Exchange.getOutMessage states that "During the inbound message processing, the outbound message is null". > {code} > 2014-08-20 23:50:53,919|ERROR|http-0.0.0.0-8443-2:|STDERR| java.lang.NullPointerException > 2014-08-20 23:50:53,919|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.ext.MessageContextImpl.get(MessageContextImpl.java:83) > 2014-08-20 23:50:53,919|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext.get(ThreadLocalMessageContext.java:38) > 2014-08-20 23:50:53,927|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.provider.JAXBElementProvider.getAttachments(JAXBElementProvider.java:542) > 2014-08-20 23:50:53,927|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.provider.JAXBElementProvider.addAttachmentMarshaller(JAXBElementProvider.java:520) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshal(JAXBElementProvider.java:444) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.provider.JAXBElementProvider.writeTo(JAXBElementProvider.java:318) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1363) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:244) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:117) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:80) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.jaxrs.interceptor.JAXRSDefaultFaultOutInterceptor.handleMessage(JAXRSDefaultFaultOutInterceptor.java:61) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:371) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:243) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:197) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149) > 2014-08-20 23:50:53,928|ERROR|http-0.0.0.0-8443-2:|STDERR| at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171) > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)