users@glassfish.java.net

JUnit testing from Glassfish V3 to V3.1 EJB Lookup failed

From: <forums_at_java.net>
Date: Wed, 15 Jun 2011 08:21:01 -0500 (CDT)

        Hi,
I created some JUnit tests in Netbeans that use EJBs and all was working with
Glassfish 3.0.1. I have now installed Glassfish 3.1 and the tests fail with a
lookup error as shown in the stack trace below. If I go back to Glassfish
3.0.1 again it works. Despite lots of searching I haven't found a solution
and suspect I am missing something obvious on this. Can anyone shed any light
on this? Any help would be much appreciated.
Here is the code I use to create the container
   @BeforeClass
    public static void setUpClass() throws Exception {
        container =
javax.ejb.embeddable.EJBContainer.createEJBContainer();
    }
.. and the point int the test case that fails:
 @Test
    public void testGetProductType() throws Exception {         
        BusinessDAORemote instance =
(BusinessDAORemote)container.getContext().lookup("java:global/classes/GameDAO");
    
The stack trace...
Testcase:
testGetProductType(docrequest.dao.business.GameDAOTest):        Caused
an ERROR
Lookup failed for 'java:global/classes/GameDAO' in
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.url.pkgs=com.sun.enterprise.naming,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
javax.naming.NamingException: Lookup failed for 'java:global/classes/GameDAO'
in
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.url.pkgs=com.sun.enterprise.naming,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
[Root exception is javax.naming.NamingException: ejb ref resolution error for
remote business interfacedocrequest.dao.business.BusinessDAORemote [Root
exception is java.lang.ClassCastException]]
        at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
        at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
docrequest.dao.business.GameDAOTest.testGetProductType(GameDAOTest.java:58)
Caused by: javax.naming.NamingException: ejb ref resolution error for remote
business interfacedocrequest.dao.business.BusinessDAORemote [Root exception
is java.lang.ClassCastException]
        at
com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:434)
        at
com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
        at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at
com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
        at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
Caused by: java.lang.ClassCastException
        at
com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:262)
        at
javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
        at
com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$12.read(DynamicMethodMarshallerImpl.java:353)
        at
com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readResult(DynamicMethodMarshallerImpl.java:483)
        at
com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:203)
        at
com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
        at
com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:227)
        at
com.sun.ejb.codegen._GenericEJBHome_Generated_DynamicStub.create(com/sun/ejb/codegen/_GenericEJBHome_Generated_DynamicStub.java)
        at
com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:422)
Caused by: java.lang.ClassCastException: Object is not of remote type
java.rmi.Remote
        at
com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:254)
 


--
[Message sent by forum member 'agush']
View Post: http://forums.java.net/node/812269