6 Replies Latest reply on Jun 9, 2011 12:45 AM by paresh2011

    How can I set classloader in JBOSS

    paresh2011

      Hi,

       

      I am using jboss-6.0.0.Final with J2EE web app. I am getting CalssCastException due to different classloader.

       

      For few object it's loading object by : BaseClassLoader@6981170d{vfs:///C:/ABB/jboss-6.0.0.Final/server/TMS/deploy/ams-ear-1.0.ear/TMS-1.0.war/}

      and after that :  sun.misc.Launcher$AppClassLoader@5acac268

       

      and at this stage system throws CalssCastException.

       

      I have set BaseClassLoader explicitly but it doesn't work. Is there any way I can set BaseClassLoader for all.

       

       

      I would appreciate if anybody can point out how can short it out.

       

       

       

      Thanks

      Paresh

        • 1. Re: How can I set classloader in JBOSS
          jaikiran

          paresh modi wrote:

           

           

          I have set BaseClassLoader explicitly but it doesn't work. Is there any way I can set BaseClassLoader for all.

           

           

          You shouldn't. Please post the entire exception stacktrace (without setting any classloader in your code). Also please read these wiki articles:

           

          http://community.jboss.org/wiki/JBossClassLoadingUseCases

          http://community.jboss.org/wiki/classloadingconfiguration

          • 2. Re: How can I set classloader in JBOSS
            paresh2011

            Hi,

             

            Thanks for the reply. Please find attached .txt file contains full stack trace of ClassCastException, please note that here IFCLINE class extends IFCCURVE so it should be cast to upper level and for few object it's successful as well, you can see this in log file as well in which I have logged class loader for both the class for each turn. I have not set any class loader explicitly. Below is my deployment artifacts.

             

            1. tms-ear-1.0.ear
              1. TMS-1.0.war
                1. jsp
                2. META-INF
                  1. MANIFEST.MF
                3. WEB-INF
                  1. Classes
                    1. com
                    2. applicationContext.xml
                  2. lib
                    1. jtds-1.2.2.jar
                  3. server-config.wsdd
                  4. web.xml
              2. META-INF
                1. MANIFEST.MF
                2. application.xml

             

            All the classes are in TMS-1.0.war\WEB-INF\classes\com location only.

             

            Waiting for your expert advice.

             

            Thanks

            Paresh.

            • 3. Re: How can I set classloader in JBOSS
              alesj

              My guess is you're bundling something that you shouldn't; e.g. some Java(EE) classes -- check jtds jar?

              .war CL - as child-first lookup - tries to load them, where something else loads those classes from boot classpath.

              • 4. Re: How can I set classloader in JBOSS
                paresh2011

                Hi,

                 

                Thanks for the reply. I have resolved mentioned issue but still have question and want some advice as well. As I have explained earlier below are my deployment artifacts of EAR.


                = > tms-ear-1.0.ear
                == > TMS-1.0.war
                === > jsp
                === > META-INF
                ==== > MANIFEST.MF
                === > WEB-INF
                ==== > Classes
                ===== > com
                ==== > lib
                ===== > jtds-1.2.2.jar
                = > META-INF
                == > MANIFEST.MF
                == > application.xml
                = > solr-1.war
                = > tms-solr-1.0.jar


                Here I have removed all the classes from TMS-1.0.war/tms-ear-1.0.ear/WEB-INF/classes/, create a jar file tms-com.jar and placed it to TMS-1.0.war/ location and that’s how my issue gets resolved.

                 

                Previously the issue was occurred due to some classes are loaded from the server/TMS/lib location from myappscommon.jar file and others are loaded from the TMS-1.0.war/tms-ear-1.0.ear/WEB-INF/classes location.

                 

                I have resolved this issue but the deployment structure has been changed as I have explained, So I want your suggestion to manage this artifact properly in a standard way.

                 

                Thanks
                Paresh

                • 5. Re: How can I set classloader in JBOSS
                  alesj

                  TMS-1.0.war/tms-com.jar? --> this does nothing, it's not a classpath entry

                  • 6. Re: How can I set classloader in JBOSS
                    paresh2011

                    Hi,

                     

                    Sorry I forgot to mention class path entry here, actually I have added class path entry in tms-ear-1.0.ear/META-INF/MANIFEST.MF file for tms-com.jar.

                     

                    I want to know that is it ok if I place all the classes in .jar file at  tms-ear-1.0.ear location ? Or any other suggestion you can provide... will be helpful a lot.

                     

                     

                     

                    Thanks

                    Paresh