You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Bengt Rodehav <be...@rodehav.com> on 2011/09/04 22:29:45 UTC
Auditor and OSGi
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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> 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. Valid aliases for this plugin are: [default]
> at
> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
> at
> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
> at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
> at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
> at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
> at
> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
> at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
> ... 21 more
> Caused by: java.lang.IllegalArgumentException:
> java.lang.ClassNotFoundException:
> se.digia.maia.common.auditlog.impl.MaiaAuditor
> at serp.util.Strings.toClass(Strings.java:164)
> at serp.util.Strings.toClass(Strings.java:108)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> ... 28 more*
/Bengt
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
I created the following JIRA:
https://issues.apache.org/jira/browse/OPENJPA-2052
/Bengt
2011/9/13 Bengt Rodehav <be...@rodehav.com>
> Hello,
>
> Just wanted to check if you've had any chance to look at this Pinak.
>
> /Bengt
>
>
> 2011/9/8 Bengt Rodehav <be...@rodehav.com>
>
>> Hello again,
>>
>> I'm not familiar with the class resolver plugin but I did the following:
>>
>> - I created a resolver (code is at the end of the mail)
>> - I configured my persistence.xml to use that resolver (persistence.xml at
>> the end of the mail)
>>
>> The above does not throw any exceptions on startup. On the other hand, I'm
>> not sure whether it's used. I added a System.out logging in
>> the getClassLoader() method but the output never shows up in runtime but it
>> does seem to show up during build time when I run the PCEnhancer ant task.
>>
>> I then tried to move my resolver into a package that I do not export (in
>> OSGi). I thought that even if the getClassLoader() method wasn't called,
>> OpenJPA might still want to find the class and then fail. But I still get no
>> errors regarding the class resolver in runtime (under OSGi). Note that at
>> this point I'm not really using OpenJPA in the container, I'm just loading
>> and initalising it.
>>
>> Not sure if this proves your point Pinaki - you be the judge.
>>
>> /Bengt
>>
>> *MyClassResolver.java*
>>
>>> *package se.digia.maia.resolver;
>>> import org.apache.openjpa.util.ClassResolver;
>>> public class MyClassResolver implements ClassResolver {
>>> @Override
>>> public ClassLoader getClassLoader(Class<?> theArg0, ClassLoader
>>> theArg1) {
>>> System.out.println("***Calling MyClassResolver***");
>>> return null;
>>> }
>>> }*
>>
>>
>> *persistence.xml*
>>
>>> *<?xml version="1.0" encoding="UTF-8"?>
>>> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>> http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
>>> version="2.0">
>>> <persistence-unit name="maiaPU" transaction-type="JTA">
>>>
>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>> osgi.jndi.service.name=jdbc/maiajta)</jta-data-source>
>>> <class>se.digia.maia.common.persistence.EntityBase</class>
>>> <class>se.digia.maia.common.security.domain.User</class>
>>> <class>se.digia.maia.common.auditlog.domain.AuditLogEntry</class>
>>> <class>se.digia.maia.core.bu.domain.BusinessUnit</class>
>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>> <validation-mode>NONE</validation-mode>
>>> <properties>
>>> <property name="openjpa.ClassResolver"
>>> value="se.digia.maia.resolver.MyClassResolver" />
>>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>> <property name="openjpa.jdbc.SynchronizeMappings"
>>> value="buildSchema(ForeignKeys=true)" />
>>> <property name="openjpa.jdbc.DBDictionary"
>>> value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
>>> <property name="openjpa.jdbc.UpdateManager" value="operation-order"
>>> />
>>> <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"
>>> />
>>> <!-- <property name="openjpa.Auditor"
>>> value="se.digia.maia.common.auditlog.impl.MaiaAuditor" />-->
>>> <!-- <property name="openjpa.InitializeEagerly" value="true" />-->
>>> <!--property name="openjpa.Auditor" value="default"/-->
>>> </properties>
>>> </persistence-unit>
>>> </persistence>*
>>
>>
>>
>>
>> 2011/9/7 Pinaki Poddar <pp...@apache.org>
>>
>>> The auditor is plugged-in in an unusual way than other plug-ins. So that
>>> might be causing this failure. But please do the following:
>>> 1. Configure any other OpenJPA plugin that takes a fully-qualified class
>>> name as property value e.g. [1]
>>> 2. Supply a org.acme.Foo class for it and package exactly the way you
>>> have
>>> packaged the Auditor implementation class.
>>> 3. Verify if the plugged-in class is loaded
>>>
>>> We will know whether it is a generic failure with loading plug-in in OSGi
>>> environment or specific to Auditor.
>>>
>>> [1]
>>>
>>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#openjpa.ClassResolver
>>>
>>> -----
>>> Pinaki Poddar
>>> Chair, Apache OpenJPA Project
>>> --
>>> View this message in context:
>>> http://openjpa.208410.n2.nabble.com/Auditor-and-OSGi-tp6759170p6769605.html
>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>
>>
>>
>
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
Hello,
Just wanted to check if you've had any chance to look at this Pinak.
/Bengt
2011/9/8 Bengt Rodehav <be...@rodehav.com>
> Hello again,
>
> I'm not familiar with the class resolver plugin but I did the following:
>
> - I created a resolver (code is at the end of the mail)
> - I configured my persistence.xml to use that resolver (persistence.xml at
> the end of the mail)
>
> The above does not throw any exceptions on startup. On the other hand, I'm
> not sure whether it's used. I added a System.out logging in
> the getClassLoader() method but the output never shows up in runtime but it
> does seem to show up during build time when I run the PCEnhancer ant task.
>
> I then tried to move my resolver into a package that I do not export (in
> OSGi). I thought that even if the getClassLoader() method wasn't called,
> OpenJPA might still want to find the class and then fail. But I still get no
> errors regarding the class resolver in runtime (under OSGi). Note that at
> this point I'm not really using OpenJPA in the container, I'm just loading
> and initalising it.
>
> Not sure if this proves your point Pinaki - you be the judge.
>
> /Bengt
>
> *MyClassResolver.java*
>
>> *package se.digia.maia.resolver;
>> import org.apache.openjpa.util.ClassResolver;
>> public class MyClassResolver implements ClassResolver {
>> @Override
>> public ClassLoader getClassLoader(Class<?> theArg0, ClassLoader theArg1)
>> {
>> System.out.println("***Calling MyClassResolver***");
>> return null;
>> }
>> }*
>
>
> *persistence.xml*
>
>> *<?xml version="1.0" encoding="UTF-8"?>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
>> version="2.0">
>> <persistence-unit name="maiaPU" transaction-type="JTA">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>> osgi.jndi.service.name=jdbc/maiajta)</jta-data-source>
>> <class>se.digia.maia.common.persistence.EntityBase</class>
>> <class>se.digia.maia.common.security.domain.User</class>
>> <class>se.digia.maia.common.auditlog.domain.AuditLogEntry</class>
>> <class>se.digia.maia.core.bu.domain.BusinessUnit</class>
>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>> <validation-mode>NONE</validation-mode>
>> <properties>
>> <property name="openjpa.ClassResolver"
>> value="se.digia.maia.resolver.MyClassResolver" />
>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>> <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)" />
>> <property name="openjpa.jdbc.DBDictionary"
>> value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
>> <property name="openjpa.jdbc.UpdateManager" value="operation-order"
>> />
>> <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
>> <!-- <property name="openjpa.Auditor"
>> value="se.digia.maia.common.auditlog.impl.MaiaAuditor" />-->
>> <!-- <property name="openjpa.InitializeEagerly" value="true" />-->
>> <!--property name="openjpa.Auditor" value="default"/-->
>> </properties>
>> </persistence-unit>
>> </persistence>*
>
>
>
>
> 2011/9/7 Pinaki Poddar <pp...@apache.org>
>
>> The auditor is plugged-in in an unusual way than other plug-ins. So that
>> might be causing this failure. But please do the following:
>> 1. Configure any other OpenJPA plugin that takes a fully-qualified class
>> name as property value e.g. [1]
>> 2. Supply a org.acme.Foo class for it and package exactly the way you have
>> packaged the Auditor implementation class.
>> 3. Verify if the plugged-in class is loaded
>>
>> We will know whether it is a generic failure with loading plug-in in OSGi
>> environment or specific to Auditor.
>>
>> [1]
>>
>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#openjpa.ClassResolver
>>
>> -----
>> Pinaki Poddar
>> Chair, Apache OpenJPA Project
>> --
>> View this message in context:
>> http://openjpa.208410.n2.nabble.com/Auditor-and-OSGi-tp6759170p6769605.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>
>
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
Hello again,
I'm not familiar with the class resolver plugin but I did the following:
- I created a resolver (code is at the end of the mail)
- I configured my persistence.xml to use that resolver (persistence.xml at
the end of the mail)
The above does not throw any exceptions on startup. On the other hand, I'm
not sure whether it's used. I added a System.out logging in
the getClassLoader() method but the output never shows up in runtime but it
does seem to show up during build time when I run the PCEnhancer ant task.
I then tried to move my resolver into a package that I do not export (in
OSGi). I thought that even if the getClassLoader() method wasn't called,
OpenJPA might still want to find the class and then fail. But I still get no
errors regarding the class resolver in runtime (under OSGi). Note that at
this point I'm not really using OpenJPA in the container, I'm just loading
and initalising it.
Not sure if this proves your point Pinaki - you be the judge.
/Bengt
*MyClassResolver.java*
> *package se.digia.maia.resolver;
> import org.apache.openjpa.util.ClassResolver;
> public class MyClassResolver implements ClassResolver {
> @Override
> public ClassLoader getClassLoader(Class<?> theArg0, ClassLoader theArg1)
> {
> System.out.println("***Calling MyClassResolver***");
> return null;
> }
> }*
*persistence.xml*
> *<?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
> version="2.0">
> <persistence-unit name="maiaPU" transaction-type="JTA">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <jta-data-source>osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=jdbc/maiajta)</jta-data-source>
> <class>se.digia.maia.common.persistence.EntityBase</class>
> <class>se.digia.maia.common.security.domain.User</class>
> <class>se.digia.maia.common.auditlog.domain.AuditLogEntry</class>
> <class>se.digia.maia.core.bu.domain.BusinessUnit</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> <validation-mode>NONE</validation-mode>
> <properties>
> <property name="openjpa.ClassResolver"
> value="se.digia.maia.resolver.MyClassResolver" />
> <property name="openjpa.ConnectionFactoryMode" value="managed" />
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
> <property name="openjpa.jdbc.DBDictionary"
> value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
> <property name="openjpa.jdbc.UpdateManager" value="operation-order"
> />
> <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
> <!-- <property name="openjpa.Auditor"
> value="se.digia.maia.common.auditlog.impl.MaiaAuditor" />-->
> <!-- <property name="openjpa.InitializeEagerly" value="true" />-->
> <!--property name="openjpa.Auditor" value="default"/-->
> </properties>
> </persistence-unit>
> </persistence>*
2011/9/7 Pinaki Poddar <pp...@apache.org>
> The auditor is plugged-in in an unusual way than other plug-ins. So that
> might be causing this failure. But please do the following:
> 1. Configure any other OpenJPA plugin that takes a fully-qualified class
> name as property value e.g. [1]
> 2. Supply a org.acme.Foo class for it and package exactly the way you have
> packaged the Auditor implementation class.
> 3. Verify if the plugged-in class is loaded
>
> We will know whether it is a generic failure with loading plug-in in OSGi
> environment or specific to Auditor.
>
> [1]
>
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#openjpa.ClassResolver
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Auditor-and-OSGi-tp6759170p6769605.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
Re: Auditor and OSGi
Posted by Pinaki Poddar <pp...@apache.org>.
The auditor is plugged-in in an unusual way than other plug-ins. So that
might be causing this failure. But please do the following:
1. Configure any other OpenJPA plugin that takes a fully-qualified class
name as property value e.g. [1]
2. Supply a org.acme.Foo class for it and package exactly the way you have
packaged the Auditor implementation class.
3. Verify if the plugged-in class is loaded
We will know whether it is a generic failure with loading plug-in in OSGi
environment or specific to Auditor.
[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#openjpa.ClassResolver
-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/Auditor-and-OSGi-tp6759170p6769605.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Auditor and OSGi
Posted by Kevin Sutter <kw...@gmail.com>.
Hi Bengt,
It sure sounds like you have narrowed down the problem. I would suggest
opening a JIRA for this problem with the information you have provided and
then "push" for it to be worked on... :-)
I'm also going to cross post to dev on the chance we could get some interest
in developing a fix for this...
Thanks,
Kevin
On Tue, Sep 6, 2011 at 2:43 PM, Bengt Rodehav <be...@rodehav.com> wrote:
> Hello again,
>
> As I didn't get any replies on this post here on the OpenJPA forum I tried
> on the Aries list since I thought the problem might lie in Aries JPA
> container. I got the following reply from 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!"*
>
>
> Looking at the stack trace it seems clear that OpenJPA tries to load my
> Auditor implementation using its own class loader. Unless OpenJPA
> dynamically imports "*" this won't work. OpenJPA needs to use the class
> loader of the bundle containing the persistence.xml. In my case this will
> work since that bundle does import the package containing my Auditor
> implementation.
>
> Can someone on the OpenJPA team confirm this? Shalll I create a JIRA?
>
> /Bengt
>
>
> 2011/9/4 Bengt Rodehav <be...@rodehav.com>
>
> > 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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> >> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> >> static newInstance method on the named factory class
> >> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> >> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> >> 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. Valid aliases for this plugin are: [default]
> >> at
> >>
> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
> >> at
> >>
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
> >> at
> >>
> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
> >> at
> >>
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
> >> at
> >> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
> >> at
> >>
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
> >> at
> >>
> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
> >> at
> >>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
> >> at
> >> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
> >> ... 21 more
> >> Caused by: java.lang.IllegalArgumentException:
> >> java.lang.ClassNotFoundException:
> >> se.digia.maia.common.auditlog.impl.MaiaAuditor
> >> at serp.util.Strings.toClass(Strings.java:164)
> >> at serp.util.Strings.toClass(Strings.java:108)
> >> at
> >>
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> >> ... 28 more*
> >
> >
> > /Bengt
> >
> >
>
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
Hello again,
As I didn't get any replies on this post here on the OpenJPA forum I tried
on the Aries list since I thought the problem might lie in Aries JPA
container. I got the following reply from 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!"*
Looking at the stack trace it seems clear that OpenJPA tries to load my
Auditor implementation using its own class loader. Unless OpenJPA
dynamically imports "*" this won't work. OpenJPA needs to use the class
loader of the bundle containing the persistence.xml. In my case this will
work since that bundle does import the package containing my Auditor
implementation.
Can someone on the OpenJPA team confirm this? Shalll I create a JIRA?
/Bengt
2011/9/4 Bengt Rodehav <be...@rodehav.com>
> 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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
>> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
>> static newInstance method on the named factory class
>> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
>> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
>> 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. Valid aliases for this plugin are: [default]
>> at
>> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
>> at
>> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
>> at
>> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
>> at
>> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
>> at
>> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
>> at
>> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
>> at
>> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
>> at
>> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
>> ... 21 more
>> Caused by: java.lang.IllegalArgumentException:
>> java.lang.ClassNotFoundException:
>> se.digia.maia.common.auditlog.impl.MaiaAuditor
>> at serp.util.Strings.toClass(Strings.java:164)
>> at serp.util.Strings.toClass(Strings.java:108)
>> at
>> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
>> ... 28 more*
>
>
> /Bengt
>
>
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
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 <ti...@apache.org>
> 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: bengt@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 <ti...@apache.org>
>
> 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: bengt@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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> 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. Valid aliases for this plugin are: [default]
> at
> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
> at
> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
> at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
> at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
> at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
> at
> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
> at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
> ... 21 more
> Caused by: java.lang.IllegalArgumentException:
> java.lang.ClassNotFoundException:
> se.digia.maia.common.auditlog.impl.MaiaAuditor
> at serp.util.Strings.toClass(Strings.java:164)
> at serp.util.Strings.toClass(Strings.java:108)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> ... 28 more*
>
>
> /Bengt
>
>
>
>
RE: Auditor and OSGi
Posted by Timothy Ward <ti...@apache.org>.
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: bengt@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 <ti...@apache.org>
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: bengt@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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error> org.apache.openjpa.persistence.ArgumentException: Could not invoke the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
<openjpa-2.2.0-SNAPSHOT-runknown fatal user error> 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. Valid aliases for this plugin are: [default]
at org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
at org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
at org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
... 21 more
Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: se.digia.maia.common.auditlog.impl.MaiaAuditor
at serp.util.Strings.toClass(Strings.java:164)
at serp.util.Strings.toClass(Strings.java:108)
at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
... 28 more
/Bengt
Re: Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
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 <ti...@apache.org>
> 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: bengt@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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> 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. Valid aliases for this plugin are: [default]
> at
> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
> at
> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
> at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
> at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
> at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
> at
> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
> at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
> ... 21 more
> Caused by: java.lang.IllegalArgumentException:
> java.lang.ClassNotFoundException:
> se.digia.maia.common.auditlog.impl.MaiaAuditor
> at serp.util.Strings.toClass(Strings.java:164)
> at serp.util.Strings.toClass(Strings.java:108)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> ... 28 more*
>
>
> /Bengt
>
>
>
RE: Auditor and OSGi
Posted by Timothy Ward <ti...@apache.org>.
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: bengt@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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error> org.apache.openjpa.persistence.ArgumentException: Could not invoke the static newInstance method on the named factory class "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
<openjpa-2.2.0-SNAPSHOT-runknown fatal user error> 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. Valid aliases for this plugin are: [default]
at org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
at org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
at org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
... 21 more
Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: se.digia.maia.common.auditlog.impl.MaiaAuditor
at serp.util.Strings.toClass(Strings.java:164)
at serp.util.Strings.toClass(Strings.java:108)
at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
... 28 more
/Bengt
Auditor and OSGi
Posted by Bengt Rodehav <be...@rodehav.com>.
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. (<openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not invoke the
> static newInstance method on the named factory class
> "org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".)
> <openjpa-2.2.0-SNAPSHOT-runknown fatal user error>
> 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. Valid aliases for this plugin are: [default]
> at
> org.apache.openjpa.lib.conf.Configurations.getCreateException(Configurations.java:409)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:219)
> at
> org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
> at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
> at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
> at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getAuditorInstance(OpenJPAConfigurationImpl.java:1822)
> at
> org.apache.openjpa.kernel.AbstractBrokerFactory.postCreationCallback(AbstractBrokerFactory.java:854)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.postCreationCallback(JDBCBrokerFactory.java:105)
> at
> org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:67)
> ... 21 more
> Caused by: java.lang.IllegalArgumentException:
> java.lang.ClassNotFoundException:
> se.digia.maia.common.auditlog.impl.MaiaAuditor
> at serp.util.Strings.toClass(Strings.java:164)
> at serp.util.Strings.toClass(Strings.java:108)
> at
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> ... 28 more*
/Bengt