Our Ear Project (ejb, jpa) contains hibernate core and entity manager and we use that for our persistence layer (instead of the eclipse link that is built in). This has worked for several years. The application also contains reflections 0.9.8 which like hibernate depends on dom4j 1.6.1. When trying to upgrade from 4.3.5 to 4.3.6 (or 7 or 8) the application fails to start due to a classloader issue:
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
I found a post related to dom4j and osgi class loader issues, but apparently something that was changed in 4.3.6 has broken it. I have tried to several options to work around this issue and aside from removing everything that has a dependency on dom4j have come to the conclusion there is no way to move forward without a fix.
I have found an interesting except that seems related (http://gurke300.gitbooks.io/osgi-with-spring-4-and-hibernate-4/content/hibernate_in_osgi/README.html). I appologize for not having a test case at this point, but I am hoping that this issue will be known well enough that it will not be necessary.
If there is anything I can try – a workaround or patch – please let me know and I will try immediately.
Full Stack trace:
2015-01-10 13:16:13.553 - :: ERROR [admin-listener(2)] javax.enterprise.system.core:114 - Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method 2015-01-10 13:16:13.563 - :: ERROR [admin-listener(2)] javax.enterprise.system.core:114 - Exception while preparing the app 2015-01-10 13:16:13.604 - :: ERROR [admin-listener(2)] javax.enterprise.system.core:447 - Exception during lifecycle processing org.hibernate.InvalidMappingException: Error while parsing file: META-INF/orm.xml at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1182) ~[hibernate-entitymanager-4.3.8.Final.jar:na] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:848) ~[hibernate-entitymanager-4.3.8.Final.jar:na] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) ~[hibernate-entitymanager-4.3.8.Final.jar:na] at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) ~[hibernate-entitymanager-4.3.8.Final.jar:na] at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152) ~[hibernate-entitymanager-4.3.8.Final.jar:na] at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199) ~[jpa-container.jar:na] at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107) ~[jpa-container.jar:na] at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223) ~[jpa-container.jar:na] at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510) ~[jpa-container.jar:na] at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230) ~[jpa-container.jar:na] at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168) ~[jpa-container.jar:na] at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925) [kernel.jar:na] at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434) [kernel.jar:na] at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) [kernel.jar:na] at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) [deployment-admin.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535) [kernel.jar:na] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_25] at javax.security.auth.Subject.doAs(Subject.java:360) [na:1.8.0_25] at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557) [kernel.jar:na] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_25] at javax.security.auth.Subject.doAs(Subject.java:360) [na:1.8.0_25] at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846) [kernel.jar:na] at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722) [kernel.jar:na] at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404) [rest-service.jar:na] at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234) [rest-service.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25] at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25] at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151) [jersey-server.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171) [jersey-server.jar:na] at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152) [jersey-server.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104) [jersey-server.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387) [jersey-server.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331) [jersey-server.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103) [jersey-server.jar:na] at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271) [jersey-server.jar:na] at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common.jar:na] at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common.jar:na] at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) [jersey-common.jar:na] at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254) [jersey-server.jar:na] at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028) [jersey-server.jar:na] at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:365) [jersey-container-grizzly2-http.jar:na] at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173) [rest-service.jar:na] at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179) [rest-service.jar:na] at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) [kernel.jar:na] at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) [kernel.jar:na] at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) [nucleus-grizzly-all.jar:na] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) [nucleus-grizzly-all.jar:na] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25] Caused by: org.hibernate.InvalidMappingException: Unable to read XML at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.cfg.Configuration.add(Configuration.java:518) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.cfg.Configuration.add(Configuration.java:514) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.cfg.Configuration.add(Configuration.java:688) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:726) ~[hibernate-core-4.3.8.Final.jar:na] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1177) ~[hibernate-entitymanager-4.3.8.Final.jar:na] ... 74 common frames omitted Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory at org.dom4j.io.SAXReader.read(SAXReader.java:484) ~[dom4j-1.6.1-PJI.jar:na] at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:325) ~[hibernate-core-4.3.8.Final.jar:na] ... 80 common frames omitted
|