aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Ward (JIRA)" <>
Subject [jira] [Commented] (ARIES-832) JPA load-time enhamcement fails for a WAB
Date Tue, 10 Jul 2012 09:38:35 GMT


Timothy Ward commented on ARIES-832:


I'm pretty convinced that there is a big problem with the above patch. It assumes that the
provider will always provide a ClassTransformer. Not all providers do weaving, and some don't
return a ClassTransformer if the classes are already enhanced. Tearing down the persistence
units here could break working environments. 

I think that the tear-down code (and the corresponding api change) should not be committed.
The blog test fixes are clearly important though, and should be added without the rest of
the patch. 

> JPA load-time enhamcement fails for a WAB
> -----------------------------------------
>                 Key: ARIES-832
>                 URL:
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>         Environment: I am using Equinox org.eclipse.osgi_3.7.2.v20120110-1415.jar with
Apache Aries revision 1187719 
>            Reporter: Brian DePradine
>         Attachments: PATCH2.TXT, PATCH3.TXT, latest_patch.txt, patch.txt, patch_with_test_changes.txt
> I was running a test with a WAB that uses JPA, and I found that the JPA entity contained
in the WAB was not being enhanced. The reason was due to the following:
> 187  polo  WARN   [Blueprint Extender: 1] openjpa.Runtime - An error occurred while registering
a ClassTransformer with org.apache.aries.jpa.container.unit.impl.PersistenceUnitInfoImpl@69b169b1.
The error is logged along with this warning. Load-time class transformation will not be available.
> java.lang.IllegalStateException: The bundle is
not started.
> 	at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(
> 	at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(
> 	at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> 	at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
> 	at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(
> 	at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(
> 	at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(
> 	at org.apache.openjpa.lib.conf.Configurations.configureInstance(
> 	at org.apache.openjpa.lib.conf.Configurations.configureInstance(
> 	at org.apache.openjpa.lib.conf.PluginValue.instantiate(
> 	at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(
> 	at org.apache.openjpa.lib.conf.ObjectValue.instantiate(
> 	at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(
> 	at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(
> 	at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(
> 	at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(
> 	at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(
> 	at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(
> 	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(
> 	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(
> 	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.setupManager(
> 	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingBundle(
> 	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(
> 	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(
> 	at org.osgi.util.tracker.AbstractTracked.trackAdding(
> 	at org.osgi.util.tracker.AbstractTracked.trackInitial(
> 	at
>         ...............................
> It turns out that the IllegalStateException is thrown because the WAB is in the RESOLVED
state when a request for the BundleContext is made against it. The javadoc says "If this bundle
is not in the STARTING, ACTIVE, or STOPPING states or this bundle is a fragment bundle, then
this bundle has no valid BundleContext. This method will return null if this bundle has no
valid BundleContext."
> Looking at the code in EntityManagerFactoryManager.bundleStateChange() I can see the
>   public synchronized void bundleStateChange() throws InvalidPersistenceUnitException
>     switch(bundle.getState()) {
>       case Bundle.RESOLVED :
>         //If we are Resolved as a result of having stopped
>         //and missed the STOPPING event we need to unregister
>         unregisterEntityManagerFactories();
>         //Create the EMF objects if necessary
>         createEntityManagerFactories();
>         break;
>         //Starting and active both require EMFs to be registered
>       case Bundle.STARTING :
>       case Bundle.ACTIVE :
>         if(tracker == null) {
>           tracker = new ServiceTracker(bundle.getBundleContext(), 
>               "org.osgi.service.jdbc.DataSourceFactory", this);
> ;
>         }
>         registerEntityManagerFactories();
>         break;
>         //Stopping means the EMFs should
>       case Bundle.STOPPING :
>         //If we're stopping we no longer need to be quiescing
>         quiesce = false;
>         if(tracker != null) {
>           tracker.close();
>           tracker = null;
>         }
>         unregisterEntityManagerFactories();
>         break;
>       case Bundle.INSTALLED :
>         //Destroy everything
>         destroyEntityManagerFactories();
>     }
>   }
> This clearly shows that createEntityManagerFactories() gets driven when the WAB is in
the RESOLVED state which results in the exception above. It looks like this should affect
more than just WABs, but I have only hit this issue with WABs so far.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message