在我的Eclipse动态Web项目中,我使用JPA。我已经在TomEE服务器下的tomee.xml中创建了连接,并且工作正常。我创建了一个persistence.xml文件,如下所示;但是,如果尝试在我的BusinessBean中添加@PersistenceContext(unitName =“ myPersistence”)行,则会看到以下错误,并且服务器无法启动。如果尝试在unitName下插入一个随机名称,也会看到相同的错误。很奇怪,我该如何解决问题?谢谢!
我的持久性文件:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="myPersistence">
<jta-data-source>connessioneCorsoWeb</jta-data-source>
<properties>
<property name="openejb.jpa.auto-scan" value="true" />
<!-- <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" /> -->
</properties>
</persistence-unit>
</persistence>
我的错误:
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:corso_web' did not find a matching property.
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Server version: Apache Tomcat (TomEE)/8.5.32 (7.0.5)
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Server built: Jun 20 2018 19:50:35 UTC
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Server number: 8.5.32.0
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: OS Name: Mac OS X
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: OS Version: 10.13.6
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Architecture: x86_64
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: JVM Version: 1.8.0_20-b26
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: JVM Vendor: Oracle Corporation
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: CATALINA_BASE: /Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: CATALINA_HOME: /Applications/apache-tomee-plume-7.0.5
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Command line argument: -Dcatalina.base=/Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Command line argument: -Dcatalina.home=/Applications/apache-tomee-plume-7.0.5
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Command line argument: -Dwtp.deploy=/Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Command line argument: -Djava.endorsed.dirs=/Applications/apache-tomee-plume-7.0.5/endorsed
Sep 06, 2018 10:47:21 AM sun.reflect.NativeMethodAccessorImpl invoke
INFORMAZIONI: Command line argument: -Dfile.encoding=UTF-8
Sep 06, 2018 10:47:21 AM sun.reflect.DelegatingMethodAccessorImpl invoke
INFORMAZIONI: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/test/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
Sep 06, 2018 10:47:22 AM sun.reflect.DelegatingMethodAccessorImpl invoke
INFORMAZIONI: Initializing ProtocolHandler ["http-nio-8080"]
Sep 06, 2018 10:47:22 AM sun.reflect.DelegatingMethodAccessorImpl invoke
INFORMAZIONI: Using a shared selector for servlet write/read
Sep 06, 2018 10:47:22 AM sun.reflect.DelegatingMethodAccessorImpl invoke
INFORMAZIONI: Initializing ProtocolHandler ["ajp-nio-8009"]
Sep 06, 2018 10:47:22 AM sun.reflect.DelegatingMethodAccessorImpl invoke
INFORMAZIONI: Using a shared selector for servlet write/read
Sep 06, 2018 10:47:23 AM org.apache.openejb.util.OptionsLog info
INFORMAZIONI: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: ********************************************************************************
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: OpenEJB http://tomee.apache.org/
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: Startup: Thu Sep 06 10:47:23 CEST 2018
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: Copyright 1999-2018 (C) Apache OpenEJB Project, All Rights Reserved.
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: Version: 7.0.5
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: Build date: 20180710
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: Build time: 12:28
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: ********************************************************************************
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: openejb.home = /Applications/apache-tomee-plume-7.0.5
Sep 06, 2018 10:47:23 AM org.apache.openejb.OpenEJB$Instance <init>
INFORMAZIONI: openejb.base = /Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Sep 06, 2018 10:47:23 AM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFORMAZIONI: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@8909f18
Sep 06, 2018 10:47:23 AM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFORMAZIONI: Succeeded in installing singleton service
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory init
INFORMAZIONI: TomEE configuration file is '/Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/openejb.xml'
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=My Singleton Container, type=Container, provider-id=Default Singleton Container)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.ConfigurationFactory configureService
INFORMAZIONI: Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
Sep 06, 2018 10:47:23 AM org.apache.openejb.config.DeploymentsResolver loadFrom
AVVERTENZA: File error: <Deployments dir="apps/"> - Does not exist: /Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/apps
Sep 06, 2018 10:47:23 AM org.apache.openejb.util.OptionsLog info
INFORMAZIONI: Using 'openejb.deployments.classpath=false'
Sep 06, 2018 10:47:23 AM org.apache.openejb.assembler.classic.Assembler createRecipe
INFORMAZIONI: Creating TransactionManager(id=Default Transaction Manager)
Sep 06, 2018 10:47:24 AM org.apache.openejb.assembler.classic.Assembler createRecipe
INFORMAZIONI: Creating SecurityService(id=Tomcat Security Service)
Sep 06, 2018 10:47:24 AM org.apache.openejb.assembler.classic.Assembler createRecipe
INFORMAZIONI: Creating Resource(id=My DataSource)
Sep 06, 2018 10:47:34 AM org.apache.openejb.config.JndiEncInfoBuilder buildEjbRefs
AVVERTENZA: Unresolved ejb reference "java:comp/env/web.Activator/activeBean" in bean "corso_web.Comp". Will attempt resolution again at runtime.
Sep 06, 2018 10:47:34 AM org.apache.openejb.config.JndiEncInfoBuilder buildEjbRefs
AVVERTENZA: Unresolved ejb reference "java:comp/env/web.Activator/activeBean" in bean "/Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/corso_web". Will attempt resolution again at runtime.
Sep 06, 2018 10:47:34 AM org.apache.openejb.config.ReportValidationResults logResults
GRAVE: FAIL ... corso_web: Use of @PersistenceContext only applies to EntityManager references. Fix ref "java:comp/env/business.PersonaBean/erisci"
Sep 06, 2018 10:47:34 AM org.apache.openejb.config.ReportValidationResults logResults
GRAVE: Invalid EjbModule(name=corso_web, path=/Volumes/Main/Workspace/Learning/JEE2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/corso_web)
Sep 06, 2018 10:47:34 AM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
GRAVE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso_web]
org.apache.openejb.config.ValidationFailedException: Module failed validation. AppModule(name=corso_web)
at org.apache.openejb.config.ReportValidationResults.deploy(ReportValidationResults.java:88)
at org.apache.openejb.config.AppInfoBuilder.build(AppInfoBuilder.java:327)
at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1040)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1281)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Sep 06, 2018 10:47:34 AM sun.reflect.NativeMethodAccessorImpl invoke
GRAVE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso_web]] in state [STARTING_PREP]
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:856)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1651)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1631)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1312)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Sep 06, 2018 10:47:34 AM sun.reflect.NativeMethodAccessorImpl invoke
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso_web]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso_web]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
... 6 more
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.config.ValidationFailedException: Module failed validation. AppModule(name=corso_web)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1315)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: org.apache.openejb.config.ValidationFailedException: Module failed validation. AppModule(name=corso_web)
at org.apache.openejb.config.ReportValidationResults.deploy(ReportValidationResults.java:88)
at org.apache.openejb.config.AppInfoBuilder.build(AppInfoBuilder.java:327)
at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1040)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1281)
... 11 more
Sep 06, 2018 10:47:34 AM sun.reflect.NativeMethodAccessorImpl invoke
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Sep 06, 2018 10:47:34 AM sun.reflect.NativeMethodAccessorImpl invoke
GRAVE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
答案 0 :(得分:0)
注入的上下文(business.PersonaBean/erisci
)是什么类型?必须为EntityManager
。如果需要EntityManagerFactory
,请使用@PersistenceUnit
。如果是EntityManager,则可能意味着您的应用打包了一个与提供的jpa api冲突的jpa api。