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

        hazurek created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 1081 32685
        Tom Mueller made changes -
        Fix Version/s not determined [ 11149 ]
        Fix Version/s 9.1pe [ 10974 ]

          People

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

            Dates

            • Created:
              Updated: