Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71F4786FB for ; Wed, 7 Sep 2011 19:33:57 +0000 (UTC) Received: (qmail 44382 invoked by uid 500); 7 Sep 2011 19:33:57 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 44270 invoked by uid 500); 7 Sep 2011 19:33:56 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 44262 invoked by uid 99); 7 Sep 2011 19:33:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 19:33:55 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ey0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 19:33:51 +0000 Received: by eyd10 with SMTP id 10so7122951eyd.15 for ; Wed, 07 Sep 2011 12:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=X0p0Nb0iCGe5nMolNJhPY9zM5zqNqwd+4IBEF0fqego=; b=svSNl6iossQ+Wj83uLl1GMfTyfSDBxGL8s4/SN2c0ucQxPM3gQ2Gfl9WKAhOhb1xHE Rq6BsAN98vp7xkIEKKU0wikvSWF8ofjq6zdV4n23+Xj2uhJ8RWKz2NgjnAZ65u85YV53 LsKbwzegtviLiZKARW4bkmpQRm6nmMxYTtV1E= Received: by 10.14.4.76 with SMTP id 52mr2661309eei.83.1315424008195; Wed, 07 Sep 2011 12:33:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.14.127.138 with HTTP; Wed, 7 Sep 2011 12:33:08 -0700 (PDT) In-Reply-To: References: From: Kevin Sutter Date: Wed, 7 Sep 2011 14:33:08 -0500 Message-ID: Subject: Re: Auditor and OSGi To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016364165d9bcd15004ac5f042f --0016364165d9bcd15004ac5f042f Content-Type: text/plain; charset=ISO-8859-1 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 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 > > > 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. 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 > > > > > --0016364165d9bcd15004ac5f042f--