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 0B33CFEDC for ; Wed, 1 May 2013 16:59:48 +0000 (UTC) Received: (qmail 69127 invoked by uid 500); 1 May 2013 16:59:47 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 69067 invoked by uid 500); 1 May 2013 16:59:47 -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 69059 invoked by uid 99); 1 May 2013 16:59:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 16:59:47 +0000 X-ASF-Spam-Status: No, hits=2.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of curtisr7@gmail.com designates 209.85.214.178 as permitted sender) Received: from [209.85.214.178] (HELO mail-ob0-f178.google.com) (209.85.214.178) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 16:59:43 +0000 Received: by mail-ob0-f178.google.com with SMTP id 16so1439066obc.37 for ; Wed, 01 May 2013 09:59:23 -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=aOtiKBGvcG68NQReTjn8/jetFtLjdgw5RnQKUQMNyJ8=; b=AED1BHEqv4NK2Nb9Ekq86rE/rDhXjnFHe12J2VD0WITOxPI9PC2rO8S+VT1Gm0lLij tRfcpItzXI+eP2nAouOpAmXtKgjZU1kwVKfRoN0+YrRXjWb0Rj1SBvoWswtRtw8OINHY T8RqQx0HP4N/u8xVI0mTgxomTTGtGsgOukwIjrdc+seMI7S8jBprDqnC1N01kf8gnpmK Ss66hz4BkdGqw3YSyt8IV4buolE0Xx7ynWEuq//bgBAMh/SFXIm8+L7ymMOVO2W4Fh+P Abnl/0LEwhoI8ZKzE5blD/iOSpEc+/cQQG8M2MaGYK7ERtQaYw3hGpOmTCkKUoBGRsCl yVhQ== MIME-Version: 1.0 X-Received: by 10.60.103.79 with SMTP id fu15mr824915oeb.127.1367427562982; Wed, 01 May 2013 09:59:22 -0700 (PDT) Received: by 10.60.23.36 with HTTP; Wed, 1 May 2013 09:59:22 -0700 (PDT) In-Reply-To: References: Date: Wed, 1 May 2013 11:59:22 -0500 Message-ID: Subject: Re: Is it possible to override the default openjpa persistence provider From: Rick Curtis To: users Content-Type: multipart/alternative; boundary=089e0116058c25d7b404dbab0a8e X-Virus-Checked: Checked by ClamAV on apache.org --089e0116058c25d7b404dbab0a8e Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable > The reason is I want to override the EntityManager. In fact the EntityMan= ager.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=97entity 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 OpenJPA implementation. On Tue, Apr 30, 2013 at 11:02 PM, Subash Chaturanga wr= ote: > 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 cla= ss > name and checked. Still the same result. So I believe it is not somethin= g > 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 >wrote: > > > >> Opps I made the error log to view so sloppy. Please see the following > >> 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:104) > >> at > >> > org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepos= itoryValue.java:68) > >> at > >> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:8= 3) > >> 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:205) > >> at org.apache.juddi.Registry.start(Registry.java:55) > >> > >> > >> > >> On Tue, Apr 30, 2013 at 8:08 PM, Subash Chaturanga >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 yo= u > >>>> 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 own > >>> entity manager factory and then I can provide my EntityManager which > 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 you > >>> 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:104) > >>> 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: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 implemen= ts > >>>> > PersistenceProvider, ProviderUtil > >>>> > > >>>> > > >>>> > private static boolean > >>>> > *isOpenJPAPersistenceProvider*(PersistenceUnitInfo > >>>> > pinfo, ClassLoader loader) { > >>>> > String provider =3D pinfo.getPersistenceProviderClassName(= ); > >>>> > 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() metho= d. > >>>> But > >>>> > > seems still the default provider class get picked up. Am i missi= ng > >>>> > > 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 > --=20 *Rick Curtis* --089e0116058c25d7b404dbab0a8e--