4 Replies Latest reply on Aug 11, 2007 6:32 AM by Pete Muir

    Seam 2.0 weird exception in org.jboss.seam.Entity

    mgrouch Expert

      java.lang.IllegalStateException: @Id attribute not found for entity class: com.test.portal.data.entity.Team_$$_javassist_9

      at org.jboss.seam.Entity.getIdentifier(Entity.java:159)


      Team entity definitely has @Id and it is loaded fully (non-lazily)
      I think somehow it is looking at proxy object instead...


        • 1. Re: Seam 2.0 weird exception in org.jboss.seam.Entity
          mgrouch Expert

          This is really weird to me as I would have expected class to be

          com.test.portal.data.entity.Team

          however

          getClass() prints its proxy

          com.test.portal.data.entity.Team_$$_javassist_9

          My entity is detached at that point (it is returned from session EJB under CMT) and it is fully initialized (no lazy load exception occurs when I print its values)

          I've tried setting hibernate.bytecode.use_reflection_optimizer=false
          to no avail.

          Just to explain what happens in my code

          public Object getId(Object bean) {
           return Entity.forClass(bean.getClass()).getIdentifier(bean);
           }


          getId is called for this entity (Team)

          and getIdentifier throws exception

          public Object getIdentifier(Object entity)
           {
           if (identifierGetter!=null)
           {
           return Reflections.invokeAndWrap(identifierGetter, entity);
           }
           else if (identifierField!=null)
           {
           return Reflections.getAndWrap(identifierField, entity);
           }
           else
           {
           throw new IllegalStateException("@Id attribute not found for entity class: " + getBeanClass().getName());
           }
           }


          My suspicion that is caused by class of object being
          com.test.portal.data.entity.Team_$$_javassist_9
          instead of real one
          com.test.portal.data.entity.Team.

          Any ideas?
          Thanks


          • 2. @Id attribute not found for entity class
            mgrouch Expert

            I've run out of options how to fix this issue.
            I'm still getting exception:

            @Id attribute not found for entity class

            @Id annotation is there in correct place (it is seam-gen reverse engineered
            classes anyway)

            Ideas?
            Thanks

            • 3. Re: Seam 2.0 weird exception in org.jboss.seam.Entity
              Sheldon s Newbie

              Does anyone have a solution yet? I have the same problem.

              • 4. Re: Seam 2.0 weird exception in org.jboss.seam.Entity
                Pete Muir Master

                Fixed in CVS ages ago.