glassfish
  1. glassfish
  2. GLASSFISH-15775

Remote EJBs fail with ClassCastException in embeddable Glassfish

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1_dev
    • Fix Version/s: 3.1.1_dev, 4.0
    • Component/s: embedded
    • Labels:
      None

      Description

      I think I've found a specification violation in the embeddable Glassfish project. My apologies if it turns out that this is not the case, but I've taken the liberty of setting the priority to Major because I don't see any wiggling out of this one.

      Here's what the specification has to say about business interfaces of stateless session beans in section 4.9.7:

      "If the business interface is a remote business interface, the argument and return values must be of valid types for RMI/IIOP. The remote business interface is not required or expected to be a java.rmi.Remote interface."

      My business interface is declared thusly:

      public interface AppealTypeManager extends DAO<Long, AppealType>

      { public Collection <? extends AppealType> findAllAppealTypes(final PagingControl pagingControl); }

      (Note the lack of @Remote, and the lack of "extends Remote".)

      My bean class is declared thusly:

      @Stateless//(name = "AppealTypeManager")
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      @Remote(AppealTypeManager.class)
      public class AppealTypeManagerBean extends AbstractDAO<Long, AppealType, AppealTypeEntity> implements AppealTypeManager

      { // ...etc. }

      I look up a reference to the remote business interface like this:

      final Context c = new InitialContext();
      final AppealTypeManager a = (AppealTypeManager)c.lookup("java:global/test-classes/AppealTypeManagerBean");

      When I deploy my EJB module to embeddable Glassfish, I get the following error upon lookup:

      javax.naming.NamingException: Lookup failed for 'java:global/test-classes/AppealTypeManagerBean' in SerialContext[myEnv=

      {java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

      [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jenzabar.ngp.ia.designation.api.AppealTypeManager [Root exception is java.lang.ClassCastException]]
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:525)
      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 com.jenzabar.junit.ejb.dbunit.mem.GlassfishEmbeddedStrategy.getBean(GlassfishEmbeddedStrategy.java:126)
      at com.jenzabar.junit.ejb.dbunit.mem.AbstractEJBTestCase.setUp(AbstractEJBTestCase.java:98)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:145)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:104)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1017)
      Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jenzabar.ngp.ia.designation.api.AppealTypeManager [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:559)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:521)
      ... 34 more
      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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:422)
      ... 38 more
      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)
      ... 50 more

      Again, the specification does not require a remote business interface to extend java.rmi.Remote, but it would appear that the Glassfish embedded runtime thinks it's necessary.

        Activity

        ljnelson created issue -
        Bhavanishankar made changes -
        Field Original Value New Value
        Assignee Bhavanishankar [ bhavanishankar ] marina vatkina [ mvatkina ]
        Component/s ejb_container [ 10596 ]
        Component/s embedded [ 10643 ]
        marina vatkina made changes -
        Summary Specification violation in embeddable Glassfish? Remote EJBs fail with ClassCastException in embeddable Glassfish?
        marina vatkina made changes -
        Summary Remote EJBs fail with ClassCastException in embeddable Glassfish? Remote EJBs fail with ClassCastException in embeddable Glassfish
        marina vatkina made changes -
        Assignee marina vatkina [ mvatkina ] Bhavanishankar [ bhavanishankar ]
        Component/s embedded [ 10643 ]
        Component/s ejb_container [ 10596 ]
        ljnelson made changes -
        Comment [ This is a false alarm.

        @Remote doesn't have anything to do with it.

        It has to do with inheritance.

        Suppose there is an interface named SimpleStateless.

        Now suppose there is a POJO named SimpleStatelessBean that implements it.

        Now suppose there is a stateless session bean named SimpleStatelessBeanExtension that extends SimpleStatelessBean and is annotated with @Stateless.

        This will cause the failure. ]
        Nazrul made changes -
        Tags 3_1-fishcat 3_1-exclude 3_1-fishcat
        Nazrul made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-exclude 3_1-fishcat 3_1-release-notes
        Scott Fordin made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-notes 3_1-exclude 3_1-fishcat 3_1-need_more_info 3_1-release-notes
        Scott Fordin made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-need_more_info 3_1-release-notes 3_1-exclude 3_1-fishcat 3_1-release-notes
        Scott Fordin made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-notes 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes
        Bhavanishankar made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-scrubbed
        Bhavanishankar made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-scrubbed 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-review 3_1_1-scrubbed
        Bhavanishankar made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-review 3_1_1-scrubbed 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-review
        scatari made changes -
        Tags 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-review 3_1-exclude 3_1-fishcat 3_1-release-note-added 3_1-release-notes 3_1_1-next 3_1_1-approved
        Bhavanishankar made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s  3.1.1_b07 [ 14738 ]
        Resolution Fixed [ 1 ]
        Bhavanishankar made changes -
        Fix Version/s 3.2 [ 10969 ]
        vasilievip made changes -
        Attachment glassfish-test-arquillian.zip [ 46869 ]
        Jill Sato made changes -
        Fix Version/s 4.0 [ 10970 ]
        Fix Version/s 3.2 [ 10969 ]
        Joe Di Pol made changes -
        Affects Version/s 3.1_dev [ 17780 ]
        Joe Di Pol made changes -
        Fix Version/s 3.1.1_dev [ 17781 ]

          People

          • Assignee:
            Bhavanishankar
            Reporter:
            ljnelson
          • Votes:
            13 Vote for this issue
            Watchers:
            15 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: