On Wed, May 1, 2013 at 10:29 PM, Rick Curtis <curti...@gmail.com> 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—entity > listeners that apply to all entities in the persistence unit—can 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. > > I think listener worked for me ;-) . Thanks > > On Tue, Apr 30, 2013 at 11:02 PM, Subash Chaturanga <subash...@gmail.com > >wrote: > > > On Tue, Apr 30, 2013 at 11:37 PM, Subash Chaturanga <subash...@gmail.com > > >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 < > subash...@gmail.com > > >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(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.<init>(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 < > subash...@gmail.com > > >wrote: > > >> > > >>> > > >>> > > >>> On Tue, Apr 30, 2013 at 6:56 PM, Rick Curtis <curti...@gmail.com> > > 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 < > > subash...@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 = 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 < > > >>>> subash...@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* > -- Subash Chaturanga Department of Computer Science & Engineering University of Moratuwa Sri Lanka Blog - http://subashsdm.blogspot.com/ Twitter - http://twitter.com/subash89