Jersey Resource .class loading

寵の児 提交于 2019-12-11 08:22:57

问题


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)



回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/10606919/jersey-resource-class-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!