com.sun.jersey.spi.container.servlet.ServletContainer上的ClassNotFoundException [英] ClassNotFoundException on com.sun.jersey.spi.container.servlet.ServletContainer

查看:126
本文介绍了com.sun.jersey.spi.container.servlet.ServletContainer上的ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将项目从jBoss-eap-5.1迁移到jboss-eap-6.0.我在jboss的modules目录中定义了球衣罐,如下所示:

I am migrating project from jBoss-eap-5.1 to jboss-eap-6.0. I have defined jersey jars in the modules directory of jboss as follows:

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

在我的项目.pom文件中,我对罐子的定义如下:

In my project .pom file i defined the jars as follows:

<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类上收到以下错误:

However, when I try to deploy, I get the following error on ServletContainer class:

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是包含该类的那个.但是,确实可以解决错误.

Initially, I was getting this error when I did not define jersey-servlet, but I did some searching, and presumably, jersey-servlet.jar is the one that contains that class. However, that did solve the error.

推荐答案

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

I have solved the issue by adding this dependencies into my manifest.mf file. In my .pom file I added the build plugin:

<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文件的引用

that added references to the needed .jar files in my manifest file

这篇关于com.sun.jersey.spi.container.servlet.ServletContainer上的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆