Monday, June 9, 2008

Deploying Jersey REST services to Weblogic

I recently had some trouble deploying a REST service using Jersey to Weblogic, specifically Weblogic 9.2. This had me stumped for quite a while as I could deploy my war to JBoss and Tomcat and it worked fine. Finally with an assist from the mailing list I was able to get past the problem and get the war to deploy. As Paul noted, the problem was that the default class scanning technique is not portable across servlet implmentations, so I needed to add the following to my web.xml (after the <servlet-class> element):


<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>*';' separated package names*</param-value>
</init-param>


This tells Jersey to use the package scanning instead of the class path scanning. Now all you have to do is insert your package names in the last param value (replace the *';' with your package name(s) seperated by ';').

For more detail on this issue see the issue that was filed with Jersey here.

3 comments:

Anonymous said...

Hello Chad, I try to use Jersey on JBoss
and I see that you did that before...
Can you help me please. What must I do?

Reiner reinerra@gmail.com

Anonymous said...

Hello Chad, I try to use Jersey on JBoss
and I see that you did that before...
Can you help me please. What must I do?

Reiner reinerra@gmail.com

Chad Gallemore said...

I would suggest reading the Jersey wiki, they have some good documentation complete with some examples. You can find the documentation at the following:

http://wikis.sun.com/display/Jersey/Main