[ http://issues.datanucleus.org/browse/NUCACCESS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19835#action_19835 ]
Vivek Mehrotra commented on NUCACCESS-99:
-----------------------------------------
Andy, Further to this, when I try on Karaf I can see persistence provider service on karaf which my consumer now is able to find out. Untill I hit a few issues in MANIFEST.MF in org.datanucleus which after fixing it it moved further. The issues were as follows:
Caused by: java.lang.NoClassDefFoundError: javax/xml/parsers/ParserConfigurationException
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:207)
Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/Element
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:207)
After fixing the above, I hit following on karaf:
Caused by: javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "YetAnotherPersistenceUnit" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl from provider: org.datanucleus.api.jpa.PersistenceProviderImpl
at javax.persistence.Persistence.createPersistenceException(Persistence.java:242)
Caused by: org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name "" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification.
Trying to figure out why it is not able to find ClassLoaderResolver. Any hint would be helpful.
On the Datanucleus Logging on Karaf. I used log4j method and created a separate appender in org.ops4j.pax.logging.cfg
I can see my consumer bundle exceptions but DataNucleus wouldn't log and this is because of following I get on Karaf:
2012-04-27 19:49:54,584 | DEBUG | rint Extender: 3 | ClassLoading | org.datanucleus.util.Log4JLogger 58 | 106 - org.datanucleus - 3.0.0.release | Class "org.eclipse.core.runtime.RegistryFactory" was not found in the CLASSPATH [Class resolver called from org.datanucleus.plugin.PluginRegistryFactory.newInstance (line=91)]
2012-04-27 19:49:54,586 | WARN | rint Extender: 3 | Plugin | org.datanucleus.util.Log4JLogger 96 | 106 - org.datanucleus - 3.0.0.release | Could not find MANIFEST.MF file for plugin file "bundle://106.0:1/plugin.xml" so ignoring it
DataNucleus on karaf is trying to look for eclipse plugin registry and failing as above.
Any thoughts?
-Vivek
> Using Datanucleus JPA in Eclipse Virgo OSGi environment
> -------------------------------------------------------
>
> Key: NUCACCESS-99
> URL: http://issues.datanucleus.org/browse/NUCACCESS-99
> Project: DataNucleus Access Platform
> Issue Type: Task
> Components: Software
> Affects Versions: 3.0.0.m1, 3.0.0.release, 3.0.7, 3.0.9, 3.1.0.m1
> Environment: Windows 7 64 bit x86, java version "1.7.0_02", Eclipse Virgo 3.0.2.RELEASE
> Reporter: Vivek Mehrotra
> Priority: Incomplete
>
> We are writing a sample application (consumer) to use DataNucleus with JPA implementation on plain OSGi (not the Eclipse plugin way) with MySQL. We have created our application data model classes based on the example given on DataNucleus website and it works fine in our environment without OSGi.
> The application we created has three model classes as 'Car', 'Toy' and 'ToyShop'. 'Car' and 'Toy' have one-to-many cardinality. This is how my database schema is, and it is defined in orm.xml. I have a persistence.xml file which defines my persistence-unit, persistence provider and databases specific properties say connection URL, user/password etc. I also have MANIFEST.MF to handle the various run time dependencies.
> Two points:
> 1. I build this application and build is successful. I enhance the model classes and enhancement is successful. I created the database schema (tables etc) and that is successful. Now when I deploy this on Equinox (Eclipse Virgo) container, it throws up the following error:
> Caused by: javax.persistence.PersistenceException: No persistence providers available for "YetAnotherPersistenceUnit" after trying the following discovered implementations: NONE
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:182)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:72)
> I have my persistence.xml well in my CLASSPATH, no issues.
> I have my datanucleus core, api-jpa and rdbms bundles properly loaded on equinox container, no issues.
> I have apache Geronimo bundles well in place (in CLASSPATH) but, this error is due to the fact that my consumer bundle is not able to get the persistence provider.
> The reason could be, that the persistence provider on the OSGi is expected to be as service, at least Geronimo is expecting it to be exposed as an OSGi service, because it tries to get the persistence provider as:
> List<PersistenceProvider> providers = resolver.getPersistenceProviders()
> List<Object> serviceProviders = ProviderLocator.getServices(PersistenceProvider.class.getName(), this.getClass(), cl);
> The 'provider' comes out as 'null' and throws the above error.
> Based on my understanding, it tries to locate the provider service (org.apache.geronimo.osgi.locator.ProviderLocator, I have this as well) and does not get the persistence provider exposed from datanucleus and hence it returns NONE.
> At the same time, when I see on virgo admin-console to look at what are the published services from the datanucles bundles, I do not see any services published by datanucleus.api.jpa bundle, is this expected behavior?
> 2. Then I try to use the OSGi class loading mechanism to explicitly load the "org.datanucleus.api.jpa.PersistenceProviderImpl" class in somewhat similar manner as it is talked on http://www.datanucleus.org/servlet/wiki/display/USERS/HOWTO+Use+Datanucleus+with+OSGi+and+Spring+DM
> Sample code snipped is:
> DataNucleusOsgiLocalContainerEntityManagerFactoryBean dataNucleusEMFB =
> new DataNucleusOsgiLocalContainerEntityManagerFactoryBean();
>
> EntityManagerFactory emf = dataNucleusEMFB.createNativeEntityManagerFactory();
>
> EntityManager em = emf.createEntityManager();
> EntityTransaction tx = em.getTransaction();
> ...
> ...
> And a bean definition with following properties:
> <property name="persistenceXmlLocation"
> value="classpath:META-INF/persistence.xml" />
> <property name="datanucleus.plugin.pluginRegistryClassName"
> value="org.datanucleus.plugin.OSGiPluginRegistry"/>
> With this approach I get the following error. I have org.datanucleus.enhancer in my CLASSPATH.
> Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.datanucleus.enhancer.DataNucleusClassFileTransformer in KernelBundleClassLoader: [bundle=org.datanucleus.api.jpa_3.0.6]
> at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:138)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:186)
> at org.datanucleus.api.jpa.JPAClassTransformer.<init>(JPAClassTransformer.java:41)
> ... 29 common frames omitted
> Caused by: java.lang.ClassNotFoundException: org.datanucleus.enhancer.DataNucleusClassFileTransformer
> at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
> at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
> at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:134)
> ... 33 common frames omitted
> What is it I am missing here, can you please help?
> Also, ideally, I would love to have datanucleus publish the provider service which I can consume (point 1) as I am not sure how class loading may work in case of dOSGi environment which we plan to use in future.
> Note: I have tried above consumer application with datanucleus 3.0.0-m1, 3.0.0.release, 3.0.7, 3.0.9 and 3.1.0-m2.
> Thanks and best regards,
> Vivek Mehrotra
> GE Global Research
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.datanucleus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|