glassfish
  1. glassfish
  2. GLASSFISH-12599

Injected Session Bean not serializable when it should be

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1_ms07
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      12,599
    • Status Whiteboard:
      Hide

      weld-int-required

      Show
      weld-int-required

      Description

      I have a stateless session bean Foo (no-interface local view) which implements
      Serializable.

      When I inject this bean into a client class FooClient, in one of the following ways,

      @Inject
      private Foo foo;

      or

      @EJB
      private Foo foo;

      the injected member foo fails to serialize and deserialize correctly.

      I tested this using writeObject(foo) to a stream followed by readObject(...)
      from that stream.

      In the first case (@Inject), I get a null pointer exception when calling any
      method on the object returned by readObject().

      In the second case (@EJB), writeObject(foo) fails because
      com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate is not serializable.

      In the first case, the injected instance is a javaassist proxy wrapping a
      Glassfish proxy wrapping the Foo implementation. The javasssist proxy appears to
      be broken as reported in https://jira.jboss.org/browse/JASSIST-97.

      After patching the weld-osgi-bundle.jar with javassist-3.12.1.GA which fixes the
      bug, I ran into the same problem with EJBLocalObjectInvocationHandlerDelegate as
      in the second case.

      To sum up:
      1) Glassfish needs to ensure that any proxy it generates for a serializable EJB
      is also serializable.

      2) Weld needs to be upgraded to a newer version containing the Javassist bugfix.

        Activity

        Hide
        Sivakumar Thyagarajan added a comment -

        Marking as weld-int-required

        Show
        Sivakumar Thyagarajan added a comment - Marking as weld-int-required
        Hide
        Sivakumar Thyagarajan added a comment -

        Since Weld 1.1.BETA2 with the latest javassist release is integrated and a test-
        case [1] that tries to reproduce this behaviour passes, I am closing this issue.

        [1] https://svn.dev.java.net/svn/glassfish-svn/trunk/v2/appserv-
        tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable

        Show
        Sivakumar Thyagarajan added a comment - Since Weld 1.1.BETA2 with the latest javassist release is integrated and a test- case [1] that tries to reproduce this behaviour passes, I am closing this issue. [1] https://svn.dev.java.net/svn/glassfish-svn/trunk/v2/appserv- tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable
        Hide
        buddypine added a comment -

        There is an error in the tests, the SLSB is actually marked as @Stateful - but the test still passes when changed to @Stateless.

        However if I directly inject the SLSB into the servlet then try to serialize the injected proxy it fails with a NotSerializableException.
        Should the injected SLSB proxy not be serializable?

        @WebServlet(name = "mytest", urlPatterns = { "/myurl" })
        public class NoInterfaceProxySerializableEJBTestServlet extends HttpServlet {
        
            @Inject
            HelloNoInterfaceLocalViewSlessEJB helloNoInterfaceLocalViewSlessEJB;
        .. 
        
        [#|2011-11-24T08:45:26.535+0100|SEVERE|glassfish3.1.1|
        javax.enterprise.system.std.com.sun.enterprise.server.logging
        |_ThreadID=22;_ThreadName=Thread-6;|
        java.io.NotSerializableException: test.ejb.__EJB31_Generated__HelloNoInterfaceLocalViewSlessEJB__Intf____Bean__
        
        Show
        buddypine added a comment - There is an error in the tests, the SLSB is actually marked as @Stateful - but the test still passes when changed to @Stateless. However if I directly inject the SLSB into the servlet then try to serialize the injected proxy it fails with a NotSerializableException. Should the injected SLSB proxy not be serializable? @WebServlet(name = "mytest" , urlPatterns = { "/myurl" }) public class NoInterfaceProxySerializableEJBTestServlet extends HttpServlet { @Inject HelloNoInterfaceLocalViewSlessEJB helloNoInterfaceLocalViewSlessEJB; .. [#|2011-11-24T08:45:26.535+0100|SEVERE|glassfish3.1.1| javax.enterprise.system.std.com.sun.enterprise.server.logging |_ThreadID=22;_ThreadName= Thread -6;| java.io.NotSerializableException: test.ejb.__EJB31_Generated__HelloNoInterfaceLocalViewSlessEJB__Intf____Bean__
        Hide
        marina vatkina added a comment -

        Do you have beans.xml in the your module? If not, local EJB reference is not serializable without CDI being enabled.

        Show
        marina vatkina added a comment - Do you have beans.xml in the your module? If not, local EJB reference is not serializable without CDI being enabled.
        Show
        buddypine added a comment - Yes I do. I'm simply modifying the Glassfish tests from here - http://java.net/projects/glassfish/sources/svn/show/trunk/v2/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable .

          People

          • Assignee:
            Sivakumar Thyagarajan
            Reporter:
            Harald Wellmann
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: