« WebLogic on Linux | Main | Site Update »

From WebLogic to JBoss

I used the WebLogic Converter tool to convert a WebLogic 8.1 EJB application to JBoss 3.2.3, realizing full well that the only supported version of WebLogic is 6.1. However, with the exception of one problem, I found the tool easy to use and helpful. Below is a description of what I did, what went wrong, and how it was fixed. Obviously, YMMV.

I downloaded and installed the .sar file (clicking on the link "Download JBoss 3.2 SAR, Service Archive for 3.2, drop in deploy.") I then simply renamed my existing EJB jar file (foo.jar) to foo.wlar and dropped it the deploy directory. JBoss converted this to foo.jar and I was able to extract the jboss.xml and jbosscmp-jdbc.xml files that I needed.

I didn't run into any problems with the jboss.xml file, but I did have one problem with the jbosscmp-jdbc.xml version of the weblogic-cmp-rdms-jar.xml file. Of course, this may have been a problem with the weblogic-cmp-rdms-jar.xml (I inherited that file, I didn't create it - if I had created it, I would be SURE that that was the problem).

The relevant snippet of weblogic-cmp-rdms-jar.xml:

   <weblogic-rdbms-relation>
        <relation-name>conv-availActs</relation-name>
        <weblogic-relationship-role>
            <relationship-role-name>
                AvailActRelationshipRole
            </relationship-role-name>
            <column-map>
                <foreign-key-column>convId</foreign-key-column>
                <key-column>convId</key-column>
            </column-map>
        </weblogic-relationship-role>
    </weblogic-rdbms-relation>
 
Gets translated to the following in jbosscmp-jdbc.xml:
<ejb-relation>
  <ejb-relation-name>conv-availActs</ejb-relation-name>
  <foreign-key-mapping/>
  <ejb-relationship-role>
    <ejb-relationship-role-name>
      ConvRelationshipRole
    </ejb-relationship-role-name>
    <key-fields/>
  </ejb-relationship-role>
  <ejb-relationship-role>
    <ejb-relationship-role-name>
      AvailActRelationshipRole
    </ejb-relationship-role-name>
    <key-fields>
      <key-field>
        <field-name>convId</field-name>
        <column-name>convId</column-name>
      </key-field>
    </key-fields>
  </ejb-relationship-role>
</ejb-relation>
And, given the original WebLogic information, that is a pretty reasonable conversion. However, in my case it generated errors of the form:
[ObjectName: jboss.j2ee:jndiName=Action,service=EJB state At least one role of a foreign-key mapped relationship must have key fields (or is missing from ejb-jar.xml) ejb-relation-name=conv-availActs

The problem was that the key fields were placed in the wrong ejb-relationship-role-name. When I changed the XML to what is shown below, then everything was fine.

<ejb-relation>
  <ejb-relation-name>conv-availActs</ejb-relation-name>
  <foreign-key-mapping/>
  <ejb-relationship-role>
    <ejb-relationship-role-name>
     ConvRelationshipRole
    </ejb-relationship-role-name>
    <key-fields>
      <key-field>
        <field-name>convId</field-name>
        <column-name>convId</column-name>
      </key-field>
    </key-fields>
  </ejb-relationship-role>
  <ejb-relationship-role>
    <ejb-relationship-role-name>
      AvailActRelationshipRole
    </ejb-relationship-role-name>
    <key-fields/>
  </ejb-relationship-role>
</ejb-relation>

Note: in my situation, there is a 1 to many relationship between Conv and AvailableActs (1 Conv has Many AvailableActs) - and the keys must go on the role that is referring to the "1" not to the role referring to the "many".

There is a good writeup on devx that was particularly helpful in resolving this issue.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)