Thank you very much Sergey, it works great with

        <util:map id="outMediaTemplates">
                <entry key="application/rdf+xml" 
value="classpath:/rdf-stylesheet.xsl" />
        </util:map>

and @Produce({...application/rdf+xml})


application/xml+rdf actually wasn't correct, so I didn't have to register
custom media types.

 
XSLTJaxbProvider is definitely very nice :-)




Sergey Beryozkin-2 wrote:
> 
> Hi,
> 
> I was using a forward slash in all my tests, for example : 
> classpath:/rdf-stylesheet.xsl
> 
> but perhaps, given that a classloader is asked to load a resource
> explicitly there is no need for this extra slash - but please use '/'
> for a while.
> 
>> application/xml+rdf
> 
> XSLTJaxbProvider has static Produces/Consumes values, particularly,
> @Produces has no "application/xml+rdf" in the list.
> 
> To make XSLTJaxbProvider recognize it you can customize its Produces
> values, when registering a provider, for :
> 
> <util:list id="mediaTypes">
> <value>application/xml</value>
> <value>application/xml+rdf</value>
> </util:list>
> 
> <bean id="xsltProvider"
> class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider">
> <property name="produceMediaTypes" ref="mediaTypes"/>
> </bean>
> 
> Actually, XSLTJaxbProvider has "application/*+xml" so it has to work...
> I just checked, it should be
> 
> application/rdf+xml rather than
> 
> application/xml+rdf ?
> 
> But if you do need application/xml+rdf
> 
> then please use the explicit customization ...
> 
> In meantime, may be I should also add "application/xml+*" to
> XSLTJaxbProvider
> 
> Hope it helps, Sergey
> 
>  
> 
> -----Original Message-----
> From: XeN0s [mailto:[email protected]] 
> Sent: 30 May 2009 14:11
> To: [email protected]
> Subject: Re: How to use cxf 2.2.2 jaxrs XSLTJaxbProvider feature ?
> 
> 
> I just investigate a little.
> 
> In application log, I found :
> 
> 2009-05-30 14:54:59 [org.apache.cxf.jaxrs.provider.XSLTJaxbProvider]
> WARN  -
> No template is available at : classpath:rdf-stylesheet.xsl
> 
> In XSLTJaxbProvider, there is a bug : 
> 
>  protected Templates createTemplates(String loc) {
>         try {
>             InputStream is = null;
>             if (loc.startsWith("classpath:")) {
>                 String path = loc.substring("classpath:".length() + 1);
>     
>                 // ===> path actually is set with "df-stylesheet.xsl"
> 
>                 is =
> this.getClass().getClassLoader().getResourceAsStream(path);
>             } else {
>                 File f = new File(loc);
>                 if (f.exists()) {
>                     is = new FileInputStream(f);
>                 }
>             }
>             if (is == null) {
>                 LOG.warning("No template is available at : " + loc);
>                 return null;
>             }
>             
>             Reader r = new BufferedReader(
>                            new InputStreamReader(is, "UTF-8"));
>             Source source = new StreamSource(r);
>             if (factory == null) {
>                 factory =
> (SAXTransformerFactory)TransformerFactory.newInstance();
>                 if (uriResolver != null) {
>                     factory.setURIResolver(uriResolver);
>                 }
>             }
>             return factory.newTemplates(source);
>             
>         } catch (Exception ex) {
>             LOG.warning("No template can be created : " +
> ex.getMessage());
>         }
>         return null;
>     }
> 
> 
> To avoid this bug, I modified my endpoint configuration : 
> 
>       <util:map id="outMediaTemplates">
>               <entry key="application/xml+rdf" value="classpath:
> rdf-stylesheet.xsl" />
>       </util:map>
> 
> With this, Templates object is correctly created (maybe a JIRA issue
> will be
> needed ?)
> 
> But it doesn't solve my base problem : when calling the service
> /prodservice, I still get a ".No message body writer found for response
> class : ProductsDTO." html error page. 
> -- 
> View this message in context:
> http://www.nabble.com/How-to-use-cxf-2.2.2-jaxrs-XSLTJaxbProvider-featur
> e---tp23792102p23793284.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-use-cxf-2.2.2-jaxrs-XSLTJaxbProvider-feature---tp23792102p23800447.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to