users@jersey.java.net

[Jersey] Re: How to get more error/logging/debug info

From: <daniel.cklam_at_gmail.com>
Date: Mon, 4 Jun 2012 10:01:10 +0000 (GMT)

Thank you for prompt reply!

When I searched around before I did come across suggestions of using
"LoggingFilter" from here:
http://stackoverflow.com/questions/2332515/how-to-get-jersey-logs-at-se
rver

What I did was I copied and pasted the following to my web.xml:

<init-param>
 
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param
-name>
 
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-v
alue>
</init-param>
<init-param>
 
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</para
m-name>
 
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-v
alue>
</init-param>

...which gave me errors:

[#|2012-06-04T14:26:48.448+1000|SEVERE|glassfish3.1.2|javax.enterprise.
system.tools.admin.org.glassfish.deployment.admin|_ThreadID=21;_ThreadN
ame=Thread-2;|Exception while deploying the app
[lamophone-resource-1.0] : org.xml.sax.SAXParseException:
cvc-complex-type.2.4.a: Invalid content was found starting with element
'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":description,
"http://java.sun.com/xml/ns/javaee":display-name, "...

I didn't know how to proceed further.

Now that you mentioned the use of LoggingFilter again, I looked at
JavaDoc again
(http://jersey.java.net/nonav/apidocs/1.12/jersey/com/sun/jersey/api/co
ntainer/filter/LoggingFilter.html) and studied some samples you
suggested (this one to be exact:
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22jersey-samples%22).

What I found is that the JavaDoc for LoggingFilter did say "When an
application is deployed as ***a Servlet or Filter*** this Jersey filter
can be registered using the following initialization parameters...". I
also saw samples where the "init-param" is used in web.xml like:

    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
       
<servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdap
tor</servlet-class>

        <init-param>
        ....
        </init-param>
        ....
    </servlet>

So, now I realized that the init-param is supposed to be used within
<servlet> tags or <filter> tags.

However my simple web service provider class is just a simple stateless
EJB. Its pom.xml doesn't have <servlet> or <filter> tags. How's it
supposed to use the LoggingFilter?

Btw, I have already figured out my original error was caused by caller
not "escaping" some return characters in a service parameter.

Thanks appreciate your help.