2 Replies Latest reply on Jan 11, 2016 4:34 AM by wdfink

    Best deployment structure of ear file in jboss 7 to avoid class cast exception

    bhimaraj

      Currently we are using Jboss5 and using single ear file with the deployment structure as follows

      company.ear |_ webapp1.war

                  |_ webapp2.war

                  |_ lib

                      |_ ejb1.jar

                      |_ ejb2.jar

                  |_ META-INF 

                      |_application.xml

                  |_ thirdparty1.jar

                  |_ thirdparty2.jar

      All ejb which are common to web application are kept in lib and thirdparty jars are kept in ear root path. This is working fine.

      Now, we are migrating the same to jboss-7.1.1. and we have tried with following deployment structures.

      1. company.ear

            |_ webapp1.war

            |_ webapp2.war

            |_ lib

            |    |_ thirdparty1.jar

            |    |_ thirdparty2.jar

            |_ META-INF

            |    |_application.xml

            |    |_jboss-deployment-structure.xml

            |_ ejb1.jar

            |_ ejb2.jar

       

      2. company.ear

            |_ webapp1.war

            |_ webapp2.war

            |_ lib '

            |    |_ ejb1.jar

            |    |_ ejb2.jar

            |_ META-INF

            |_application.xml

      |_jboss-deployment-structure.xml

      In the second deployment structure, we have defined thirdparty jars in modules folder and added global dependency in the stanalone.xml.

      Though we are following jboss7 migration document and some work-around, we are getting ClassCastExceptions during deployment. Is there any best ear deployment structure for jboss7? or how can we force jboss to load all ejb jars by a single class loader.

        • 1. Re: Best deployment structure of ear file in jboss 7 to avoid class cast exception
          jaysensharma

          Please provide the following details:

           

          1.  The *current structure* / Current approach which you are using of your EAR which is giving the ClassCastException.

          2.  The complete stackTrace of the exception which you are getting, sothat we can see which class is being referenced and which class is causing the ClassCastException.

          3. The exact place/name of the JAR which contains the class mentioned in the ClassCastException.   ANd where that jar is placed inside the EAR.

          4. If using module then list the JARs present inside the list.

           

          Regards

          Jay SenSharma

          • 2. Re: Best deployment structure of ear file in jboss 7 to avoid class cast exception
            wdfink

            The new AS7 or WildFly has a different policy for class loading. In my opinion more clear, but the migration might have issues.

            Most problem is if you have the setting "call by value" to false which is the default.

            In this case remote invocations will use call by reference, in that case you have often errors like "class A can not be cast to A". That means you create class A in webapp1 and call something in webapp2 which use a different classloader. (remember a class is identified by full name AND classloader).

             

            So if you cant find the reason please provide the information Jay asked for.