链接两个java项目时找不到类的类

时间:2015-07-06 07:40:12

标签: java spring jsf tomcat

可能这是一个重复的问题。已发布的问题的解决方案并没有帮助我解决问题。这就是为什么我重新发布它

我有2个Java项目。说1.ibz和2.Mailer ibz是一个Web应用程序,Mailer包含一些java类。我需要邮件中的一些类来从ibz访问。尝试了以下步骤

右键点击ibz项目>属性> Java构建路径>项目>添加>选择的梅勒项目>好的>确定

但是当我试图启动服务器时,它会显示以下异常


    SEVERE: Critical error during deployment: 
    java.lang.NoClassDefFoundError: Lcom/ibz/mailer/MailClass;
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:2499)
        at java.lang.Class.getDeclaredFields(Class.java:1811)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.collectAnnotatedFields(ManagedBeanConfigHandler.java:242)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.getBeanInfo(ManagedBeanConfigHandler.java:151)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.process(ManagedBeanConfigHandler.java:137)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.push(ManagedBeanConfigHandler.java:123)
        at com.sun.faces.application.annotation.AnnotationManager.applyConfigAnnotations(AnnotationManager.java:234)
        at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:402)
        at com.sun.faces.config.processor.ManagedBeanConfigProcessor.process(ManagedBeanConfigProcessor.java:244)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ValidatorConfigProcessor.process(ValidatorConfigProcessor.java:120)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ConverterConfigProcessor.process(ConverterConfigProcessor.java:126)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ComponentConfigProcessor.process(ComponentConfigProcessor.java:117)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:344)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:239)
        at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:221)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
        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: com.ibz.mailer.MailClass
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1295)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
        ... 33 more

    Jul 06, 2015 12:35:38 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
    java.lang.RuntimeException: java.lang.NoClassDefFoundError: Lcom/ibz/mailer/MailClass;
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:280)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
        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.NoClassDefFoundError: Lcom/ibz/mailer/MailClass;
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:2499)
        at java.lang.Class.getDeclaredFields(Class.java:1811)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.collectAnnotatedFields(ManagedBeanConfigHandler.java:242)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.getBeanInfo(ManagedBeanConfigHandler.java:151)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.process(ManagedBeanConfigHandler.java:137)
        at com.sun.faces.application.annotation.ManagedBeanConfigHandler.push(ManagedBeanConfigHandler.java:123)
        at com.sun.faces.application.annotation.AnnotationManager.applyConfigAnnotations(AnnotationManager.java:234)
        at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:402)
        at com.sun.faces.config.processor.ManagedBeanConfigProcessor.process(ManagedBeanConfigProcessor.java:244)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ValidatorConfigProcessor.process(ValidatorConfigProcessor.java:120)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ConverterConfigProcessor.process(ConverterConfigProcessor.java:126)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ComponentConfigProcessor.process(ComponentConfigProcessor.java:117)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:344)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
        at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
        at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:239)
        at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:221)
        ... 9 more
    Caused by: java.lang.ClassNotFoundException: com.ibz.mailer.MailClass
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1295)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
        ... 33 more

    Jul 06, 2015 12:35:38 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Jul 06, 2015 12:35:38 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/ibzerp] startup failed due to previous errors
    Jul 06, 2015 12:35:38 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Jul 06, 2015 12:35:38 PM org.springframework.web.context.support.XmlWebApplicationContext doClose
    INFO: Closing Root WebApplicationContext: startup date [Mon Jul 06 12:35:32 IST 2015]; root of context hierarchy
    Jul 06, 2015 12:35:38 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
    WARNING: The web application [ibzerp] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
    Jul 06, 2015 12:35:38 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
    WARNING: The web application [ibzerp] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
     java.lang.Object.wait(Native Method)
     java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
     com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)
    Jul 06, 2015 12:35:39 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-nio-8080"]
    Jul 06, 2015 12:35:39 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["ajp-nio-8009"]
    Jul 06, 2015 12:35:39 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 10391 ms

其他信息

  • Eclipse LSR 1(4.4.1)
  • Tomcat 8.0

有人知道我做错了什么/错过了吗?

1 个答案:

答案 0 :(得分:0)

我假设你在谈论Eclipse,对吧?您应该提到这一点,因为还有很多其他Java IDE。

右键单击ibz project / Properties / Deployment Assembly并单击“添加”。选择“项目”,然后单击“下一步”。然后选择项目邮件程序并单击“完成”。 Web部署程序集列表中应该有一个新条目,其中包含源:邮件程序和部署路径:WEB-INF/lib/Mailer.jar。然后单击“确定”关闭属性窗口并重新启动servlet容器。