Hi Paul,
thanks a lot for your quick reply! Indeed that was it! THANKS!!!
Hurray!!! You saved my day & made me very very happy
;-)
However, I really wonder why there's
nothing in the log
=-O
First, I used the default GlassFish logging configuration (untouched)
which set the default loglevel to INFO and did not mention Jersey at
all. I'd expect such a problem to be serious enough to come through
this default config.
Then, I tried it with all logging set to FINEST, but there was still
nothing
:-(
Anyway, I'm sorry not to have tried this out myself before, but I
thought, everything concerning class-loading is fine as I was able to
reference the class
XStreamMessageBodyWriter without any
exception in my
TestRestApplication.getClasses() and - as you
saw - the logger is a static field. Strange, strange...
Anyway, now it's running (I removed all logging) and I'll deal with
SLF4J later.
Best regards and THANKS again, Marco
:-)
On 05/04/2010 05:32 PM, Paul Sandoz wrote:
Hi Marco,
Is there any output in the server log?
I think it is a dependency issue and the MBW/R cannot be
instantiated due to a missing slf4j dependency. Depending on the
instantiation exception when constructing Jersey logs such errors at
the level of CONFIG and not SEVERE. It uses the former when there is a
direct missing dependency, that if missing at compile time would result
in a compilation failure.
But for slf4j the same behavior is induced if slf4f cannot bind
to a logging implementation :-(
Currently Jersey does not differentiate between system and
application components when instantiating, and it should such that
deployment will fail in the latter case.
Note that GF does not ship with slf4j.
See attached for a maven project that works with your code.
Paul.
On May 4, 2010, at 4:01 PM, Marco หงุ่ยตระกูล-Schulze wrote:
Hello *,
I'm porting a small evaluation project (which works fine with RESTeasy
on JBoss) to Jersey on GlassFish v3.
I can access the URL
http://localhost:8080/TestRest/resources/room/2
without any problem when tagging the method
org.nightlabs.testrest.RoomService#getRoom(String)
with
@Produces("application/xml").
Even though, I have a custom
MessageBodyWriter declared via a
javax.ws.rs.core.Application
subclass, when tagging my
RoomService method with
@Produces("application/x-nightlabs-jfire-xstream"),
Jersey claims that there is no writer:
SEVERE: A message body writer for Java
type, class org.nightlabs.testrest.Room, and MIME media type,
application/x-nightlabs-jfire-xstream, was not found
SEVERE: Mapped exception to response: 500 (Internal Server Error)
Here's my little project:
http://www.nightlabs.de/~marco/jersey/2010-05-04.00/TestRest.tar.gz
My javax.ws.rs.core.Application subclass is instantiated and the method
getClasses() is called (I debugged through it), but even
though this method returns
XStreamMessageBodyWriter.class
(among others), my custom writer is ignored.
Can anyone give me a hint? What am I doing wrong? Is this a bug in
Jersey? Did I miss any configuration setting in my web.xml? Here's an
excerpt of my web.xml (see the TestRest.tar.gz for all details):
<servlet>
<servlet-name>TestRestJerseyServlet</servlet-name>
<servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.nightlabs.testrest.TestRestApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TestRestJerseyServlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
Best regards, Marco
:-)