Как исправить проблемы с ASM в TomEE 8.x, Hibernate 5.4 и Java 8? - PullRequest
1 голос
/ 05 мая 2020

Согласно этой странице, TomEE 8.0 совместим с Java 8: http://tomee.apache.org/master/docs/java-compatibility.html

Однако у меня возникают некоторые проблемы с настройкой проекта с TomEE и Hibernate с java 8.

Я создаю проект из организации архетипа Maven. apache .openejb.maven: tomee-webapp-archetype версия 1.7.1. Мой SDK проекта - это простой JDK 1.8.0_221.

Все идет нормально. Запуск mvn package и mvn tomee:run запускает пример приложения, которое отлично работает.

Теперь я go в свой файл pom. xml и добавляю зависимость Hibernate:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>5.4.14.Final</version>
</dependency>

без доработок по проекту. mvn package по-прежнему работает нормально. Но при запуске приложения я получаю следующее:

[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< org.example:TomEETest >------------------------
[INFO] Building TomEETest TomEE Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- tomee-maven-plugin:1.7.1:run (default-cli) @ TomEETest ---
[INFO] TomEE was unzipped in '/Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee'
[INFO] Removed not mandatory default webapps
[INFO] Installed '/Users/bcassistat/IdeaProjetcs/TomEETest/target/TomEETest-1.0-SNAPSHOT.war' in /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT.war
[INFO] Running 'org.apache.openejb.maven.plugin.run'. Configured TomEE in plugin is localhost:8080 (plugin shutdown port is 8005 and https port is 8443)
Started server process on port: 8080
May 04, 2020 5:47:47 PM org.apache.catalina.core.AprLifecycleListener init
INFOS: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/bcassistat/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
May 04, 2020 5:47:47 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["http-bio-8080"]
May 04, 2020 5:47:47 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["ajp-bio-8009"]
May 04, 2020 5:47:48 PM org.apache.openejb.util.OptionsLog info
INFOS: Using 'tomee.remote.support=true'
May 04, 2020 5:47:48 PM org.apache.openejb.util.OptionsLog info
INFOS: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: ********************************************************************************
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: OpenEJB http://openejb.apache.org/
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: Startup: Mon May 04 17:47:48 EDT 2020
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: Version: 4.7.1
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: Build date: 20140912
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: Build time: 01:43
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: ********************************************************************************
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: openejb.home = /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee
May 04, 2020 5:47:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFOS: openejb.base = /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee
May 04, 2020 5:47:48 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFOS: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@587c290d
May 04, 2020 5:47:48 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFOS: Succeeded in installing singleton service
May 04, 2020 5:47:48 PM org.apache.openejb.config.ConfigurationFactory init
INFOS: openejb configuration file is '/Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/conf/tomee.xml'
[INFO] Waiting for command: [quit, exit, reload]
May 04, 2020 5:47:48 PM org.apache.openejb.config.ConfigurationFactory configureService
INFOS: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
May 04, 2020 5:47:48 PM org.apache.openejb.config.ConfigurationFactory configureService
INFOS: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
May 04, 2020 5:47:48 PM org.apache.openejb.util.OptionsLog info
INFOS: Using 'openejb.system.apps=false'
May 04, 2020 5:47:48 PM org.apache.openejb.util.OptionsLog info
INFOS: Using 'openejb.deployments.classpath=false'
May 04, 2020 5:47:48 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFOS: Creating TransactionManager(id=Default Transaction Manager)
May 04, 2020 5:47:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFOS: Creating SecurityService(id=Tomcat Security Service)
May 04, 2020 5:47:49 PM org.apache.openejb.server.SimpleServiceManager start
INFOS:   ** Bound Services **
May 04, 2020 5:47:49 PM org.apache.openejb.server.SimpleServiceManager printRow
INFOS:   NAME                 IP              PORT  
May 04, 2020 5:47:49 PM org.apache.openejb.server.SimpleServiceManager start
INFOS: -------
May 04, 2020 5:47:49 PM org.apache.openejb.server.SimpleServiceManager start
INFOS: Ready!
May 04, 2020 5:47:49 PM org.apache.catalina.startup.Catalina load
INFOS: Initialization processed in 2002 ms
May 04, 2020 5:47:49 PM org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
INFOS: Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
May 04, 2020 5:47:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFOS: Creating Resource(id=UserDatabase)
May 04, 2020 5:47:49 PM org.apache.catalina.core.StandardService startInternal
INFOS: Démarrage du service Catalina
May 04, 2020 5:47:49 PM org.apache.catalina.core.StandardEngine startInternal
INFOS: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.55 (1.7.1)
May 04, 2020 5:47:49 PM org.apache.catalina.startup.HostConfig deployWAR
INFOS: Déploiement de l'archive /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT.war de l'application web
May 04, 2020 5:47:49 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFOS: ------------------------- localhost -> /
May 04, 2020 5:47:49 PM org.apache.openejb.util.JarExtractor extract
INFOS: Extracting jar: /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT.war
May 04, 2020 5:47:49 PM org.apache.openejb.util.JarExtractor extract
INFOS: Extracted path: /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT
May 04, 2020 5:47:49 PM org.apache.openejb.util.OptionsLog info
INFOS: Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
May 04, 2020 5:47:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
AVERTISSEMENT: jar '/Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT/WEB-INF/lib/javax.persistence-api-2.2.jar' contains offending class: javax.persistence.Entity. It will be ignored.
May 04, 2020 5:47:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
AVERTISSEMENT: jar '/Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT/WEB-INF/lib/jboss-transaction-api_1.2_spec-1.1.1.Final.jar' contains offending class: javax.transaction.Transaction. It will be ignored.
May 04, 2020 5:47:49 PM org.apache.catalina.core.ContainerBase addChildInternal
GRAVE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    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:649)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module : null
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2150)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1134)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1087)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5378)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module : null
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:844)
    at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:216)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2148)
    ... 17 more
Caused by: java.lang.IllegalArgumentException
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1148)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:139)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:152)
    at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:514)
    at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:259)
    at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:77)
    at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:66)
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:836)
    ... 19 more

May 04, 2020 5:47:49 PM org.apache.catalina.startup.HostConfig deployWAR
GRAVE: Erreur lors du déploiement de l'archive /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT.war de l'application web
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

May 04, 2020 5:47:49 PM org.apache.catalina.startup.HostConfig deployWAR
INFOS: Deployment of web application archive /Users/bcassistat/IdeaProjetcs/TomEETest/target/apache-tomee/webapps/ROOT.war has finished in 474 ms
May 04, 2020 5:47:49 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["http-bio-8080"]
May 04, 2020 5:47:49 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["ajp-bio-8009"]
May 04, 2020 5:47:49 PM org.apache.catalina.startup.Catalina start
INFOS: Server startup in 637 ms

Согласно моим исследованиям, это похоже на ошибку с ASM4 с Java 8, обнаруженную на этом: java .lang.IllegalArgumentException в орг. apache .xbean.asm4.ClassReader. . Но последняя версия TomEE, которую я использую, зависит от ASM5, который должен поддерживать Java 8. И почему проблема возникает только при добавлении зависимости Hibernate? И Hibernate 5.4 кажется совместимым с Java 8.

1 Ответ

3 голосов
/ 22 июля 2020

Проблема

TomEE Webapp Archetype в версии 1.7.1 запустит (довольно) старый экземпляр TomEE (среда выполнения), см .:

ИНФОРМАЦИЯ: Запуск механизма сервлетов: Apache Tomcat (TomEE) /7.0.55 ( 1.7.1)

и

ИНФОРМАЦИЯ: Дата сборки: 2014 0912

Решение

Вместо этого используйте TomEE Webapp Archetype в версии 8.0.x (последняя: 8.0.3 ). Это исправит ситуацию с ASM, поскольку зависимости среды выполнения от запуска контейнера будут соответствовать зависимостям Hibernate 5.4.x.

Напоминание: проверяйте / проверяйте каждую (компиляцию и) время выполнения зависимость Hibernate 5.4.x предоставляется в каталоге /lib среды контейнера или связана с файлом .war вашего приложения.

...