9 Replies Latest reply on Sep 15, 2003 12:33 AM by wolfie

    Bean lock error

    smehta

      Hello all:

      I am seeing the following error while getting getting attributes through a session Bean.
      I do not see an exception per se but on the console I see the following Error being displayed -

      "12:17:08,484 INFO [Log4jService] Creating
      12:17:08,484 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
      12:17:36,609 ERROR [BeanLock] removing bean lock and it has tx set! QPL bean=ContainerBean id=1004 tx=TransactionImpl:Xi
      dImpl [FormatId=257, GlobalId=D6Z1VH01//7, BranchQual=] synched=null timeout=5000 queue=[]"

      I am currently using jboss 3.2.1, and looking through the posts here I see that some people have had a kinda similar problem except that jboss is throwing an iilegalstateException or complains about hashcode/equals/... of the primarkKey during deployment.

      I don't see any such messages during deployment or illegalStateExceptions during runtime.

      Any help/lead/pointers would be most appreciated..

      jr

        • 1. Re: Bean lock error

          As you say, check your equals() hashCode() and serialization
          of the primary key. The check at deployment is very simple
          and won't catch all errors.

          Regards,
          Adrian

          • 2. Re: Bean lock error
            smehta

            Thank you for your response.

            Here is My PK class

            public class ContainerPK implements Serializable
            {

            public long ID = (long)0;

            public ContainerPK()
            {
            this.ID = (long)0;
            }

            public ContainerPK(long Id)
            {
            this.ID = Id;
            }

            public int hashCode()
            {
            return (int)ID;
            }

            public boolean equals(Object other)
            {
            return ((other != null) && (other instanceof ContainerPK) && ((ContainerPK)other).ID == ID);
            }

            public String toString()
            {
            return String.valueOf(ID);
            }
            }

            I have implemented the equals and hashcode method as above. Is there something else I need to do?

            Thx again

            jr

            • 3. Re: Bean lock error

              That looks correct, it is usually the reason.

              Do you have a simple test case that reproduces the problem?
              I can tell you where you are going wrong.

              Regards,
              Adrian

              • 4. Re: Bean lock error
                wolfie

                I also get exactly the same error message with JBOSS 3.2.2RC2 when using 1:1 CMR between two CMP beans with compound keys (all classes, including PKs and VOs, generated by XDoclet). All other CMR types seems to work just fine...

                • 5. Re: Bean lock error

                  There was a bug fixed in 3.2.2RC3 the compound primary key
                  mapping of CMR fields where their order wasn't checked correctly.
                  Again post an example.

                  Regards,
                  Adrian

                  • 6. Re: Bean lock error
                    wolfie

                    Thanks for the answer!

                    My code looks like this (two EJBs referencing each other in a bi-directional 1:1 relationship):

                    SystemEJB.java:

                    /**
                    * Bi-directional 1:1 relation to SystemAdministrativeInformation
                    *
                    * @ejb.interface-method
                    *
                    * @ejb.relation
                    * name="System-SystemAdministrativeInformation"
                    * role-name="System-has-SystemAdministrativeInformation"
                    *
                    * @jboss.relation-mapping style="foreign-key"
                    *
                    * @jboss.relation
                    * fk-constraint="true"
                    * fk-column="PRId"
                    * related-pk-field="pRId"
                    * @jboss.relation
                    * fk-constraint="true"
                    * fk-column="SystemNumber"
                    * related-pk-field="systemNumber"
                    */
                    abstract public SystemAdministrativeInformationLocal getSystemAdministrativeInformation();
                    abstract public void setSystemAdministrativeInformation(SystemAdministrativeInformationLocal v);



                    SystemAdministrativeInformationEJB.java:

                    /**
                    * Bi-directional 1:1 relation to System
                    *
                    * @ejb.interface-method
                    *
                    * @ejb.relation
                    * name="System-SystemAdministrativeInformation"
                    * role-name="SystemAdministrativeInformation-has-System"
                    *
                    * @jboss.relation-mapping style="foreign-key"
                    *
                    * @jboss.relation
                    * fk-constraint="true"
                    * fk-column="PRId"
                    * related-pk-field="pRId"
                    * @jboss.relation
                    * fk-constraint="true"
                    * fk-column="SystemNumber"
                    * related-pk-field="systemNumber"
                    */
                    abstract public SystemLocal getSystem();
                    /**
                    * @ejb.interface-method
                    */
                    abstract public void setSystem(SystemLocal v);


                    If I comment these code fragments out, there are no errors. Maybe I have missed something? The PK class (generated by XDoclet) consists of the fields pRId and systemNumber with corresponing column names PRId and SystemNumber in the DB. I will also try JBoss 3.2.2RC3 during the weekend to see if it fixes the problem...

                    /Ulf

                    • 7. Re: Bean lock error
                      smehta

                      Sorry for the late response.

                      I am still learning the ropes on JBoss 3.2.1 as I am relatively new. We were using Jboss 2.2 for the past year and half. Due to the improved performance in 3.0, we decided to upgrade to 3.2.1.

                      After making the necessary changes in ejb-jar.xml and jboss.xml, compiling our code with the new 3.2.1 classes, I started seeing these Bean Lock Error.

                      The same code though works correctly on JB2.2 and did we not see these errors because JBoss 2.2. did not enforce these rules that 3.2.1 enforces?

                      In the meantime, I shall dig around and post the code that throws this error.

                      thx
                      -jr

                      • 8. Re: Bean lock error
                        smehta

                        Hi Adrian:

                        Your mentioned that there was a bug fixed in 3.2.2RC3 that had something to do with compund primary keys.

                        Here is another one of my other primary key classes.

                        ---------------------------------------------------------------
                        public class ContainerClassPK implements Serializable
                        {

                        public long TypeID;
                        public short CatID;

                        public ContainerClassPK()
                        {
                        TypeID = 0;
                        CatID = 0;
                        }

                        public ContainerClassPK(short catID, long typeID)
                        {
                        TypeID = typeID;
                        CatID = catID;
                        }

                        public int hashCode()
                        {
                        return (int)(TypeID ^ CatID);
                        }

                        public boolean equals(Object that)
                        {
                        return ((that == this) || ((that != null) && (that instanceof ContainerClassPK) &&
                        ((ContainerClassPK)that).CatID == CatID && ((ContainerClassPK)that).TypeID == this.TypeID));
                        }
                        }

                        -------------------------------------------------------------
                        Would th exor operation in the hashCode method be a cause?

                        jr

                        • 9. Re: Bean lock error
                          wolfie

                          I have now tested JBoss RC3.2.2RC3 and the BeanLock errors seem to be gone. Once again, thanks for your advice! :)

                          /Ulf