2014-02-10 54 views
0

我試過在tomee 1.6.0上運行我的應用程序,但是我遇到了JPA和Hibernate的問題。我使用postgresql和驅動程序9.3-1100。我閱讀了更多關於這個主題的教程,但是我的問題仍然存在。我讀過的東西,我的服務器和commpiler使用不同的JVM,但不,我檢查這種可能性。另外,我將jar文件從tutorial複製到tomee/lib目錄,但沒有更改。我嘗試休眠jar文件4.3.0和4.1.4和相同的結果。你能告訴我我做錯了什麼嗎?Tommy上的Hibernate,Postgresql

我嘗試從我TomEE http://tomee.apache.org/tomee-and-hibernate.html

http://tomee.apache.org/examples-trunk/jpa-hibernate/README.html

登錄:

 
Feb 10, 2014 11:05:55 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal 
SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/] 
org.apache.openejb.OpenEJBException: Creating application failed: /home/leaflock/3.Programovanie/Java/Intellij Projects/Avicularia/target/avicularia: org.apache.openejb.OpenEJBRuntimeException: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider 
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:897) 
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:612) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1205) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1051) 
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:127) 
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.deployWar(TomcatWebAppBuilder.java:622) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.deployWebApps(TomcatWebAppBuilder.java:593) 
    at org.apache.tomee.catalina.deployment.TomcatWebappDeployer.deploy(TomcatWebappDeployer.java:44) 
    at org.apache.openejb.assembler.DeployerEjb.deploy(DeployerEjb.java:168) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164) 
    at org.apache.openejb.security.internal.InternalSecurityInterceptor.invoke(InternalSecurityInterceptor.java:34) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164) 
    at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:180) 
    at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:99) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182) 
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164) 
    at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:80) 
    at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:212) 
    at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:181) 
    at org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:370) 
    at org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:181) 
    at org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:344) 
    at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:240) 
    at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:86) 
    at org.apache.openejb.server.httpd.ServerServlet.service(ServerServlet.java:58) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
    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:744) 
Caused by: org.apache.openejb.OpenEJBException: org.apache.openejb.OpenEJBRuntimeException: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider 
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:758) 
    ... 62 more 
Caused by: org.apache.openejb.OpenEJBRuntimeException: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider 
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:117) 
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.(ReloadableEntityManagerFactory.java:101) 
    at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:150) 
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:752) 
    ... 62 more 
Caused by: java.lang.ClassNotFoundException: org.hibernate.jpa.HibernatePersistenceProvider 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
    at org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java:109) 
    at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:47) 
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:115) 
    ... 65 more 
 
[2014-02-10 11:05:55,315] Artifact Avicularia:war: Error during artifact deployment. See server log for details. 
[2014-02-10 11:05:55,317] Artifact Avicularia:war: javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is: 
    org.apache.openejb.OpenEJBRuntimeException: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/]] 

回答

0

假設你的庫都OK,也許是錯誤的東西與你的persistence.xml

它必須看起來如此這樣的方法:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="NewFleetSystem" transaction-type="JTA"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <jta-data-source>java:openejb/Resource/YOUR_RESOURCE_NAME</jta-data-source> 
     <properties> 
      <property name="hibernate.show_sql" value="true"/> 
      <property name="hibernate.format_sql" value="true"/> 
      <property name="hibernate.use_sql_comments" value="true"/> 
      <property name="hibernate.generate_statistics" value="true"/> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

我猜你正面臨的錯誤只是錯誤的配置。

希望這會有所幫助。

0

請仔細檢查您的classpath中是否有hibernate-entitymanager。

您應該將它定義爲您的WebApps的依賴項,因爲您應該嘗試保持它的獨立性。目標是讓它在Tomcat,Jetty,Resin等上運行。

請注意,TomEE附帶安裝了openjpa。這是通過Tomcat使用TomEE的主要原因之一,因爲它提供了一堆已經集成並經過兼容性測試的技術。