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 42F71FC18 for ; Wed, 1 May 2013 19:09:35 +0000 (UTC) Received: (qmail 85177 invoked by uid 500); 1 May 2013 19:09:33 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 85139 invoked by uid 500); 1 May 2013 19:09:33 -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 85129 invoked by uid 99); 1 May 2013 19:09:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 19:09:33 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of subashsdm@gmail.com designates 209.85.128.42 as permitted sender) Received: from [209.85.128.42] (HELO mail-qe0-f42.google.com) (209.85.128.42) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 19:09:27 +0000 Received: by mail-qe0-f42.google.com with SMTP id 1so1086127qee.1 for ; Wed, 01 May 2013 12:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=tmi5VdcTIUAq/DxsxY/bkLx0gHGvTwy9LncJIzQMye4=; b=o0uTsqRx9AeA6Ad7WKB2bo3mom4SlSwkCmb5eHHsnk2Jowx6s4CdDXoS2UYt/gPKQ0 g+xkeTp3PIZZS+BaU1imIJxlCE+emTnm2pEDkpzzj0bt9xJW5sP/K7bPNG4zMfvNPa80 JIDYevgK9J6dXDGkQZylwDed/FD90TK8P2mTKuS/Mx+r/oZxPeEoC6WkcGjoHVsdIzv6 Q2Z+lapgVRnkIkC0LY7Ko3VYUFlwOe+1kWyDdS1CTxFL+WJyTtEGnIBio0EJIPkJ5VKC UdU8rxdWGZq+zUU2ajZP7wQBV3bkKKCDbBXGHxWNqN+s8N9VbErtUnhJYX5mYOahMsxN 6bwA== MIME-Version: 1.0 X-Received: by 10.224.92.81 with SMTP id q17mr4722801qam.61.1367435346401; Wed, 01 May 2013 12:09:06 -0700 (PDT) Received: by 10.49.12.42 with HTTP; Wed, 1 May 2013 12:09:06 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 May 2013 00:39:06 +0530 Message-ID: Subject: Re: Is it possible to override the default openjpa persistence provider From: Subash Chaturanga To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=089e0153867c137bae04dbacda99 X-Virus-Checked: Checked by ClamAV on apache.org --089e0153867c137bae04dbacda99 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Wed, May 1, 2013 at 10:29 PM, Rick Curtis wrote: > > The reason is I want to override the EntityManager. In fact the > EntityManager.persist() > method (way I could intercept a set of JPA calls without touching any > others like Entity classes ). > Have you investigated creating an orm.xml file which denotes a default > entity listener? From the JPA 2.0 SPEC -- Default entity listeners=97enti= ty > listeners that apply to all entities in the persistence unit=97can be > specified > by means of the XML descriptor. I'd suggest downloading the JPA-2.0 spec > and reading through section 3.5. > > This is 100% easier / better way to go than trying to override the OpenJP= A > implementation. > > I think listener worked for me ;-) . Thanks > > On Tue, Apr 30, 2013 at 11:02 PM, Subash Chaturanga >wrote: > > > On Tue, Apr 30, 2013 at 11:37 PM, Subash Chaturanga > >wrote: > > > > > Hi > > > > > > Forgot to mention that, Yes I am running in an OSGi env. > > > > > > Appreciate any update on this. Is there anyone who has written a custom > > persistence provider before for JPA ? So that I can compare the > > persistence.xml file. > > Currently I just copy pasted the very same > > org.apache.openjpa.PersistenceProviderImpl code and only changed the > class > > name and checked. Still the same result. So I believe it is not > something > > in the provider class I added. I have the openjpa code with me and > > appreciate any clue where I should debug ? > > > > > > > > > > Thanks > > > > > > > > > On Tue, Apr 30, 2013 at 8:09 PM, Subash Chaturanga < > subashsdm@gmail.com > > >wrote: > > > > > >> Opps I made the error log to view so sloppy. Please see the followin= g > > >> error log. > > >> > > >> > > >> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or > > >> DataSource class name must be specified in the ConnectionDriverName > > >> property. Available properties in configuration are > > >> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698". > > >> at > > >> > > > org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSource= Factory.java:72) > > >> at > > >> > > > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactor= y(JDBCConfigurationImpl.java:844) > > >> at > > >> > > > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstanc= e(JDBCConfigurationImpl.java:602) > > >> at > > >> > > > org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRe= pository.java:1510) > > >> at > > >> > > > org.apache.openjpa.lib.conf.Configurations.configureInstance(Configuratio= ns.java:518) > > >> at > > >> > > > org.apache.openjpa.lib.conf.Configurations.configureInstance(Configuratio= ns.java:443) > > >> at > > >> > > org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:10= 4) > > >> at > > >> > > > org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepos= itoryValue.java:68) > > >> at > > >> > org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83) > > >> at > > >> > > > org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryIns= tance(OpenJPAConfigurationImpl.java:968) > > >> at > > >> > > > org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryIns= tance(OpenJPAConfigurationImpl.java:959) > > >> at > > >> > > > org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrok= erFactory.java:638) > > >> at > > >> > > > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerF= actory.java:203) > > >> at > > >> > > > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBro= kerFactory.java:156) > > >> at > > >> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:227) > > >> at > > >> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:154) > > >> at > > >> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:60) > > >> at > > >> > > > org.apache.juddi.config.PersistenceManager.getEntityManager(PersistenceMa= nager.java:45) > > >> at > > >> > > > org.apache.juddi.config.AppConfig.getPersistentConfiguration(AppConfig.ja= va:109) > > >> at > > org.apache.juddi.config.AppConfig.loadConfiguration(AppConfig.java:95) > > >> at org.apache.juddi.config.AppConfig.(AppConfig.java:62) > > >> at org.apache.juddi.config.AppConfig.getInstance(AppConfig.java:183) > > >> at > > >> org.apache.juddi.config.AppConfig.getConfiguration(AppConfig.java:20= 5) > > >> at org.apache.juddi.Registry.start(Registry.java:55) > > >> > > >> > > >> > > >> On Tue, Apr 30, 2013 at 8:08 PM, Subash Chaturanga < > subashsdm@gmail.com > > >wrote: > > >> > > >>> > > >>> > > >>> On Tue, Apr 30, 2013 at 6:56 PM, Rick Curtis > > wrote: > > >>> > > >>>> Is there a compelling reason that you're trying to extend OpenJPA? > > What > > >>>> container are you running in? The reason I ask is that I see that > > >>>> org.apache > > >>>> .openjpa.osgi.OSGiPersistenceProviderImpl is a valid provider. If > you > > >>>> are > > >>>> running in an OSGI environment, that will complicate things. > > >>>> > > >>> > > >>> Hi Rick > > >>> Thank you very much for the response. > > >>> > > >>> The reason is I want to override the EntityManager. In fact the > > >>> EntityManager.persist() method (way I could intercept a set of JPA > > calls > > >>> without touching any others like Entity classes ). Thus I wanted to > > have my > > >>> own provider which will be like MyProvider extends > > >>> org.apache.openjpa.presist.PersistenceProviderImpl and provide my o= wn > > >>> entity manager factory and then I can provide my EntityManager whic= h > > will > > >>> again will (hoping) to extend default openjpa EntityManager classes= . > > >>> > > >>> Please find my persistence.xml file [1] > > >>> So I had come configuration issues and now I am getting this. Can y= ou > > >>> please provide any solution for this. > > >>> > > >>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or > > >>> DataSource class name must be specified in the ConnectionDriverName > > >>> property. Available properties in configuration are > > >>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698". at > > >>> > > > org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSource= Factory.java:72) > > >>> at > > >>> > > > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactor= y(JDBCConfigurationImpl.java:844) > > >>> at > > >>> > > > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstanc= e(JDBCConfigurationImpl.java:602) > > >>> at > > >>> > > > org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRe= pository.java:1510) > > >>> at > > >>> > > > org.apache.openjpa.lib.conf.Configurations.configureInstance(Configuratio= ns.java:518) > > >>> at > > >>> > > > org.apache.openjpa.lib.conf.Configurations.configureInstance(Configuratio= ns.java:443) > > >>> at > > >>> > > org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:10= 4) > > >>> at > > >>> > > > org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepos= itoryValue.java:68) > > >>> at > > org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83= ) > > >>> at > > >>> > > > org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryIns= tance(OpenJPAConfigurationImpl.java:968) > > >>> at > > >>> > > > org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryIns= tance(OpenJPAConfigurationImpl.java:959) > > >>> at > > >>> > > > org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrok= erFactory.java:638) > > >>> at > > >>> > > > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerF= actory.java:203) > > >>> at > > >>> > > > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBro= kerFactory.java:156) > > >>> at > > >>> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:227) > > >>> at > > >>> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:154) > > >>> at > > >>> > > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManag= er(EntityManagerFactoryImpl.java:60) > > >>> at > > >>> > > > org.apache.juddi.config.PersistenceManager.getEntityManager(PersistenceMa= nager.java:45) > > >>> at > > >>> > > > org.apache.juddi.config.AppConfig.getPersistentConfiguration(AppConfig.ja= va:109) > > >>> at > > org.apache.juddi.config.AppConfig.loadConfiguration(AppConfig.java:95) > > >>> at org.apache.juddi.config.AppConfig.(AppConfig.java:62) at > > >>> org.apache.juddi.config.AppConfig.getInstance(AppConfig.java:183) a= t > > >>> > org.apache.juddi.config.AppConfig.getConfiguration(AppConfig.java:205) > > at > > >>> org.apache.juddi.Registry.start(Registry.java:55) > > >>> > > >>> > > >>> [1] - http://pastebin.com/download.php?i=3D3MJtE1cZ > > >>> > > >>> > > >>> > > >>>> > > >>>> > > >>>> On Tue, Apr 30, 2013 at 1:00 AM, Subash Chaturanga < > > subashsdm@gmail.com > > >>>> >wrote: > > >>>> > > >>>> > Any idea on this please ? Please find my question posted in SO > [1] . > > >>>> This > > >>>> > is regarding openjpa 2.2.0. And I think a custom provider class > > >>>> recognizes > > >>>> > as unknown. > > >>>> > > > >>>> > Here is the code I found, this method evaluates to false for a > > custom > > >>>> > provider class as for example public class MyProviderImpl > implements > > >>>> > PersistenceProvider, ProviderUtil > > >>>> > > > >>>> > > > >>>> > private static boolean > > >>>> > *isOpenJPAPersistenceProvider*(PersistenceUnitInfo > > >>>> > pinfo, ClassLoader loader) { > > >>>> > String provider =3D pinfo.getPersistenceProviderClassNam= e(); > > >>>> > if (StringUtils.isEmpty(provider) || > > >>>> > PersistenceProviderImpl.class.getName().equals(provider)) > > >>>> > return true; > > >>>> > > > >>>> > if (loader =3D=3D null) > > >>>> > loader =3D > > >>>> > > > >>>> > > > >>>> > > > AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction(= )); > > >>>> > try { > > >>>> > if > > >>>> > > > >>>> > > (PersistenceProviderImpl.class.isAssignableFrom(Class.forName(provider, > > >>>> > false, loader))) > > >>>> > return true; > > >>>> > } catch (Throwable t) { > > >>>> > log(_loc.get("unloadable-provider", provider, > > >>>> t).getMessage()); > > >>>> > return false; > > >>>> > } > > >>>> > return false; > > >>>> > } > > >>>> > > > >>>> > > > >>>> > [1]- > > >>>> > > > >>>> > > > >>>> > > > http://stackoverflow.com/questions/16293136/openjpa-2-2-0-cannot-add-a-cu= stom-persistence-provider-class-openjpa-recogniz > > >>>> > > > >>>> > On Mon, Apr 29, 2013 at 11:18 PM, Subash Chaturanga < > > >>>> subashsdm@gmail.com > > >>>> > >wrote: > > >>>> > > > >>>> > > Hi > > >>>> > > I wrote a MyProvider > > >>>> > > extends org.apache.openjpa.persistence.PersistenceProviderImpl= . > > And > > >>>> added > > >>>> > > MyProvider as the provider in the persistence.xml. > > >>>> > > Why I did this was to override the EntityManager.persist() > method. > > >>>> But > > >>>> > > seems still the default provider class get picked up. Am i > missing > > >>>> > > something ? > > >>>> > > > > >>>> > > -- > > >>>> > > Subash Chaturanga > > >>>> > > Sri Lanka > > >>>> > > > > >>>> > > Blog - http://subashsdm.blogspot.com/ > > >>>> > > Twitter - http://twitter.com/subash89 > > >>>> > > > > >>>> > > > > >>>> > > > >>>> > > > >>>> > > > >>>> > -- > > >>>> > Subash Chaturanga > > >>>> > Department of Computer Science & Engineering > > >>>> > University of Moratuwa > > >>>> > Sri Lanka > > >>>> > > > >>>> > Blog - http://subashsdm.blogspot.com/ > > >>>> > Twitter - http://twitter.com/subash89 > > >>>> > > > >>>> > > >>>> > > >>>> > > >>>> -- > > >>>> *Rick Curtis* > > >>>> > > >>> > > >>> > > >>> > > >>> -- > > >>> Subash Chaturanga > > >>> Department of Computer Science & Engineering > > >>> University of Moratuwa > > >>> Sri Lanka > > >>> > > >>> Blog - http://subashsdm.blogspot.com/ > > >>> Twitter - http://twitter.com/subash89 > > >>> > > >>> > > >> > > >> > > >> > > >> -- > > >> Subash Chaturanga > > >> Department of Computer Science & Engineering > > >> University of Moratuwa > > >> Sri Lanka > > >> > > >> Blog - http://subashsdm.blogspot.com/ > > >> Twitter - http://twitter.com/subash89 > > >> > > >> > > > > > > > > > > > > -- > > > Subash Chaturanga > > > Department of Computer Science & Engineering > > > University of Moratuwa > > > Sri Lanka > > > > > > Blog - http://subashsdm.blogspot.com/ > > > Twitter - http://twitter.com/subash89 > > > > > > > > > > > > > > -- > > Subash Chaturanga > > Department of Computer Science & Engineering > > University of Moratuwa > > Sri Lanka > > > > Blog - http://subashsdm.blogspot.com/ > > Twitter - http://twitter.com/subash89 > > > > > > -- > *Rick Curtis* > --=20 Subash Chaturanga Department of Computer Science & Engineering University of Moratuwa Sri Lanka Blog - http://subashsdm.blogspot.com/ Twitter - http://twitter.com/subash89 --089e0153867c137bae04dbacda99--