-
15. Re: AS 7 Custom Hibernate Persistence Provider in EAR
woelfle Jun 22, 2012 8:38 AM (in response to smarlow)The service declaration of the custom persistence provider is at the specified location. Our custom PersistenceProvider already worked with JBoss 6. I've removed the dependency to 'org.hibernate' from the MANIFEST.MF. The exception remains the same:
14:37:41,739 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."ear.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."ear.ear".INSTALL: Failed to process phase INSTALL of deployment "ear.ear"
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]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0]
Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'my.custom.HibernatePersistence' not found
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:555)
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.handleEarDeployment(PersistenceUnitDeploymentProcessor.java:216)
at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:119)
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
-
16. Re: AS 7 Custom Hibernate Persistence Provider in EAR
woelfle Jun 22, 2012 8:42 AM (in response to woelfle)I've added a debug breakpoint to the PersistenceUnitDeploymentProcessor.lookupProvider method to see what happens there. As far as I can see it calls 'getProviderByName'. In that method the call to 'PersistenceProviderResolverHolder.getPersistenceProviderResolver()' returns the 'org.hibernate.ejb.HibernatePersistence' only.
Maybe this helps.
-
17. Re: AS 7 Custom Hibernate Persistence Provider in EAR
smarlow Jun 22, 2012 8:51 AM (in response to woelfle)Debugging always helps!
Can you set a breakpoint in org.jboss.as.jpa.processor.PersistenceProviderProcessor deploy() and see how far we get in the following code:
final ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES); if (module != null && servicesAttachment != null) { final ModuleClassLoader deploymentModuleClassLoader = module.getClassLoader(); PersistenceProvider provider; // collect list of persistence providers packaged with the application final List<String> providerNames = servicesAttachment.getServiceImplementations(PERSISTENCE_PROVIDER_CLASSNAME); List<PersistenceProvider> providerList = new ArrayList<PersistenceProvider>(); for (String providerName : providerNames) { try { final Class<? extends PersistenceProvider> providerClass = deploymentModuleClassLoader.loadClass(providerName).asSubclass(PersistenceProvider.class); final Constructor<? extends PersistenceProvider> constructor = providerClass.getConstructor(); provider = constructor.newInstance(); Set<ClassLoader> deploymentClassLoaders = allDeploymentModuleClassLoaders(deploymentUnit); ROOT_LOGGER.debugf("Deployment has its own persistence provider %s associated with classloaders %s", providerClass, deploymentClassLoaders.toString()); // register persistence provider so javax.persistence.Persistence.createEntityManagerFactory can find it PersistenceProviderResolverImpl.getInstance().addDeploymentSpecificPersistenceProvider(provider, deploymentClassLoaders); providerList.add(provider); } catch (Exception e) { throw MESSAGES.cannotDeployApp(e, providerName); } } if (providerList.size() > 0) { final String adapterClass = deploymentUnit.getAttachment(JpaAttachments.ADAPTOR_CLASS_NAME); PersistenceProviderAdaptor adaptor; if (adapterClass != null) { try { adaptor = (PersistenceProviderAdaptor) deploymentModuleClassLoader.loadClass(adapterClass).newInstance(); adaptor.injectJtaManager(JtaManagerImpl.getInstance()); deploymentUnit.putAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER, new PersistenceProviderDeploymentHolder(providerList, adaptor)); } catch (InstantiationException e) { throw MESSAGES.cannotCreateAdapter(e, adapterClass); } catch (IllegalAccessException e) { throw MESSAGES.cannotCreateAdapter(e, adapterClass); } catch (ClassNotFoundException e) { throw MESSAGES.cannotCreateAdapter(e, adapterClass); } } else { // register the provider (no adapter specified) deploymentUnit.putAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER, new PersistenceProviderDeploymentHolder(providerList)); } } }
I mostly want to know if we reach the "PersistenceProviderResolverImpl.getInstance().addDeploymentSpecificPersistenceProvider(provider, deploymentClassLoaders)" and one of the "deploymentUnit.putAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER ..." calls.
-
18. Re: AS 7 Custom Hibernate Persistence Provider in EAR
woelfle Jun 22, 2012 10:09 AM (in response to smarlow)"PersistenceProviderResolverImpl.getInstance().addDeploymentSpecificPersistenceProvider(provider, deploymentClassLoaders)" is reached two times. First for 'org.hibernate.ejb.HibernatePersistence' and second for 'my.custom.HibernatePersistence'. Both times the 'deployClassLoaders' are:
[ModuleClassLoader for Module "deployment.ear.ear.business.jar:main" from Service Module Loader, ModuleClassLoader for Module "deployment.ear.ear:main" from Service Module Loader]
"deploymentUnit.putAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER ..." is not reached because the call 'deploymentUnit.getAttachment(JpaAttachments.ADAPTOR_CLASS_NAME)' returns 'null'
-
19. Re: AS 7 Custom Hibernate Persistence Provider in EAR
smarlow Jun 22, 2012 10:30 AM (in response to woelfle)Hmm, isn't there an else being used?
} else { // register the provider (no adapter specified) deploymentUnit.putAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER, new PersistenceProviderDeploymentHolder(providerList)); }
-
20. Re: AS 7 Custom Hibernate Persistence Provider in EAR
smarlow Jun 22, 2012 10:33 AM (in response to smarlow)Ahh, you don't have the "else" yet. That was fixed for https://issues.jboss.org/browse/AS7-4128.
You could either try the AS7 nightly build or set persistence unit property "jboss.as.jpa.adapterModule" to value "org.jboss.as.jpa.hibernate:4".
-
21. Re: AS 7 Custom Hibernate Persistence Provider in EAR
woelfle Jun 25, 2012 9:23 AM (in response to smarlow)Great. I am a step further. Using AS 7.2.0.Alpha1 the custom hibernate persistence provider now is working. Thank you very much for your help