Jersey Resource .class loading

2019-08-06 04:21发布

I have the Jersey resource classes bundled within a larger WAR as JAR file which is now residing underneath WEB-INF/lib folder on Websphere Application Server. I have the correct web.xml entry(WEB-INF/web.xml) but still on the server, the scan appears to be not able to lookup the Resource classes which are bundled as a JAR. I was looking at a few threads, and the suggestion was to not bundle Resources as a JAR but instead load the classes seperately underneath /WEB-INF/classes.

<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
 <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>blah.blah.blah</param-value>
 </init-param>
 </servlet>

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes..at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:1064)


2条回答
老娘就宠你
2楼-- · 2019-08-06 04:29

Having the classes in a JAR vs in WEB-INF/classes makes no difference. Either your package name(s) are wrong in the web.xml, something else in your web.xml is configured incorrectly, or your resource classes aren't annotated properly (or, possibly, some WebSphere devilry is at work--I've never used it myself, but I've heard of really strange class path problems with it). If you show a resource class, a full web.xml, and more of the logs around the error, someone might be able to point out what's going wrong.

查看更多
爷、活的狠高调
3楼-- · 2019-08-06 04:36

There are issues outlined in the blog post from Rohit here on various jersey issues with specific versions of WebSphere, can you please see if anything there helps you?

http://wasdynacache.blogspot.com/2011/08/jax-rs-implementations-in-websphere.html

查看更多
登录 后发表回答