1 2 Previous Next 24 Replies Latest reply on Jun 21, 2004 2:48 AM by aloubyansky Go to original post
      • 15. Re: unexplained lock in 3.2.4
        bentins

        Here is the class header definition for xDoclet I'm using:

        /**
         * @ejb.bean name="User"
         * view-type = "local"
         * jndi-name="User"
         * type="CMP"
         * primkey-field="id"
         * schema="User"
         * cmp-version="2.x"
         *
         * @ejb.transaction type = "Required"
         *
         * @ejb.interface local-extends = "com.matrix.framework.infrastructure.model.BeanLocalInterface"
         * @ejb.home local-extends = "com.matrix.framework.infrastructure.model.BeanLocalHomeInterface"
         *
         * @ejb.persistence
         * table-name="EMI_USER"
         *
         * @ejb.finder
         * query="SELECT OBJECT(a) FROM User as a"
         * signature="java.util.Collection findAll()"
         *
         * @ejb.finder
         * query = "SELECT DISTINCT OBJECT(a) FROM User AS a WHERE a.userName=?1 AND a.password=?2"
         * signature="com.matrix.framework.ip.UserLocal findByUserNameAndPassword(java.lang.String aUserName, java.lang.String aPassword)"
         *
         * @ejb.finder
         * query = "SELECT DISTINCT OBJECT(a) FROM User AS a WHERE a.userName=?1"
         * signature = "com.matrix.framework.ip.UserLocal findByUserName(java.lang.String aUserName)"
         *
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User AS a WHERE a.person.passportNumber=?1 AND a.person.passportCountryVlId=?2"
         * signature = "com.matrix.framework.ip.UserLocal findByPassport(java.lang.String passportNumber, java.lang.String passportCountryVlId)"
         *
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User as a WHERE a.person.identificationNumber=?1"
         * signature = "com.matrix.framework.ip.UserLocal findByIdentificationNumber(java.lang.String identificationNumber)"
         *
         * @ejb.finder
         * query = "SELECT DISTINCT OBJECT(a) FROM User as a WHERE a.person.firstName = ?1 AND a.person.lastName = ?2"
         * signature = "java.util.Collection findByUserFullName(java.lang.String userFirstName, java.lang.String userLastName)"
         *
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User AS a, IN(a.roles) AS role WHERE a.organization.id=?1 AND role.roleVlId=?2"
         * signature="java.util.Collection findAllByOrganizationIdAndRoleId(java.lang.Long organizationId, java.lang.String roleId)"
         *
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User AS a, IN(a.roles) AS role WHERE role.roleVlId=?1"
         * signature="java.util.Collection findAllByRoleId(java.lang.String roleId)"
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User AS a, IN(a.roles) AS role WHERE a.person.passportNumber=?1 AND a.person.passportCountryVlId=?2 AND role.roleVlId=?3"
         * signature = "com.matrix.framework.ip.UserLocal findByPassportRole(java.lang.String passportNumber, java.lang.String passportCountryVlId, java.lang.String roleId)"
         *
         * @ejb.finder
         * query="SELECT DISTINCT OBJECT(a) FROM User as a, IN(a.roles) AS role WHERE a.person.identificationNumber=?1 AND role.roleVlId=?2"
         * signature = "com.matrix.framework.ip.UserLocal findByIdentificationNumberRole(java.lang.String identificationNumber, java.lang.String roleId)"
         *
         * @ejb.finder
         * query = "SELECT DISTINCT OBJECT(a) FROM User as a, IN(a.roles) AS role WHERE a.person.firstName = ?1 AND a.person.lastName = ?2 AND role.roleVlId=?3"
         * signature = "java.util.Collection findByUserFullNameRole(java.lang.String userFirstName, java.lang.String userLastName, java.lang.String roleId)"
         *
         * @jboss.container-configuration name = "Instance Per Transaction CMP 2.x EntityBean"
         * @jboss.persistence
         * datasource = "java:/OracleDS"
         * datasource-mapping = "Oracle9i"
         * table-name = "EMI_USER"
         *
         * @jboss.read-ahead strategy = "on-find" page-size = "4" eager-load-group = "basic"
         *
         * @jboss.load-group name="basic"
         * @jboss.load-group name="sig"
         * @jboss.load-group name="password"
         * @jboss.load-group name="relations"
         * @jboss.lazy-load-group name="sig"
         * @jboss.lazy-load-group name="password"
         * @jboss.lazy-load-group name="relations"
         **/


        • 16. Re: unexplained lock in 3.2.4
          aloubyansky

          Could you post the code and deployment descriptors?
          In the last log only one thread is running or you didn't post other threads? If you have a testcase, send it me privately.

          • 17. Re: unexplained lock in 3.2.4
            bentins

            I can post the deployment descriptors no problem, what code would you like to see, it's a lot of code there is a bean factory that automatically copies from the bean to the TO using reflection, and there is the login trasaction logic.

            I ran it against 3.2.3 the same exact ear and it works no problem, it also finds the bean in context and does much less selects to the DB. They are both configured with defaults for this test, and only UserBean has been configured to per instance cache.

            It is correct that only one thread was running, I was working as single user, performing logon. there were no other threads.


            • 18. Re: unexplained lock in 3.2.4
              aloubyansky

              I meant the code for the transaction you posted the log in the previous post.
              Ok, so looking at the log I can say that
              1. the finder is executed in its own transaction, preloads data which thorwn away when tx commits.
              2. getId() is executed w/o transaction (NotSupported), load command preloads data which is then thrown away.
              3. getSignature() is executed in the transaction which loads the instance third times now.

              Wrap everything in one transaction. If you want to get Id, use javax.ejb.EJBLocalObject.getPrimaryKey(), it won't pass the invocation down the interceptor chain.

              • 19. Re: unexplained lock in 3.2.4
                bentins

                OK. I've changed the getID to getPrimaryKey().

                How do you determine the tranaction state, by seeing the finaly in the log? I ask this because I see that it uses the same transaction ID (15) on all calls?

                If what you say on the transaction is correct it raises another question:my code opens up the transaction in a remote session bean which than makesa local call to another internal session bean (which functions as the specific controller for the action we preform,kind of a front controller pattern), which does the work on the entity bean,first calling the finder, than coping the info from the beanLocal to our Transport Object that is returned to the client servlet.Why is it that after the finder the transaction closes? since it should already be running inside a trasnaction.

                I again want to thank you for your help.

                • 20. Re: unexplained lock in 3.2.4
                  aloubyansky

                  Yes, right. The tx is suspended after the finder since you are using NotSupported. Do you also use read-only tags in jboss.xml?

                  • 21. Re: unexplained lock in 3.2.4
                    bentins

                    At the moment I have not gone through my beans and decided which will be read only,thus there are no read-only in jboss.xml, however I plan to use it when needed.

                    • 22. Re: unexplained lock in 3.2.4
                      aloubyansky

                      Seems like you are running into undetectable deadlock with a scenario like:
                      in, say, a session facade method with Required tx attr:

                      ALocal a = AUtil.getLocalHome().findByPrimaryKey(new APK(new Long(1), "avoka"));
                      a.doRequired(); // tx attribute Required
                      a.doNotSupported(); // tx attribute NotSupported

                      The doNotSupported() invocation will lead to a deadlock. Because it will find that the instance 'a' is locked. Same would be true for a.doRequiresNew().
                      Try Required for all method invocations. Plus, NotSupported is the worst option for entity beans.

                      • 23. Re: unexplained lock in 3.2.4
                        bentins

                        The only unsupported I had were the getId() which were a mistake instead of using getPrimaryKey().

                        After fixing this in my code, I managed to pass this deadlock. I still get dead locks in other places, but I now no what to investigate.One thing is bothering me, this code runs without this problem both on 3.2.3 and 3.2.2, is it a bug in those versions that allows it to run, or a bug in 3.2.4?

                        Thanks for all your help

                        • 24. Re: unexplained lock in 3.2.4
                          aloubyansky

                          What does the thread dump show when it's in the deadlock?

                          1 2 Previous Next