glassfish
  1. glassfish
  2. GLASSFISH-1081

Using entity class with @ManyToOne(fetch = FetchType.LAZY) as session bean method return value produce serialization exception

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,081

      Description

      There are two classes with many-to-one relationship (it is
      implemented as LAZY):

      public class City implements Serializable
      {
      ....
      @ManyToOne(fetch = FetchType.LAZY)
      public Region getRegion()
      {
      return region;
      }

      @Entity
      @Table(name = "AO_REGION")
      public class Region implements Serializable
      {
      ...
      }

      City object is used as return value of session bean:

      @Stateless
      public class FacadeBean implements Facade
      {
      ...
      public City getCityById(int cityId)
      {
      return em.find(City.class, cityId);
      }
      ...
      }

      So calling method getCityById from client generates exception:

      Caused by: java.io.IOException: Mismatched serialization UIDs : Source (Rep.
      IDRMI:ru.amfitel.test.bean.City:B1E9E01D2BAAFA14:AE31789539030075) =
      AE31789539030075 whereas Target (Rep. ID
      RMI:ru.amfitel.test.bean.City:657A6D7B12B930E8:9E8761A15FE9F9ED) =
      9E8761A15FE9F9ED
      at com.sun.corba.ee.impl.util.RepositoryId.useFullValueDescription
      (RepositoryId.java:573)
      at com.sun.corba.ee.impl.io.ValueHandlerImpl.useFullValueDescription
      (ValueHandlerImpl.java:386)
      ....

      This can be worked around by defining field serialVersionUID in class City.
      But this is not expected by spec, as it is said that (#2.1 of spec):

      If an entity value is to be passed by value as detached object (e.g., through a
      remote interface), the entity class must implement the Serializable interface.

      There is nothing about serialVersionUID field.

        Activity

        Hide
        Tom Mueller added a comment -

        Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.

        Show
        Tom Mueller added a comment - Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.
        Hide
        vr143562 added a comment -

        added myself to the interest list

        --varun.

        Show
        vr143562 added a comment - added myself to the interest list --varun.
        Hide
        vr143562 added a comment -

        Using Glassfish build 33a here are some observations/corrections:
        1. The class specified in step 2 of
        http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#StaticWeaving
        should be oracle.toplink.essentials.weaving.StaticWeave
        instead of oracle.toplink.weaving.StaticWeave
        2. (Please confirm this) Along with toplink-essentials.jar; xercesImpl.jar also
        needs to be in path. With glassfish, xercesImpl.jar is available under
        <glassfish-install-location>/lib/ant/

        Show
        vr143562 added a comment - Using Glassfish build 33a here are some observations/corrections: 1. The class specified in step 2 of http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#StaticWeaving should be oracle.toplink.essentials.weaving.StaticWeave instead of oracle.toplink.weaving.StaticWeave 2. (Please confirm this) Along with toplink-essentials.jar; xercesImpl.jar also needs to be in path. With glassfish, xercesImpl.jar is available under <glassfish-install-location>/lib/ant/
        Hide
        tware added a comment -

        See:

        https://glassfish.dev.java.net/issues/show_bug.cgi?id=2101

        for an issue with static weaving and a workaround

        Show
        tware added a comment - See: https://glassfish.dev.java.net/issues/show_bug.cgi?id=2101 for an issue with static weaving and a workaround
        Hide
        tware added a comment -

        In the absence of the ability to use an agent on the client, you should the
        TopLink Essentials Static Weaving feature with the classes you deploy on the
        client. To find instructions, go to the following link:

        http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#LazyLoading

        And look at the sections entitles: "Static Weaving Using the StaticWeave Class
        on the Command Line" and "Static Weaving Using the weave Ant Task".

        You can then package the weaved classes on your client and serialization should
        be successful. This step puts the client VM into the state of being a "JVM
        instance of that vendor's runtime" as mentioned by the specification.

        Show
        tware added a comment - In the absence of the ability to use an agent on the client, you should the TopLink Essentials Static Weaving feature with the classes you deploy on the client. To find instructions, go to the following link: http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#LazyLoading And look at the sections entitles: "Static Weaving Using the StaticWeave Class on the Command Line" and "Static Weaving Using the weave Ant Task". You can then package the weaved classes on your client and serialization should be successful. This step puts the client VM into the state of being a "JVM instance of that vendor's runtime" as mentioned by the specification.

          People

          • Assignee:
            tware
            Reporter:
            hazurek
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: