我使用的是Glassfish v2(我知道它很旧)。现在我已经切换到Jersey 2.0,在启动时它给了我这个异常:
com.sun.jersey.spi.container.servlet.ServletContainer
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1578)
at org.apache.catalina.core.StandardWrapper.loadServletClass(StandardWrapper.java:1273)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1049)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1023)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4969)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5376)
at com.sun.enterprise.web.WebModule.start(WebModule.java:345)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:986)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:970)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:704)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1649)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1254)
at com.sun.enterprise.web.WebContainer.loadJ2EEApplicationWebModules(WebContainer.java:1177)
at com.sun.enterprise.server.TomcatApplicationLoader.doLoad(TomcatApplicationLoader.java:141)
at com.sun.enterprise.server.ExtendedApplicationLoader.doLoad(ExtendedApplicationLoader.java:134)
at com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:240)
at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:336)
at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:210)
at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:645)
at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:959)
at com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:943)
at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:467)
at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:182)
at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:231)
at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298)
at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
有人知道为什么/如何给出这个错误吗?这不是我能找到的任何球衣代码使用的包名。是否可以在Glassfish 2.x上使用Jersey 2.0 ?
我没有尝试在Glassfish 2上运行Jersey 2.0。但是从1开始,从com.sun.jersey -> org.glassfish.jersey的包有明显的重命名。X到2。分别x。
看起来你的(web.xml)配置仍然使用旧的类名。您可能需要这样的内容:
<web-app>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.foo.rest.MyApplication</param-value>
</init-param>
...
</servlet>
...
</web-app>
查看最新的Jersey部署信息在这里了解其他细节。