com.sun.jersey.spi.container.servlet.ServletContainer上的ClassNotFoundException

时间:2013-02-22 19:21:47

标签: jboss jboss7.x jboss-eap-6

我正在将项目从jBoss-eap-5.1迁移到jboss-eap-6.0。我已经在jboss的modules目录中定义了jersey jars,如下所示:

com
|_jersey
  |_jersey-core
  |_jersey-client
  |_jersey-server
  |_jersey-servlet

在我的项目.pom文件中,我按如下方式定义了jar:

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-servlet</artifactId>
    <version>1.10</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
    <version>${jersey-version}</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-client</artifactId>
    <version>${jersey-version}</version>
    <scope>test</scope>
</dependency>

但是,当我尝试部署时,我在ServletContainer类上收到以下错误:

13:03:29,908 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.subunit."ApiEar-2.0.0-SNAPSHOT.ear"."ApiService-2.
0.0-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ApiEar-2.0.0-SNAPSHOT.ear"."ApiService-2.0.0-SNAPSHOT.war".POST_MODULE
: JBAS018733: Failed to process phase POST_MODULE of subdeployment "ApiService-2.0.0-SNAPSHOT.war" of deployment "ApiEar-2.0.0-SNAPSHOT.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_32-ea]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_32-ea]
        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_32-ea]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer from [Modu
le "deployment.ApiEar-2.0.0-SNAPSHOT.ear.ApiService-2.0.0-SNAPSHOT.war:main" from Service Module Loader]
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:295)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:160)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:109)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

        ... 5 more

最初,当我没有定义jersey-servlet时,我收到了这个错误,但我做了一些搜索,大概是jersey-servlet.jar是包含该类的那个。但是,这确实解决了错误。

2 个答案:

答案 0 :(得分:1)

我通过将此依赖项添加到manifest.mf文件中解决了该问题。在我的.pom文件中,我添加了构建插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
         <archive>
             <manifestEntries>
                  <Dependencies>com.jersey.jersey-server,com.jersey.jersey-client,com.jersey.jersey-json</Dependencies>
             </manifestEntries>
         </archive>
    </configuration>
</plugin>

在我的清单文件中添加了对所需.jar文件的引用

答案 1 :(得分:1)

不是答案,但我相信这是在版本10的球衣中实施的。那是图书馆发生大修的时候