You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jason Coon <ja...@hotmail.com> on 2010/07/13 16:43:17 UTC
XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
I'm trying to configure XSLTJaxbProvider programmatically. When I attempt to
access my REST service, I get the following exception:
exception: javax.xml.transform.TransformerConfigurationException: Templates
object was not created by Saxon
javax.ws.rs.WebApplicationException:
javax.xml.transform.TransformerConfigurationException: Templates object was
not created by Saxon
at
org.apache.cxf.jaxrs.provider.JAXBElementProvider.writeTo(JAXBElementProvider.java:246)
at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:248)
at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:139)
at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:78)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:78)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:312)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:276)
at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at
org.mortbay.jetty.security.SslSocketConnector$SslConnection.run(SslSocketConnector.java:680)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.xml.transform.TransformerConfigurationException: Templates
object was not created by Saxon
at
com.icl.saxon.TransformerFactoryImpl.newTransformerHandler(TransformerFactoryImpl.java:637)
at
org.apache.cxf.jaxrs.provider.XSLTJaxbProvider.marshalToOutputStream(XSLTJaxbProvider.java:145)
at
org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshal(JAXBElementProvider.java:382)
at
org.apache.cxf.jaxrs.provider.JAXBElementProvider.marshal(JAXBElementProvider.java:318)
at
org.apache.cxf.jaxrs.provider.JAXBElementProvider.writeTo(JAXBElementProvider.java:239)
... 22 more
Here's the code I'm using to configure the XSLTJaxbProvider:
...
List providers = new ArrayList();
XSLTJaxbProvider xsltJaxbProvider = new XSLTJaxbProvider();
Map<String, String> outMediaTemplates = new HashMap<String, String>();
outMediaTemplates.put("application/xhtml+xml",
"classpath:/results-xhtml.xsl");
xsltJaxbProvider.setOutMediaTemplates(outMediaTemplates);
providers.add(xsltJaxbProvider);
jaxRSServerFactoryBean.setProviders(providers);
...
I've verified my xsl file is in the classpath, I've tried changing it to an
invalid file name and instead get a different exception, so I think I have
the path correct. I've tried stripping my xsl file down, and checked it
manually to ensure it's valid xsl.
Any help would be greatly appreciated. Thanks!
Jason Coon
--
View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1046769.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Sergey Beryozkin <sb...@gmail.com>.
Thanks for getting to the bottom of it. To me it's an obvious Saxon bug.
I'm wondering, is there any other option to inject parameters into (Saxon)
Templates ?
cheers, Sergey
On Wed, Jul 14, 2010 at 10:45 PM, Jason Coon <ja...@hotmail.com> wrote:
>
> Sergey, I stepped through the XSLTJaxbProvider code, and I think I found
> the
> problem. The following line in marshalToOutputStream:
>
> TransformerHandler th =
> factory.newTransformerHandler(createTemplates(getOutTemplates(mt),
> outParamsMap, outProperties));
>
> I found that the createTemplates method is creating a new TemplatesImpl,
> which implements Templates, but is not an instance of PreparedStylesheet.
> Apparently the saxon transformer factory checks to make sure the Templates
> are an instance of PreparedStylesheet, and throws an exception if not:
>
> if (!(templates instanceof PreparedStylesheet)) {
> throw new TransformerConfigurationException("Templates object
> was not created by Saxon");
> }
>
> For now, I've made my own copy of XSLTJaxbProvider, and replaced the above
> code with:
>
> TransformerHandler th = factory.newTransformerHandler(getOutTemplates(mt));
>
> This works, and my xslt template is being applied. It looks like this will
> not pass parameters and out properties to the transformer, which doesn't
> currently affect me.
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1111305.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Jason Coon <ja...@hotmail.com>.
Sergey, I stepped through the XSLTJaxbProvider code, and I think I found the
problem. The following line in marshalToOutputStream:
TransformerHandler th =
factory.newTransformerHandler(createTemplates(getOutTemplates(mt),
outParamsMap, outProperties));
I found that the createTemplates method is creating a new TemplatesImpl,
which implements Templates, but is not an instance of PreparedStylesheet.
Apparently the saxon transformer factory checks to make sure the Templates
are an instance of PreparedStylesheet, and throws an exception if not:
if (!(templates instanceof PreparedStylesheet)) {
throw new TransformerConfigurationException("Templates object
was not created by Saxon");
}
For now, I've made my own copy of XSLTJaxbProvider, and replaced the above
code with:
TransformerHandler th = factory.newTransformerHandler(getOutTemplates(mt));
This works, and my xslt template is being applied. It looks like this will
not pass parameters and out properties to the transformer, which doesn't
currently affect me.
--
View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1111305.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
you might want to confirm that the media type is indeed
application/xhtml+xml (if not then we'll get the failure), and if it is then
may be try to put a breakpoint in XSLTJaxbProvider and see what happens -
may be Saxon does not like some of the parameters/properties ?
cheers, Sergey
On Wed, Jul 14, 2010 at 2:49 AM, Jason Coon <ja...@hotmail.com> wrote:
>
> Thanks for your response, Sergey.
>
> I did try using an empty XSLT template, just to make sure it's not a
> problem
> with the file. I got the same error.
>
> I haven't tried configuring it from Spring, as we're not currently using
> it.
> I'll see if it's possible in our project.
>
> If there's any more information that would be useful, just let me know.
> I'll see if I can create a simple example to reproduce the issue.
>
> Thanks again,
>
> Jason
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1066200.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Jason Coon <ja...@hotmail.com>.
Thanks for your response, Sergey.
I did try using an empty XSLT template, just to make sure it's not a problem
with the file. I got the same error.
I haven't tried configuring it from Spring, as we're not currently using it.
I'll see if it's possible in our project.
If there's any more information that would be useful, just let me know.
I'll see if I can create a simple example to reproduce the issue.
Thanks again,
Jason
--
View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1066200.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
It's difficult to help without having some more info.
Does it work when the provider is configured from Spring ?
Can it be something specific to a particular XSLT template ? Does it work if
you just have an empty <xslt:template/>, may be with an identity transform
only ?
cheers, Sergey
On Tue, Jul 13, 2010 at 6:54 PM, Jason Coon <ja...@hotmail.com> wrote:
>
> Yeah, I've spent the last day searching and haven't found anything of use.
> I
> understand you get a lot of posts from people who haven't searched on their
> own, but I really did try. Any assistance anyone could provide would be
> greatly appreciated. Thanks!
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1046900.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Jason Coon <ja...@hotmail.com>.
Yeah, I've spent the last day searching and haven't found anything of use. I
understand you get a lot of posts from people who haven't searched on their
own, but I really did try. Any assistance anyone could provide would be
greatly appreciated. Thanks!
--
View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1046900.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: XSLTJaxbProvider: getting TransformerConfigurationException:
Templates object was not created by Saxon
Posted by Glen Mazza <gl...@gmail.com>.
I don't know about this issue, but I'd check some of the 500+ Google
responses to a search on "Templates object was not created by Saxon" to see
if the answer is there.
Glen
Jason Coon wrote:
>
> I'm trying to configure XSLTJaxbProvider programmatically. When I attempt
> to access my REST service, I get the following exception:
>
> exception: javax.xml.transform.TransformerConfigurationException:
> Templates object was not created by Saxon
> javax.ws.rs.WebApplicationException:
> javax.xml.transform.TransformerConfigurationException: Templates object
> was not created by Saxon
>
--
View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-getting-TransformerConfigurationException-Templates-object-was-not-created-by-Saxon-tp1046769p1046876.html
Sent from the cxf-user mailing list archive at Nabble.com.