Tomcat 7无法加载javax.persistence

时间:2014-07-21 10:22:50

标签: java eclipse tomcat tomcat7 persistence

我正在将eclipse项目导入虚拟机。我更改了库(更改路径并重新导入项目,因为此VM只有C:而不是D :)。 Tomcat无法加载并显示此信息。导入所有库并将persistence.xml文件配置为ok。

[2014-07-21 12:15:43] ERROR (InicializacionListener.java:142) - Excepcion cerrando DAO: java.lang.NullPointerException
java.lang.NullPointerException
    at com.dominion.procop.listeners.InicializacionListener.contextInitialized(InicializacionListener.java:140)
    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(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
jul 21, 2014 12:15:43 PM org.apache.catalina.core.StandardContext listenerStart
Grave: Excepción enviando evento inicializado de contexto a instancia de escuchador de clase com.dominion.procop.listeners.InicializacionListener
java.lang.NoClassDefFoundError: javax/persistence/PersistenceException
    at com.dominion.procop.listeners.InicializacionListener.contextInitialized(InicializacionListener.java:126)
    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(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.persistence.PersistenceException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    ... 10 more

jul 21, 2014 12:15:43 PM org.apache.catalina.core.StandardContext startInternal
Grave: Error listenerStart
jul 21, 2014 12:15:43 PM org.apache.catalina.core.StandardContext startInternal
Grave: Falló en arranque del Contexto [/MyData] debido a errores previos
[2014-07-21 12:15:43]  WARN (InicializacionListener.java:53) - >>>>>>  FINALIZANDO SERVICIO   <<<<<<
[2014-07-21 12:15:43]  INFO (Sincronizador.java:117) - Sincronizador - FINAL
jul 21, 2014 12:15:43 PM org.apache.coyote.AbstractProtocol startjava.lang.Thread.run(Unknown Source)

2 个答案:

答案 0 :(得分:1)

您错过了应用程序类路径中的javax.persistence_1.0.0.jar或tomcat的类路径。

答案 1 :(得分:0)

最后我删除并再次复制.jars(Toplink),现在它完美无缺。 (老实说,我不知道现在它是如何工作的......)