Hi Jo,
Jo Størset wrote:
>
> Den 29. feb.. 2008 kl. 11.41 skrev Paul Sandoz:
>
>> How have you implemented the freemarker template processor? can you
>> provide some example code.
>
> My inital cut is the same as your example. The provider is found
>
> INFO: Provider classes found:
> class no.uio.total.frida.FreemarkerTemplateProcessor
>
> But my debug sysout in resolve never shows up:
>
> public String resolve(String path) {
> System.out.println("Hello world: " + path);
> ....
>
> Instead I get this (expected) exception:
>
> 2008-03-03 11:49:21.782::WARN: /test/
> java.lang.IllegalArgumentException: A message body writer for Java type,
> class no.uio.total.frida.resources.Test, and MIME media type,
> application/octet-stream, was not found
> at
> com.sun.ws.rest.impl.application.MessageBodyFactory.getMessageBodyWriter(MessageBodyFactory.java:153)
>
What is the HTTP method of the resource class returning? from the output
above it implies that an HTTP method of a resource class is returning an
instance of Test. It should return an instance of Viewable.
>
> I suspect this might be a problem with my use of the SpringServlet
> (copied from the blog example), and that this overrides some of the
> initialization logic.
I have just tested mixing Spring, JSP templates and my own hacked
template running from the latest source and it all worked OK.
Attached is the NetBeans project that i used (if you use this you will
need to change the jar locations in the project properties configuration).
Notice that to use an explicit template i do the following for an HTTP
method:
@GET public Viewable get() {
return new Viewable("show", "content");
}
or:
@GET
@ProduceMime("text/html")
public Viewable getDescriptionView() {
return new Viewable("show", this);
}
To utilize an implicit templates one needs to set a property in the web.xml:
<init-param>
<param-name>com.sun.ws.rest.config.feature.ImplicitViewables</param-name>
<param-value>true</param-value>
</init-param>
(explicit HTTP methods will always override implicit behaviour).
In the attached code notice that there is a resource class:
a.b.c.MyResource
and notice that there is a resource file:
/a/b/c/MyResource/foo.xxx
When the URI path is:
<context>/abc/foo
my hacked template provider will kick in (because
/a/b/c/MyResource/foo.xxx exists) with the model set to the instance of
MyResource.
If you can send me your Freemarker code i may be able to get something
working for you.
Paul.
> I guess it might be to early to try to use
> different extension mechanisms at the same time, without knowing the
> internals of the initialization.
>
> As an example I see the springservlet overrides
> wa.initiate(rc);
> with
> wa.initiate(rc, new SpringComponentProvider(springContext));
>
> I'll see if I can make some time tonight to take another look at it.
>
> Jo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109