Bug 310176 - Most JPA Metamodel tests failed on Glassfish-v3 with ClassCastException
Summary: Most JPA Metamodel tests failed on Glassfish-v3 with ClassCastException
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/D...
Whiteboard:
Keywords: test
Depends on: 266912 296269
Blocks:
  Show dependency tree
 
Reported: 2010-04-22 14:57 EDT by Kevin Yuan CLA
Modified: 2022-06-09 10:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Yuan CLA 2010-04-22 14:57:53 EDT
This JPA 2.0 tests haven't run on Glassfish-v3 (JPA2.0 supported application server) before, this is the first run. 
There are 97 tests (total 124 test cases) in JPA 2.0 Metamodel test suite failed on Glassfish v3 with the following java.lang.ClassCastException:

<error message="org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl cannot be cast to org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl" type="java.lang.ClassCastException">java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl cannot be cast to org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl
	at org.eclipse.persistence.testing.tests.jpa.metamodel.MetamodelMetamodelTest.testAttribute_getPersistentAttributeType_BASIC_Method(MetamodelMetamodelTest.java:524)
	at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBareServer(JUnitTestCase.java:489)
	at org.eclipse.persistence.testing.framework.server.TestRunnerBean.runTest(TestRunnerBean.java:87)
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5239)
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:610)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:562)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:157)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:139)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:858)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:367)
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5211)
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5199)
	at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:201)
	at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:75)
	at $Proxy127.runTest(Unknown Source)
	at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:146)
	at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:176)
	at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:682)
	at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:216)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1841)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1695)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1078)
	at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:221)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:797)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:561)
	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2558)
	at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:492)
	at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:528)
</error>

Seems there are some class loading issues with Glassfish-v3, but need to investigate deeply.
Comment 1 Michael OBrien CLA 2010-04-22 15:45:02 EDT
>I suspect that is is a classLoader issue where 2 versions of the eclipselink.jar library are being used.
Usually when we get a [packageA.classA cannot be cast to packageA.ClassA] where the classes are identical - it is a classLoader issue
- we need to check that the [org.eclipse.persistence.jpa.jar] library as part of the 5 org.eclipse.persistence.* jars in the GlassFish V3 glassfish/modules is the only library being used by the test suite.
- we also need to verify that all the server SSB and client use that same library
Comment 2 Michael OBrien CLA 2010-04-22 15:51:45 EDT
>line is
 EntityTypeImpl<Manufacturer> entityManufacturer_ = (EntityTypeImpl)metamodel.entity(Manufacturer.class);
>this is better
 EntityTypeImpl<Manufacturer> entityManufacturer_ = (EntityTypeImpl<Manufacturer>)metamodel.entity(Manufacturer.class);
>this will work with only interfaces
 EntityType<Manufacturer> entityManufacturer_ = (EntityType<Manufacturer>)metamodel.entity(Manufacturer.class);
>as will this (avoiding the cast) which is an even better and a quick fix (without fixing why we get the CCE)
 EntityType<Manufacturer> entityManufacturer_ = metamodel.entity(Manufacturer.class);
Comment 3 Michael OBrien CLA 2010-04-29 14:12:37 EDT
>see related deferred bugs
bug# 296269 : JPA 2.0: Add GlassFish V3 configuration process to enable the JPA 2.0 library functionality

bug# 297711 : Build: Glassfish library override requires new build-eclipselink-bundle-jars
Comment 4 Kevin Yuan CLA 2010-05-04 15:39:10 EDT
Since the bug 311606 (org.eclipse.persistence.internal.jpa.metamodel was missed in "Export-Package" for org.eclipse.persistence.jpa_2.1.0.qualifier.jar), all files with package org.eclipse.persistence.internal.jpa.metamodel couldn't
be loaded on Glassfish-v3 when using
"org.eclipse.persistence.jpa_2.1.0.qualifier.jar".
By manually adding package org.eclipse.persistence.internal.jpa.metamodel in in MANIFEST.MF within this jar, also remove eclipselink.jar from Glassfish\domains\<domain_name>\lib, all metamodel tests passed.

The second fix (in glassfish.xml) was checked in trunk, revision#: 7151

Code reviewed by: Edwin Tang.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:20:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink