1 Reply Latest reply on Nov 7, 2006 4:59 AM by wdfink

    read-only

    andreas.ammer

      Hello, i recently started for a company fixing some of the problems they had in their java code. The problem remaining in the application is the amount of deadlocks in the database. The system is running on jboss 4.0.2, ejb2.0, xdoclet 1.1.2, j2sdk1.4.1, mysql 4.0.16.

      I dont know that much about configuring beans but ive noticed that trying to fix the order of all transactions in the application looks like it could take weeks if at all even possible. Ive been reading around a bit and found that you can set certain methods in a bean to read-only. For example this site: http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch5.chapter.html
      in chapter 5.4.6.4. there is a description on how making readonly methods to avoid deadlocks.

      What ive done is this.
      In the code of the bean:
      * @ejb.persistence
      * read-only="true" <<< added this
      * column-name="uuid"
      * sql-type="VARCHAR(35)"

      and in the jboss-web.xml i added method-attributes:
      <ejb-ref>
      <ejb-ref-name>ejb/SomeBean</ejb-ref-name>
      <jndi-name>ejb/SomeBean</jndi-name>
      <method-attributes>

      <method-name>getUUID</method-name>
      <read-only>true</read-only>

      </method-attributes>
      </ejb-ref>

      with the ref-name linked to the web-..xml:
      <ejb-ref>
      <ejb-ref-name>ejb/SomeBean</ejb-ref-name>
      <ejb-ref-type>EntityBean</ejb-ref-type>
      capi.SomeBeanHome
      capi.SomeBean
      </ejb-ref>

      Deadlocks only appear when accessing the primary key field (uuid) of the table, the changes ive made in both the code and the xml-file seem to have no effect at all. Is there some crucial detail im missing here? Would appreciate any input.

      Thanks in advance
      Andreas

        • 1. Re: read-only
          wdfink

          Hello,
          in your case you prevent a lock if using the method getUuid.
          Any other method include findBy... will set a lock if declared.

          You can set the transaction of getter, finder to "Supports" and setter/create to Mandatory/Required.
          If you use a Session without a transaction reads to the bean will not lock.

          It can be helful to log the TX
          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=59031

          <category name="org.jboss.tm">
           <priority value="TRACE" class="org.jboss.logging.XLevel"/>
          </category>