Re: Auditor and OSGi

2011-09-07 Thread Bengt Rodehav
Thanks for your advice Tim.

I have a discussion with the OpenJPA people (Pinaki) about this. It seems
the "normal" way of doing this has not been done in this case. I assume they
normally do it the way you suggest but has failed to do so for the new audit
logging facility.

In other words, there is a bug in OpenJPA that they are looking into.

Thanks for your help,

/Bengt

2011/9/7 Timothy Ward 

>  Hi,
>
> So the Aries JPA container uses the createContainerEntityManagerFactory
> method to build EMFs. This provides, amongst other things, a ClassLoader for
> the persistence unit. IMO JPA providers should use this to load config if it
> isn't found on their own classloader.
>
> Regards,
>
> Tim
>
> --
> Date: Tue, 6 Sep 2011 21:47:19 +0200
> Subject: Re: Auditor and OSGi
>
> From: be...@rodehav.com
> To: user@aries.apache.org
>
> Thanks for your reply Tim,
>
> I agree, it seems like OpenJPA uses its own classloader to load my auditor
> implementation. That won't work of course. Is best practice for JPA
> providers to use the class loader for the bundle containing  the
> persistence.xml?
>
> /Bengt
>
> 2011/9/6 Timothy Ward 
>
>  This sort of problem is usually caused by a JPA provider using the wrong
> classloader to try and find your class. If you import the *
> se.digia.maia.common.auditlog.impl* package into your persistence bundle
> *and* OpenJPA uses the Persistence Unit classloader (rather than its own) to
> load it then everything should work fine. Realistically they should try both
> their classloader and the persistence unit classloader in case the config
> property is for their own internals.
>
> Unfortunately there is a limit to how much Aries can shield JPA providers
> from OSGi classloading!
>
> Regards,
>
> Tim
>
>
>
> --
> Date: Mon, 5 Sep 2011 23:01:07 +0200
> Subject: Auditor and OSGi
> From: be...@rodehav.com
> To: user@aries.apache.org
>
>
> I posted the following mail on OpenJPA's mailing list but got no answer.
> I'm posting it on the Aries mailing list as well since I suspect that this
> may rather depend on the JPA container in Aries than on OpenJPA itself.
>
> /Bengt
>
> 
>
> Hello everyone,
>
> After a long discussion about audit logging on this mailing list, Pinaki
> developed an audit logging facility that he describes on:
>
> http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html
>
> It provides very interesting functionality and I've tried it in simple
> JUnit scenarios using RESOURCE_LOCAL and it seems to work fine. However, my
> production environment nowadays is OSGi using Karaf+Felix. I use Aries for
> transaction support and also for it's JPA support. In that environment,
> OpenJPA doesn't seem to be able to find my auditor implementation
> (se.digia.maia.common.auditlog.impl.MaiaAuditor) that I specify in my
> persistence.xml.
>
> Has anyone else tried OpenJPA's new audit log facility? How can I make
> OpenJPA find classes specified in the persistence.xml? I have double-checked
> that the se.digia.maia.common.auditlog.impl is exported from my implementing
> bundle.
>
> I get the following exception:
>
> *ERROR: Bundle org.apache.aries.jpa.container [21] EventDispatcher: Error
> during dispatch. (
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> 
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".
>  at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:76)
> at
> org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:147)
>  at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:185)
> at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
>  at
> org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:263)
> at
> org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:153)
>  at
> org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:283)
> at
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker

RE: Auditor and OSGi

2011-09-07 Thread Timothy Ward

Hi,

So the Aries JPA container uses the createContainerEntityManagerFactory method 
to build EMFs. This provides, amongst other things, a ClassLoader for the 
persistence unit. IMO JPA providers should use this to load config if it isn't 
found on their own classloader.

Regards,

Tim

Date: Tue, 6 Sep 2011 21:47:19 +0200
Subject: Re: Auditor and OSGi
From: be...@rodehav.com
To: user@aries.apache.org

Thanks for your reply Tim,
I agree, it seems like OpenJPA uses its own classloader to load my auditor 
implementation. That won't work of course. Is best practice for JPA providers 
to use the class loader for the bundle containing  the persistence.xml?

/Bengt

2011/9/6 Timothy Ward 






This sort of problem is usually caused by a JPA provider using the wrong 
classloader to try and find your class. If you import the 
se.digia.maia.common.auditlog.impl package into your persistence bundle *and* 
OpenJPA uses the Persistence Unit classloader (rather than its own) to load it 
then everything should work fine. Realistically they should try both their 
classloader and the persistence unit classloader in case the config property is 
for their own internals.


Unfortunately there is a limit to how much Aries can shield JPA providers from 
OSGi classloading!

Regards,

Tim



Date: Mon, 5 Sep 2011 23:01:07 +0200
Subject: Auditor and OSGi

From: be...@rodehav.com
To: user@aries.apache.org

I posted the following mail on OpenJPA's mailing list but got no answer. I'm 
posting it on the Aries mailing list as well since I suspect that this may 
rather depend on the JPA container in Aries than on OpenJPA itself.




/Bengt


Hello everyone,






After a long discussion about audit logging on this mailing list, Pinaki 
developed an audit logging facility that he describes on:






http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html






It provides very interesting functionality and I've tried it in simple JUnit 
scenarios using RESOURCE_LOCAL and it seems to work fine. However, my 
production environment nowadays is OSGi using Karaf+Felix. I use Aries for 
transaction support and also for it's JPA support. In that environment, OpenJPA 
doesn't seem to be able to find my auditor implementation 
(se.digia.maia.common.auditlog.impl.MaiaAuditor) that I specify in my 
persistence.xml.






Has anyone else tried OpenJPA's new audit log facility? How can I make OpenJPA 
find classes specified in the persistence.xml? I have double-checked that the 
se.digia.maia.common.auditlog.impl is exported from my implementing bundle.












I get the following exception:







ERROR: Bundle org.apache.aries.jpa.container [21] EventDispatcher: Error during 
dispatch. ( 
org.apache.openjpa.persistence.ArgumentException: Could not invoke the static 
newInstance method on the named factory class 
"org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)






 
org.apache.openjpa.persistence.ArgumentException: Could not invoke the static 
newInstance method on the named factory class 
"org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".






at 
org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:76)
at 
org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:147)






at 
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:185)
at 
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)






at 
org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:263)
at 
org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:153)






at 
org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:283)
at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)






at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
at 
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)






at 
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)






at 
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3879)






at org.apache.felix.framework.Felix.access$800(Felix.java:79)
at 
org.apache.felix.framework.Felix$StatefulResolver.fireResolvedEvents(Felix.java:4491)






at 
org.apache.felix.framewor

Re: Auditor and OSGi

2011-09-06 Thread Bengt Rodehav
Thanks for your reply Tim,

I agree, it seems like OpenJPA uses its own classloader to load my auditor
implementation. That won't work of course. Is best practice for JPA
providers to use the class loader for the bundle containing  the
persistence.xml?

/Bengt

2011/9/6 Timothy Ward 

>  This sort of problem is usually caused by a JPA provider using the wrong
> classloader to try and find your class. If you import the *
> se.digia.maia.common.auditlog.impl* package into your persistence bundle
> *and* OpenJPA uses the Persistence Unit classloader (rather than its own) to
> load it then everything should work fine. Realistically they should try both
> their classloader and the persistence unit classloader in case the config
> property is for their own internals.
>
> Unfortunately there is a limit to how much Aries can shield JPA providers
> from OSGi classloading!
>
> Regards,
>
> Tim
>
>
>
> --
> Date: Mon, 5 Sep 2011 23:01:07 +0200
> Subject: Auditor and OSGi
> From: be...@rodehav.com
> To: user@aries.apache.org
>
>
> I posted the following mail on OpenJPA's mailing list but got no answer.
> I'm posting it on the Aries mailing list as well since I suspect that this
> may rather depend on the JPA container in Aries than on OpenJPA itself.
>
> /Bengt
>
> 
>
> Hello everyone,
>
> After a long discussion about audit logging on this mailing list, Pinaki
> developed an audit logging facility that he describes on:
>
> http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html
>
> It provides very interesting functionality and I've tried it in simple
> JUnit scenarios using RESOURCE_LOCAL and it seems to work fine. However, my
> production environment nowadays is OSGi using Karaf+Felix. I use Aries for
> transaction support and also for it's JPA support. In that environment,
> OpenJPA doesn't seem to be able to find my auditor implementation
> (se.digia.maia.common.auditlog.impl.MaiaAuditor) that I specify in my
> persistence.xml.
>
> Has anyone else tried OpenJPA's new audit log facility? How can I make
> OpenJPA find classes specified in the persistence.xml? I have double-checked
> that the se.digia.maia.common.auditlog.impl is exported from my implementing
> bundle.
>
> I get the following exception:
>
> *ERROR: Bundle org.apache.aries.jpa.container [21] EventDispatcher: Error
> during dispatch. (
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> 
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".
>  at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:76)
> at
> org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:147)
>  at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:185)
> at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
>  at
> org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:263)
> at
> org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:153)
>  at
> org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:283)
> at
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
>  at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
> at
> org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
>  at
> org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
> at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
>  at
> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
> at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3879)
>  at org.apache.felix.framework.Felix.access$800(Felix.java:79)
> at
> org.apache.felix.framework.Felix$StatefulResolver.fireResolvedEvents(Felix.java:4491)
>  at
> org.apache.felix.framework.Felix$StatefulResolver.resolve(Felix.java:4162)
> at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3557)
>  at org.apache.felix.framework.Felix.startBundle(Felix.java:1797)
> at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
>  at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: org.apache.openjpa.lib.util.ParseException: Instantiation of
> plugin "Auditor" with value "se.digia.maia.common.auditlog.impl.MaiaAuditor"
> caused an error "java.lang.IllegalArgu

RE: Auditor and OSGi

2011-09-06 Thread Timothy Ward

This sort of problem is usually caused by a JPA provider using the wrong 
classloader to try and find your class. If you import the 
se.digia.maia.common.auditlog.impl package into your persistence bundle *and* 
OpenJPA uses the Persistence Unit classloader (rather than its own) to load it 
then everything should work fine. Realistically they should try both their 
classloader and the persistence unit classloader in case the config property is 
for their own internals.

Unfortunately there is a limit to how much Aries can shield JPA providers from 
OSGi classloading!

Regards,

Tim



Date: Mon, 5 Sep 2011 23:01:07 +0200
Subject: Auditor and OSGi
From: be...@rodehav.com
To: user@aries.apache.org

I posted the following mail on OpenJPA's mailing list but got no answer. I'm 
posting it on the Aries mailing list as well since I suspect that this may 
rather depend on the JPA container in Aries than on OpenJPA itself.



/Bengt


Hello everyone,





After a long discussion about audit logging on this mailing list, Pinaki 
developed an audit logging facility that he describes on:





http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-Facility-tc6722915.html





It provides very interesting functionality and I've tried it in simple JUnit 
scenarios using RESOURCE_LOCAL and it seems to work fine. However, my 
production environment nowadays is OSGi using Karaf+Felix. I use Aries for 
transaction support and also for it's JPA support. In that environment, OpenJPA 
doesn't seem to be able to find my auditor implementation 
(se.digia.maia.common.auditlog.impl.MaiaAuditor) that I specify in my 
persistence.xml.





Has anyone else tried OpenJPA's new audit log facility? How can I make OpenJPA 
find classes specified in the persistence.xml? I have double-checked that the 
se.digia.maia.common.auditlog.impl is exported from my implementing bundle.










I get the following exception:






ERROR: Bundle org.apache.aries.jpa.container [21] EventDispatcher: Error during 
dispatch. ( 
org.apache.openjpa.persistence.ArgumentException: Could not invoke the static 
newInstance method on the named factory class 
"org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)





 
org.apache.openjpa.persistence.ArgumentException: Could not invoke the static 
newInstance method on the named factory class 
"org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".





at 
org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:76)
at 
org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:147)





at 
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:185)
at 
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)





at 
org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:263)
at 
org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:153)





at 
org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:283)
at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)





at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
at 
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)





at 
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)





at 
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3879)





at org.apache.felix.framework.Felix.access$800(Felix.java:79)
at 
org.apache.felix.framework.Felix$StatefulResolver.fireResolvedEvents(Felix.java:4491)





at 
org.apache.felix.framework.Felix$StatefulResolver.resolve(Felix.java:4162)
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3557)





at org.apache.felix.framework.Felix.startBundle(Felix.java:1797)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)





at 
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.openjpa.lib.util.ParseException: Instantiation of plugin 
"Auditor" with value "se.digia.maia.common.auditlog.impl.MaiaAuditor" caused an 
error "java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: 
se.digia.maia.common.auditlog.impl.MaiaAuditor". The alias or class name may 
have been misspelled, or the class may not have be available in the class path. 
Va