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 AF38B10B89 for ; Tue, 30 Apr 2013 14:38:53 +0000 (UTC) Received: (qmail 93859 invoked by uid 500); 30 Apr 2013 14:38:53 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 93830 invoked by uid 500); 30 Apr 2013 14:38:53 -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 93813 invoked by uid 99); 30 Apr 2013 14:38:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 14:38:53 +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 (athena.apache.org: domain of subashsdm@gmail.com designates 209.85.128.47 as permitted sender) Received: from [209.85.128.47] (HELO mail-qe0-f47.google.com) (209.85.128.47) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 14:38:49 +0000 Received: by mail-qe0-f47.google.com with SMTP id x7so321988qeu.34 for ; Tue, 30 Apr 2013 07:38:28 -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=Hf0fsaOFjXpx6uNDiQxQyhl7CFm4UbQ6nl77077fDsY=; b=deQk6Jeb43pugxI6cx/5bZ5n6erQsliJaCK+TxfEK72pld/bagH6NG7GDyZ3PQPIX0 eiPlIslfqMIBfRRFmGqb5RGx/+NFakhz5EYM7xAfAN8eUK4NsUt3V4G/T9stNxpLNhKO gx6BOf37TbXtyRHlGWXqyT332VDoNGKBWm7OFcTtVH8uNEiGOoZiIfYq+NjiQfpE/AGw WcysAK6gWqGA3H8q1zd62mefr6d6v/Prj6Fbm8AJxi3myfK4OvmYe6hnHEnBzGYhs88X lhEzZ1Bikp+hsYnNZEFasAU8aEO08pEgoN7SEiMzab81aqc4wjHOgEkYbjJMrg0QSQ/v LezQ== MIME-Version: 1.0 X-Received: by 10.224.37.134 with SMTP id x6mr16616643qad.98.1367332708559; Tue, 30 Apr 2013 07:38:28 -0700 (PDT) Received: by 10.49.12.42 with HTTP; Tue, 30 Apr 2013 07:38:28 -0700 (PDT) In-Reply-To: References: Date: Tue, 30 Apr 2013 20:08:28 +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=001a11c1f4a262658504db94f41a X-Virus-Checked: Checked by ClamAV on apache.org --001a11c1f4a262658504db94f41a Content-Type: text/plain; charset=ISO-8859-1 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 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(DataSourceFactory.java:72) at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844) at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602) at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443) at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104) at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68) at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:968) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:959) at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60) at org.apache.juddi.config.PersistenceManager.getEntityManager(PersistenceManager.java:45) at org.apache.juddi.config.AppConfig.getPersistentConfiguration(AppConfig.java: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=3MJtE1cZ > > > On Tue, Apr 30, 2013 at 1:00 AM, Subash Chaturanga >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 = pinfo.getPersistenceProviderClassName(); > > if (StringUtils.isEmpty(provider) || > > PersistenceProviderImpl.class.getName().equals(provider)) > > return true; > > > > if (loader == null) > > loader = > > > > > 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-custom-persistence-provider-class-openjpa-recogniz > > > > On Mon, Apr 29, 2013 at 11:18 PM, Subash Chaturanga > >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 --001a11c1f4a262658504db94f41a--