Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2598

BeanDisplay cannot resolve Hibernate proxy

    XMLWordPrintableJSON

Details

    Description

      When I attempt to use BeanDisplay on a Hibernate object, it fails when the object is lazily loaded. An example of the error is:

      Unable to read class file for ....entities.Location_$$_jvst70_51.getCity()

      The mapping is:

      @ManyToOne(fetch=FetchType.LAZY)
      private Location location;
      

       

      Comparing 5.4 to an older version, the difference appears to be that 5.4 is using PlasticProxyFactory. This is getMemberLocation:

      String className = member.getDeclaringClass().getName();
      ...
      location = constructMemberLocation(member, methodName, memberTypeDesc, textDescriptionCreator.createObject());
      ...
      ClassNode classNode = readClassNode(member.getDeclaringClass()); // This returns null
      

       

      The older version uses ClassFactory:

      Class declaringClass = method.getDeclaringClass();
      Class effectiveClass = importClass(declaringClass);
      ...
      CtClass ctClass = classSource.toCtClass(effectiveClass);
      

       The importClass line changes it from the proxy to the real class. That step appears to be missing in the newer version. 

       

      Changing the new version to something like this, works around the issue, but I'm not confident enough in my knowledge of the code to know if it's correct:

      Class declaringClass = member.getDeclaringClass();
      if (org.hibernate.proxy.HibernateProxy.class.isAssignableFrom(declaringClass)) {
          declaringClass = declaringClass.getSuperclass();
      }
      ClassNode classNode = readClassNode(declaringClass);

       

      Am I missing a new configuration setting or a requirement that would avoid this issue?

      Attachments

        Activity

          People

            Unassigned Unassigned
            bdeter Brian Deterling
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: