2 Replies Latest reply on Jan 30, 2013 5:00 AM by Juergen Weber

    Class sharing between rar and ear

    Juergen Weber Newbie

      I want to port an app to JBoss 7 where an ejb in an ear accesses a resource adapter in a rar.

      I get a ClassCastException because ear and rar have different classloaders.

      How would one solve this? In JBoss 4 I had put the common classes into server/lib.

       

      Put the rar into the ear and make the ejb use the classes from the rar? How?

       

      Extract the common classes into a shared module? Not nice.

       

      I tried <global-modules> but this did not work.

      And yes, I read "Class Loading in AS7" ;-)

       

      Thanks, Juergen

        • 1. Re: Class sharing between rar and ear
          Frank Langelage Master

          This is probably one of the most frequently asked questions.

          Seems ypu overlooked something while reading the classloading topic.

           

          Different ways available, like jboss-deploymentstructure.xml.

           

          The easiest way for me was to add a manifest entry to the ear file:

          <attribute name="Dependencies" value="deployment.controller.rar, deployment.filesystem.rar"/>

          With this, the ear file can use classes from the deployments named controller.rar and filesystem.rar.

          Only those rar-files contain the shared class files, the ear file does not.

          1 of 1 people found this helpful
          • 2. Re: Class sharing between rar and ear
            Juergen Weber Newbie

            Thanks, I got it to work with my.ear/META-INF/jboss-deployment-structure.xml

             

            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">

                <deployment>

                    <dependencies>

                        <module name="deployment.my.rar" export="true"/>

                    </dependencies>

                    </deployment>

            </jboss-deployment-structure>

             

            export="true" is important, else there are NoClassDefFoundError for the RA classes, I guess the ear classes don't see javax.resource.*