TomEE JPA MySql 配置 "An invalid Lifecycle transition was attempted"
TomEE JPA MySql Configuration "An invalid Lifecycle transition was attempted"
我是 Java EE 的新手,花了一些时间学习它。
在这个错误上花了几个小时,找不到完全相似的问题,在同一门课程中排除了一名学生的 udemy 问答,但老师无法帮助学生。
教程是在 MySQL 上使用 TomEE 和 JPA 教授持久性。
我正在使用 Eclipse:
面向 Web 开发人员的 Eclipse Java EE IDE。
版本:2018-09 (4.9.0)
TomEE 版本:
Tomcat v9.0 服务器
使用 JRE 的 TomEE:
jdk-12.0.1
项目Java构建路径-->模块路径-->执行环境:
JavaSE-10 (jdk-12.0.1)
Java 编译器:
使用来自执行环境 JavaSE-10
的合规性
lib TomEE 文件夹中的实际 MySql 连接器(尝试了几个):
mysql-连接器-java-8.0.17.jar
这是我的tomee.xml
<tomee>
<Resource id="connessioneCorsoWeb" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:Mysql://127.0.0.1:3306/corso_java_web?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
UserName root
Password admin
</Resource>
</tomee>
这是persistence.xml
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
<persistence-unit name="corsoWebPersistence">
<jta-data-source>connessioneCorsoWeb</jta-data-source>
<properties>
<property name="openejb.jpa.auto-scan" value="true"/>
</properties>
</persistence-unit>
</persistence>
启动应用程序时的控制台消息对我没有帮助
INFO: Undeploying app: D:\Shared\Studio\Java EE Developer - La guida
completa\apache-tomee-8.0.0-M3-plume\apache-tomee-plume-8.0.0-M3\webapps\corso-web
Aug 16, 2019 12:11:31 PM jdk.internal.reflect.NativeMethodAccessorImpl
invoke SEVERE: Error destroying child
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:430)
at
org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:316)
at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:814)
...
我可以看什么更深入?
编辑:
删除 persistence.xml 服务器启动。
添加 persistence.xml 只有几行:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
</persistence>
服务器启动。
把persistence.xml改成这样就好了:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
<persistence-unit>
</persistence-unit>
</persistence>
服务器出现故障。
这是对当前控制台的更详尽的摘录:
... Aug 18, 2019 3:21:18 PM
org.apache.tomee.catalina.TomcatWebAppBuilder startInternal SEVERE:
Unable to deploy collapsed ear in war
StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]
java.lang.NullPointerException at
org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at
org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl
invoke SEVERE: Error destroying child
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:430)
at
org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:316)
at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:814)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1656)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1636)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1317)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl
invoke SEVERE: 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.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused
by: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]]
at
org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 21 more Caused by:
org.apache.tomee.catalina.TomEERuntimeException:
java.lang.NullPointerException at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more Caused by: java.lang.NullPointerException at
org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at
org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286)
... 32 more
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl
invoke SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: A child container failed
during start at
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused
by: org.apache.catalina.LifecycleException: A child container failed
during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 13 more Caused by: java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]]
at
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 21 more Caused by: org.apache.catalina.LifecycleException: Failed
to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]]
at
org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 21 more Caused by:
org.apache.tomee.catalina.TomEERuntimeException:
java.lang.NullPointerException at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more Caused by: java.lang.NullPointerException at
org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at
org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286)
... 32 more
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl
invoke SEVERE: The required Server component failed to start so Tomcat
is unable to start. org.apache.catalina.LifecycleException: A child
container failed during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused
by: java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: A child container failed
during start at
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 13 more Caused by: org.apache.catalina.LifecycleException: A child
container failed during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 13 more Caused by: java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]]
at
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 21 more Caused by: org.apache.catalina.LifecycleException: Failed
to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]]
at
org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 21 more Caused by:
org.apache.tomee.catalina.TomEERuntimeException:
java.lang.NullPointerException at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more Caused by: java.lang.NullPointerException at
org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at
org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at
org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286)
... 32 more
Aug 18, 2019 3:21:18 PM
jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Pausing
ProtocolHandler ["http-nio-8080"] Aug 18, 2019 3:21:18 PM
jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Pausing
ProtocolHandler ["ajp-nio-8009"] Aug 18, 2019 3:21:18 PM
jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO:
Stopping service [Catalina] Aug 18, 2019 3:21:18 PM
org.apache.openejb.server.SimpleServiceManager stop INFO: Stopping
server services Aug 18, 2019 3:21:18 PM
org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeploying app: D:\Shared\Studio\Java EE Developer - La guida
completa\apache-tomee-8.0.0-M3-plume\apache-tomee-plume-8.0.0-M3\webapps\ROOT
Aug 18, 2019 3:21:18 PM org.apache.openejb.assembler.classic.Assembler
doResourceDestruction INFO: Closing DataSource: connessioneCorsoWeb
Aug 18, 2019 3:21:18 PM
jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO:
Destroying ProtocolHandler ["http-nio-8080"] Aug 18, 2019 3:21:18 PM
jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO:
Destroying ProtocolHandler ["ajp-nio-8009"]
如有任何想法,我们将不胜感激。
试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="corsoWebPersistence">
<jta-data-source>connessioneCorsoWeb</jta-data-source>
<properties>
<property
name="openejb.jpa.auto-scan"
value="true" />
</properties>
</persistence-unit>
</persistence>
最后我解决了,说的很清楚:
在 Udemy 课程中被使用
Tomcat v8.0 服务器 (apache-tomee-7.0.4)
相反,我正在使用
Tomcat v9.0 服务器 (apache-tomee-8.0.0-M3-plume)
现在使用旧版本不需要,但是使用 tomee-8.0.0 有必要在 Project Facets 中设置 JPA(当检查 JPA 屏幕警报以配置它时),或在 JPA 项目属性中设置。
我已经测试了两个 tomee 版本,现在都可以使用了。
这是我的 Tomcat v9.0 服务器 (apache-tomee-8.0.0-M3-plume)
中的 JPA 配置屏幕
我是 Java EE 的新手,花了一些时间学习它。 在这个错误上花了几个小时,找不到完全相似的问题,在同一门课程中排除了一名学生的 udemy 问答,但老师无法帮助学生。
教程是在 MySQL 上使用 TomEE 和 JPA 教授持久性。
我正在使用 Eclipse: 面向 Web 开发人员的 Eclipse Java EE IDE。 版本:2018-09 (4.9.0)
TomEE 版本: Tomcat v9.0 服务器
使用 JRE 的 TomEE: jdk-12.0.1
项目Java构建路径-->模块路径-->执行环境: JavaSE-10 (jdk-12.0.1)
Java 编译器: 使用来自执行环境 JavaSE-10
的合规性lib TomEE 文件夹中的实际 MySql 连接器(尝试了几个): mysql-连接器-java-8.0.17.jar
这是我的tomee.xml
<tomee>
<Resource id="connessioneCorsoWeb" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:Mysql://127.0.0.1:3306/corso_java_web?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
UserName root
Password admin
</Resource>
</tomee>
这是persistence.xml
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
<persistence-unit name="corsoWebPersistence">
<jta-data-source>connessioneCorsoWeb</jta-data-source>
<properties>
<property name="openejb.jpa.auto-scan" value="true"/>
</properties>
</persistence-unit>
</persistence>
启动应用程序时的控制台消息对我没有帮助
INFO: Undeploying app: D:\Shared\Studio\Java EE Developer - La guida completa\apache-tomee-8.0.0-M3-plume\apache-tomee-plume-8.0.0-M3\webapps\corso-web Aug 16, 2019 12:11:31 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke SEVERE: Error destroying child 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:430) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:316) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:814) ...
我可以看什么更深入?
编辑:
删除 persistence.xml 服务器启动。
添加 persistence.xml 只有几行:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
</persistence>
服务器启动。
把persistence.xml改成这样就好了:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="1.0">
<persistence-unit>
</persistence-unit>
</persistence>
服务器出现故障。
这是对当前控制台的更详尽的摘录:
... Aug 18, 2019 3:21:18 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web] java.lang.NullPointerException at org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke SEVERE: Error destroying child 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:430) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:316) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:814) at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1656) at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1636) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1317) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke SEVERE: 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.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ... 21 more Caused by: org.apache.tomee.catalina.TomEERuntimeException: java.lang.NullPointerException at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 27 more Caused by: java.lang.NullPointerException at org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286) ... 32 more
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ... 13 more Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ... 21 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ... 21 more Caused by: org.apache.tomee.catalina.TomEERuntimeException: java.lang.NullPointerException at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 27 more Caused by: java.lang.NullPointerException at org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286) ... 32 more
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke SEVERE: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ... 13 more Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ... 13 more Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ... 21 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/corso-web]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ... 21 more Caused by: org.apache.tomee.catalina.TomEERuntimeException: java.lang.NullPointerException at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1320) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 27 more Caused by: java.lang.NullPointerException at org.apache.openejb.util.LinkResolver.resolve(LinkResolver.java:55) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:37) at org.apache.openejb.util.LinkResolver.add(LinkResolver.java:33) at org.apache.openejb.config.AutoConfig.resolvePersistenceRefs(AutoConfig.java:223) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:197) at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1033) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286) ... 32 more
Aug 18, 2019 3:21:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Pausing ProtocolHandler ["http-nio-8080"] Aug 18, 2019 3:21:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Pausing ProtocolHandler ["ajp-nio-8009"] Aug 18, 2019 3:21:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Stopping service [Catalina] Aug 18, 2019 3:21:18 PM org.apache.openejb.server.SimpleServiceManager stop INFO: Stopping server services Aug 18, 2019 3:21:18 PM org.apache.openejb.assembler.classic.Assembler destroyApplication INFO: Undeploying app: D:\Shared\Studio\Java EE Developer - La guida completa\apache-tomee-8.0.0-M3-plume\apache-tomee-plume-8.0.0-M3\webapps\ROOT Aug 18, 2019 3:21:18 PM org.apache.openejb.assembler.classic.Assembler doResourceDestruction INFO: Closing DataSource: connessioneCorsoWeb Aug 18, 2019 3:21:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Destroying ProtocolHandler ["http-nio-8080"] Aug 18, 2019 3:21:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
如有任何想法,我们将不胜感激。
试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="corsoWebPersistence">
<jta-data-source>connessioneCorsoWeb</jta-data-source>
<properties>
<property
name="openejb.jpa.auto-scan"
value="true" />
</properties>
</persistence-unit>
</persistence>
最后我解决了,说的很清楚: 在 Udemy 课程中被使用 Tomcat v8.0 服务器 (apache-tomee-7.0.4) 相反,我正在使用 Tomcat v9.0 服务器 (apache-tomee-8.0.0-M3-plume)
现在使用旧版本不需要,但是使用 tomee-8.0.0 有必要在 Project Facets 中设置 JPA(当检查 JPA 屏幕警报以配置它时),或在 JPA 项目属性中设置。
我已经测试了两个 tomee 版本,现在都可以使用了。
这是我的 Tomcat v9.0 服务器 (apache-tomee-8.0.0-M3-plume)
中的 JPA 配置屏幕