|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Unrecognized persistence providerI'm trying to figure out a puzzling exception in my app. I'm using Eclipslink for JPA. I have the line
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> in my persistence.xml. However, I'm getting an exception when I reach the line EntityManagerFactory emf = Persistence.createEntityManagerFactory("LetterPU", map); The exception trace is: WARNING: Found unrecognized persistence provider "org.eclipse.persistence.jpa.PersistenceProvider" in place of OpenJPA provider. This provider's properties will not be used. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.loadClass(PersistenceUnitProcessor.java:261) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.initPersistenceUnitClasses(MetadataProcessor.java:247) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processEntityMappings(MetadataProcessor.java:422) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:296) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:830) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:101) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initPersistenceUnits(JPAInitializer.java:149) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initialize(JPAInitializer.java:135) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:104) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:64) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at com.magicballbingo.yboard.Main.initializePersistence(Main.java:166) at com.magicballbingo.yboard.Main.main(Main.java:54) Caused by: java.lang.ClassNotFoundException: org.apache.openjpa.enhance.PersistenceCapable at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) ... 25 more Now, I've never used or called for OpenJPA. I don't have any idea what's trying to load OpenJPA or why. My only imports are: import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.persistence.Persistence; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.jms.ConnectionFactory; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.eclipse.persistence.config.PersistenceUnitProperties; Any ideas? |
|
|
Re: Unrecognized persistence providerIt seems your classes have been enhanced by OpenJPA to contain references to OpenJPA classes. But these classes are not visible to your EclipseLink's classpath.
James Sutherland EclipseLink, TopLink Wiki: EclipseLink, TopLink Forums: TopLink, EclipseLink Book: Java Persistence |
|
|
Re: Unrecognized persistence providerDo you mean my entity classes have been enhanced? How would that have happened? I have never used or referred to anything about OpenJPA. I was using Toplink Essentials and then switched to Eclipselink. I've never used any other JPA implementation. Are there references to OpenJPA in the Java 6 JDK? In log4j? I've been fooling around with ActiveMQ and Apache Camel lately too, but I've purged them from the project for the moment and I'm still seeing the exception. |
|
|
Re: Unrecognized persistence providerRMMM, Hi,
The part of the code that is failing is looping through all persistence providers in your classpath. It looks like it found your default-shipped OpenJPA provider first, try putting the eclipselink.jar higher in your classpath or temporarily removing/disabling the OpenJPA jars. If you are running one of the following containers like Geronimo, WebSphere 6.1, Spring 2 or WebLogic 10 you may run into this issue. http://openjpa.apache.org/powered-by.html thank you /michael
|
|
|
Re: Unrecognized persistence providerHang on, now I'm really confused. Doesn't the NoClassDefFound exception mean that it *didn't* find the openJPA library? There are no OpenJPA jars in my classpath. I assumed it meant that something is calling explicitly for OpenJPA but it's not present. Isn't that so? I'm using plain Java and none of the containers you've listed. In general, I consider it poor design if a library doesn't play well will others, does something that creates exceptions in normal use, requires a programmer to waste hours debugging and seeking help in newsgroups and resorting to kludges like rearranging the classpath, ... If the libraries listed on the "powered by OpenJPA" page are doing anything like that, I'll regard that page as a blacklist of libraries that I will ban from projects I'm involved with. But before doing so, I want to be completely clear that that is what you are claiming about them. |
|
|
Re: Unrecognized persistence providerHi,
James is right - it looks like your classes are instrumented already. I looked at the EclipseLink code again and it is the entities that are being iterated - not the persistence providers. For the stack trace, yes, it means that the OpenJPA jars are missing from the classpath. I would inspect your .class bytecode by compiling the entities somewhere you can gaurantee that nothing else is in the classpath and do a diff or comparison of the ones you are running with in a jar or classes dir. An example of the difference can be seen in a screencap of a diff of statically weaved (instrumented) .class files below. http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/JBoss#Weaving_or_Instrumentation thank you /michael
|
| Free embeddable forum powered by Nabble | Forum Help |