cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Strange NPE with XSLTJaxbProvider
Date Fri, 07 Sep 2012 15:36:54 GMT
Hi
On 07/09/12 15:59, bligny wrote:
> I am facing a strange behaviour with the XSLTJaxbProvider (cxf version
> 2.4.6).
>
> 1) My JAXRS web service is returning a collection of beans that is correctly
> marshalled to XML by CXF using JAXB:
>
> <jaxrs:server address="/">
> 	<jaxrs:serviceBeans>
> 		<ref bean="myWS"/>
> 	</jaxrs:serviceBeans>
> 	<jaxrs:providers>
> 		<ref bean="jaxbProvider"/>
> 	</jaxrs:providers>
> </jaxrs:server>
>
> <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>
> The obtained XML is very fine :-)
>
> 2) Now, I want that XML to be transformed using an XSL-T :
>
> <jaxrs:server address="/">
> 	<jaxrs:serviceBeans>
> 		<ref bean="myWS"/>
> 	</jaxrs:serviceBeans>
> 	<jaxrs:providers>
> 		<ref bean="xsltProvider"/>
> 	</jaxrs:providers>
> </jaxrs:server>
>
> <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>
> <bean id="xsltProvider"
> class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider"
> parent="jaxbProvider">
> 	<property name="outTemplate" value="classpath:mytemplate.xsl" />
> </bean>
>
> When calling my Web Service, i got an error (a NPE):
>
> java.lang.NullPointerException
> 	at
> com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.startElement(TransformerHandlerImpl.java:263)
> 	at
> com.sun.xml.bind.v2.runtime.output.SAXOutput.endStartTag(SAXOutput.java:124)
> 	at
> com.sun.xml.bind.v2.runtime.XMLSerializer.endAttributes(XMLSerializer.java:306)
> 	at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:592)
> 	at
> com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:324)
> 	at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
> 	at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
> 	at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:103)
> 	at
> org.apache.cxf.jaxrs.provider.XSLTJaxbProvider.marshalToOutputStream(XSLTJaxbProvider.java:221)
> 	at
> org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshal(JAXBElementProvider.java:503)
> 	at
> org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshalCollectionMember(JAXBElementProvider.java:361)
> 	at
> org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshalCollection(JAXBElementProvider.java:320)
> 	at
> org.apache.cxf.jaxrs.provider.JAXBElementProvider.writeTo(JAXBElementProvider.java:251)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:257)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:144)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:83)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
> 	at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
>
>
>
> I have tested the "mytemplate.xsl" with the xml obtained in step 1: it is
> working fine.
>
> So my original xml is ok, my xsl is ok, but the application (by cxf) of that
> xsl on that xml does not work.
> Any idea ?
>
It may be the bug in Xalan itself, in the way TransformHandlers are 
managed. CXF creates Templates and wraps them in TransformerHandler:

http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java

Note there were quite a few changes in the code, perhaps you can try the 
latest released CXF 2.4.x ?

We have a couple of tests involving this provider so I think the 
provider code is OK, there might be a bug there but it is difficult to 
comment without seeing a test case

Thanks
Sergey

> Thx in advance,
>
> Bernard.
>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Strange-NPE-with-XSLTJaxbProvider-tp5713703.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message