ClassNotFoundException,即使包含该类的jar正确存在于类路径中

时间:2023-01-22 15:11:13

I'm configuring a new project in eclipse. my project has many modules including one of them named eas.core. to the buildPath of my eas.core module, i have added a jar file common.jcr.jar containing a class named ContentRepositorySettings, that I'm using into my codes. but on runtime, I'm still getting a ClassNotFoundException as shown below

我在eclipse中配置一个新项目。我的项目有很多模块,其中一个名为eas.core。在我的eas.core模块的buildPath中,我添加了一个jar文件common.jcr.jar,其中包含一个名为ContentRepositorySettings的类,我将其用于我的代码中。但是在运行时,我仍然得到一个ClassNotFoundException,如下所示

java.lang.NoClassDefFoundError: cm/bao/common/jcr/ContentRepositorySettings
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2944)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at cm.bao.eas.core.ElectronicArchivingApplicationImpl.setupGlobalSettings(ElectronicArchivingApplicationImpl.java:33)
at cm.bao.eas.core.ElectronicArchivingApplicationImpl.start(ElectronicArchivingApplicationImpl.java:49)
at cm.bao.eas.ui.gwt.server.listner.ElectronicArchivingContextListner.contextInitialized(ElectronicArchivingContextListner.java:18)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: cm.bao.common.jcr.ContentRepositorySettings
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)

1 个解决方案

#1


9  

If your project is Faceted, right click on the project and go to Properties, and choose Deployment Assembly on the left pane. Check if the dependencies exists there as Build Path entries or Archives (jars). Once this is done you may do Project>Clean and restart the server.

如果您的项目是Faceted,请右键单击该项目并转到Properties,然后在左窗格中选择Deployment Assembly。检查依赖关系是否存在于Build Path条目或Archives(jar)中。完成后,您可以执行Project> Clean并重新启动服务器。

#1


9  

If your project is Faceted, right click on the project and go to Properties, and choose Deployment Assembly on the left pane. Check if the dependencies exists there as Build Path entries or Archives (jars). Once this is done you may do Project>Clean and restart the server.

如果您的项目是Faceted,请右键单击该项目并转到Properties,然后在左窗格中选择Deployment Assembly。检查依赖关系是否存在于Build Path条目或Archives(jar)中。完成后,您可以执行Project> Clean并重新启动服务器。