Java 获取“ClassNotFoundException:ResteasyBootstrap”和“ClassNotFoundException:SpringContextLoaderListenerexception”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18494722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting "ClassNotFoundException: ResteasyBootstrap" and "ClassNotFoundException:SpringContextLoaderListenerexception"
提问by Beginer
I am getting the following exception:
我收到以下异常:
java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:124)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
I have the following dependencies in my pom file:
我的 pom 文件中有以下依赖项:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
<version>${resteasy.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.0.GA</version>
</dependency>
I also see the resteasy-jaxrs-2.3.0.GA.jar in the WEB/INF/lib folder. Please let me know which dependency is missing. I also checked Getting "java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet" in Eclipse + jboss 5.1.0and have all in place.
我还看到了 WEB/INF/lib 文件夹中的 resteasy-jaxrs-2.3.0.GA.jar。请让我知道缺少哪个依赖项。我还检查了 Eclipse + jboss 5.1.0 中的“java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet”并已全部就绪。
I also get the following error:
我也收到以下错误:
SEVERE: Error configuring application listener of class org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
Despite having the following dependency:
尽管有以下依赖:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
<version>${resteasy.version}</version>
</dependency>
采纳答案by Beginer
I finally solved it. The solution was simple. Right Click on the project and select 'Properties'. Under project properties, select 'Deployment Assembly'. Add Maven Dependency here. You need to tell Eclipse that you want all your Maven dependencies to be published too.
我终于解决了。解决办法很简单。右键单击项目并选择“属性”。在项目属性下,选择“部署程序集”。在此处添加 Maven 依赖项。您需要告诉 Eclipse 您也希望发布所有 Maven 依赖项。
回答by Pushkar
If your project is maven base project then run
如果您的项目是 maven 基础项目,则运行
mvn eclipse:clean
mvn eclipse:clean
mvn eclipse:eclipse
mvn 日食:日食
it will add jar from m2 repo to lib folder then redeploy webapp and restart tomcat/server
它会将 jar 从 m2 repo 添加到 lib 文件夹,然后重新部署 webapp 并重新启动 tomcat/server
回答by Bevor
I had the same problem in Wildfly. It turned out that the deployed WAR needs at least one endpoint to do the bootstrap, see below. Otherwise I got java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
:
我在 Wildfly 中遇到了同样的问题。事实证明,部署的 WAR 至少需要一个端点来进行引导,见下文。否则我得到java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
:
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
public class ConfigurationEndpoint {
@Path("/info")
@GET
public Response getInfo() {
return Response.ok().build();
}
}
回答by Neil Yue
I resolved it by right clicking on the project -> Maven -> Update Project. And it may need a redeploy or do a 'clean' on the deployment under the Tomcat server that is plugged into the Eclipse.
我通过右键单击项目 -> Maven -> 更新项目来解决它。它可能需要重新部署或对插入 Eclipse 的 Tomcat 服务器下的部署进行“清理”。