-
Bug
-
Resolution: Obsolete
-
Major
-
None
-
None
An a dependency added automatically by AS7 using persistence provider detection cannot be excluded using jboss-deployment-structure.xml . The exclusion takes effect but does so incorrectly, producing a non-functional deployment where the persistence provider module still gets activated (if present) but cannot see its own classes via the deployment's classloader.
If the persistence provider module is not present, the deployment will fail with a missing dependency even when the automatic dependency has been excluded.
This behaviour renders it apparently impossible to package a persistence provider in a deployment's /WEB-INF/lib/ directory. If you want to do automated integration testing (say, with Arquillian) that makes it pretty impractical. Additionally, the half-excluded state is clearly just broken.
DETAIL
------
JBoss's module loader automatically adds dependencies on persistence providers declared in <provider/> entries in deployments' persistence.xml files. That's fine if a module for the provider is installed, but it also adds dependencies on modules that are not installed.
The mapping from provider to module is in jpa/core/src/main/java/org/jboss/as/jpa/config/Configuration.java and seems to be used by jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADependencyProcessor.java to add the dependency.
If a jboss-deployment-structure.xml excludes the automatically added dependency, AS7 still tries to load the module and use it. If the module isn't present (as many of the persistence provider modules aren't) this will fail the deployment.
If the module is present, the exclusion prevents the module from being visible on the deployment's classpath. If the persistence provider ever tries to access its classes via the classloader context of the depoyment (which it will) this will fail with ClassNotFoundException.
What happens if you try to publish a deployment with EclipseLink in /WEB-INF/lib but with it not present in modules/ .
18:22:01,549 INFO [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for as7.eclipselink 18:22:01,593 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war 18:22:01,661 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war".INSTALL: Failed to process phase INSTALL of deployment "a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03-icedtea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03-icedtea] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03-icedtea] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011434: Persistence provider module load error org.eclipse.persistence (class org.eclipse.persistence.jpa.PersistenceProvider) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:549) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:295) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:194) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:118) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more Caused by: org.jboss.modules.ModuleNotFoundException: Module org.eclipse.persistence:main is not found in local module loader @20a6a283 (roots: /home/craig/java/jboss-as-7.1.1.Final/modules) at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:204) [jboss-modules.jar:1.1.1.GA] at org.jboss.as.jpa.persistenceprovider.PersistenceProviderLoader.loadProviderModuleByName(PersistenceProviderLoader.java:59) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:546) ... 10 more
If the org.eclipse.persistence module is added in modules/ but excluded in jboss-deployment-structure.xml, the result is instead:
18:22:01,549 INFO [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for as7.eclipselink 18:22:01,593 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war 18:22:01,597 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named TestBase$DummyEJB in deployment unit deployment "a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war" are as follows: java:global/a7adfd8d-0104-454d-ac40-d8c5be27b2eb/TestBase$DummyEJB!id.au.ringerc.as7.eclipselinkintegration.test.TestBase$DummyEJB java:app/a7adfd8d-0104-454d-ac40-d8c5be27b2eb/TestBase$DummyEJB!id.au.ringerc.as7.eclipselinkintegration.test.TestBase$DummyEJB java:module/TestBase$DummyEJB!id.au.ringerc.as7.eclipselinkintegration.test.TestBase$DummyEJB java:global/a7adfd8d-0104-454d-ac40-d8c5be27b2eb/TestBase$DummyEJB java:app/a7adfd8d-0104-454d-ac40-d8c5be27b2eb/TestBase$DummyEJB java:module/TestBase$DummyEJB 18:22:01,661 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war".INSTALL: Failed to process phase INSTALL of deployment "a7adfd8d-0104-454d-ac40-d8c5be27b2eb.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03-icedtea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03-icedtea] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03-icedtea] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011434: Persistence provider module load error org.eclipse.persistence (class org.eclipse.persistence.jpa.PersistenceProvider) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:549) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:295) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:194) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:118) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more Caused by: org.jboss.modules.ModuleNotFoundException: Module org.eclipse.persistence:main is not found in local module loader @20a6a283 (roots: /home/craig/java/jboss-as-7.1.1.Final/modules) at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:204) [jboss-modules.jar:1.1.1.GA] at org.jboss.as.jpa.persistenceprovider.PersistenceProviderLoader.loadProviderModuleByName(PersistenceProviderLoader.java:59) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:546) ... 10 more ... and lots more ...
I'll add a test case soon.