1

我正在使用 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?

4

1 回答 1

0

我没有尝试让 Jersey 2.0 在 Glassfish 2.x 上运行,但是将包从 com.sun.jersey -> org.glassfish.jersey 分别从 1.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>

在此处查看最新的泽西岛部署信息以了解其他细节。

于 2013-07-23T18:47:02.943 回答