users@jersey.java.net

[Jersey] Issue with jersey-freemarker

From: Rob Shepherd (DataCymru) <"Rob>
Date: Wed, 23 May 2012 18:38:51 +0100

Hi,

I've included the jersey-contribs/jersey-freemarker maven dependency
along with the rest of my working jersey application, then placed a
template in src/main/resources/freemarker/...

then, added the following to web.xml

<init-param>
<param-name>com.sun.jersey.freemarker.templateBasePath</param-name>
<param-value>freemarker</param-value>
</init-param>

However I can't seem to fiddle with it to get the
FreemarkerViewProcessor to kick in and process the template - it seems
to be falling back to the standard method.

java.io.IOException: The template name,
/com/myapp/ViewableRootResource/status.ftl, could not be resolved to a
fully qualified template name
         at
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.writeTo(ViewableMessageBodyWriter.java:79)
         at
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.writeTo(ViewableMessageBodyWriter.java:62)
         at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)

There's no mention in the stacktrace of the FreemarkerViewProcessor.

I've checked that all the files and libs are in the war, but in my
limited knowledge of jersey et al, I can't fathom how it would *ever*
work - there's no @Provider in the source for FreemarkerViewProcessor.java]

Aside the fact that it doesn't work for me - please could somebody
satisfy my curiosity and inform me how it theoretically could work - how
jersey know to utilise FreemarkerViewProcessor and not <jsp-builtin>?

Many thanks

Rob


-- 
Rob Shepherd BEng PhD - Director / Senior Engineer - DataCymru Ltd