[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
Re: [eclipselink-users] Re: EclipseLink 2.0.1 jars...?
 | 
Hi Magnus,
  Spring is actually more similar to a JEE container than it is to a non JEE 
container - it provides much of the same functionality as a JEE container. 
(e.g. it ships and uses the javax.persistence classes, and initializes 
persistence units like a JEE container)
  The issue we are trying to solve by providing a subset of the 
javax.persistence classes in the EclipseLink 2.0 jar is to allow it to be a JPA 
1.0 provider and a JPA 2.0 provider.
  In your first two attempts, the class that is causing issues is a JPA 2.0 
class (referenced by a class within EclipseLink)  The class is in the 
EclipseLink jar.  My guess is that something is enforcing the fact that classes 
from the same package cannot exist in different jars.  Does spring do that?  Is 
the jar containing javax.persistence classes in Spring signed/sealed?
  In your third attempt, you have solved that problem by removing the classes 
that are in a package that is split between jars.  That is why it works.
  You are correct that we need to work on better documenting how to configure 
EclipseLink 2.0 on containers that ship with JPA 1.0 support.
  Here is the wiki page that has some initial documentation.  We still have 
some work to do:
http://wiki.eclipse.org/EclipseLink/Examples/JPA#Tutorials
-Tom
Magnus Heino wrote:
On Fri, Feb 26, 2010 at 3:20 PM, Tom Ware <tom.ware@xxxxxxxxxx 
<mailto:tom.ware@xxxxxxxxxx>> wrote:
    Hi Magnus,
     What problem is having the javax.persistence classes in
    eclipselink.jar causing?  Are you trying to use JPA 2.0 functionality?
Well, I think this text from http://wiki.eclipse.org/EclipseLink/Maven 
is a bit missleading talking about the EclipseLink 2.0 "complete" jar:
""""
        Full functionality - non OSGI
This is the recommended way of getting EclipseLink unless you are using 
OSGi, or you want to explicitly exclude certain parts of EclipseLink
    * eclipselink
    * javax.persistence (optional - only needed if you are using JPA
      outside of a Java EE containe
""""
Since I am booting jpa from within Spring, not Jboss, I guess I am using 
it outside of a JEE container? Spring is managing everything for me. 
Anyway...
First try:
I replaced ejb-persistence.jar (jpa1 api) from jboss server/default/lib 
with javax-persistence-2.0.jar , added eclipselink-2.0.1.jar to by 
WEB-INF/lib, updated orx.xml/persistence.xml and deployed:
[exec] [INFO] [talledLocalContainer] Caused by: 
java.lang.NoClassDefFoundError: javax/persistence/Cache
     [exec] [INFO] [talledLocalContainer] at 
java.lang.Class.getDeclaredMethods0(Native Method)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.Class.privateGetPublicMethods(Class.java:2547)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.Class.getMethods(Class.java:1410)
     [exec] [INFO] [talledLocalContainer] at 
sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:409)
     [exec] [INFO] [talledLocalContainer] at 
sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:306)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.reflect.Proxy.getProxyClass(Proxy.java:501)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
     [exec] [INFO] [talledLocalContainer] at 
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.createEntityManagerFactoryProxy(AbstractEntityManagerFactoryBean.java:344)
     [exec] [INFO] [talledLocalContainer] at 
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:321)
     [exec] [INFO] [talledLocalContainer] at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
     [exec] [INFO] [talledLocalContainer] at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
     [exec] [INFO] [talledLocalContainer] ... 164 more
     [exec] [INFO] [talledLocalContainer] Caused by: 
java.lang.ClassNotFoundException: Unexpected error during load of: 
javax.persistence.Cache, msg=loader constraint violation: loader 
(instance of org/jboss/mx/loading/UnifiedClassLoader3) previously 
initiated loading for a different type with name "javax/persistence/Cache"
     [exec] [INFO] [talledLocalContainer] at 
org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:560)
     [exec] [INFO] [talledLocalContainer] at 
org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     [exec] [INFO] [talledLocalContainer] ... 176 more
     [exec] [INFO] [talledLocalContainer] Caused by: 
java.lang.LinkageError: loader constraint violation: loader (instance of 
org/jboss/mx/loading/UnifiedClassLoader3) previously initiated loading 
for a different type with name "javax/persistence/Cache"
This is because eclipselink-jar contains a subset of whats in 
javax-peristence-2.0.jar 
Second attempt, I removed javax-persistence-2.0.jar
     [exec] [INFO] [talledLocalContainer] Caused by: 
java.lang.ClassNotFoundException: No ClassLoaders found for: 
javax.persistence.PersistenceContext
     [exec] [INFO] [talledLocalContainer] at 
org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
     [exec] [INFO] [talledLocalContainer] at 
org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
     [exec] [INFO] [talledLocalContainer] at 
org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
     [exec] [INFO] [talledLocalContainer] at 
java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     [exec] [INFO] [talledLocalContainer] ... 153 more 
Third try, added javax-persistence-2.0.jar and stripped 
eclipselink.jar... success :-)
     eclipselink.jar has some of the javax.persistence classes because
    although it is the JPA 2.0 reference implementation, it still
    supports JPA 1.0 and needs some of those classes to maintain that
    support.
Why isn't it possible to require persistence-api-1.0.jar on the classpath?
 
     The bundles have no-such issue and for servers that do not
    explicitly package eclipselink.jar likely provide a good way of
    avoiding this issue.  If you need help selecting the bundles to use,
    I can help with that.
I'm ok with it now, thanks. However, I do think 
that http://wiki.eclipse.org/EclipseLink/Maven could be a bit more 
informative.
/Magnus
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users