9 Replies Latest reply on Nov 10, 2016 1:57 AM by Mohamed Azoor

    Static variable in servlet gets shared between 2 application

    sada abc Newbie

      Hi,

      I have two turbine appliactions deployed in JBoss default profile. Actually turbine jar is packaged seperately in 2 ears but still static variables in turbine servlet are getting shared between 2 applications.

      I have added jboss-app.xml in meta-inf of both ear files e.g.
      <jboss-app>
      <loader-repository>
      test:loader=test.ear
      <loader-repository-config>
      java2ParentDelegation=false
      </loader-repository-config>
      </loader-repository>
      </jboss-app>

      After adding above, applications are not getting deployed. It throws exception like,
      java.lang.NoClassDefFoundError: java/lang/Object
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)

      I am not getting why this is not working?
      Can anybody gives solution?

      If I add above jboss-app.xml for test applications having only servlet(common to both) then it works fine (static var is not getting shared). But it doesn't work for my turbine application where there are too many jars ejbs etc.

      Please give suggestions if anybody has.

      Thanks in advance.

        • 1. Re: Static variable in servlet gets shared between 2 applica
          jaikiran pai Master

           

          After adding above, applications are not getting deployed. It throws exception like,
          java.lang.NoClassDefFoundError: java/lang/Object


          NoClassDefFoundError for java.lang.Object?

          If I add above jboss-app.xml for test applications having only servlet(common to both) then it works fine (static var is not getting shared). But it doesn't work for my turbine application where there are too many jars ejbs etc.


          What are the list of jars contained in this turbine application? Are you by any chance including jar(s) containing java.lang.* classes? Post the list of jars in that application.

          While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.



          • 2. Re: Static variable in servlet gets shared between 2 applica
            Ales Justin Master

            This is what Seam uses in its DVD example app and it definitely works - as Seam is required to be scoped if you want to run more than one Seam instance.

            <!DOCTYPE jboss-app
             PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
             "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
            <jboss-app>
             <loader-repository>
             seam.jboss.org:loader=seam-dvd
             </loader-repository>
            </jboss-app>
            



            • 3. Re: Static variable in servlet gets shared between 2 applica
              sada abc Newbie

              I tried this one also but still it is not working.

              List of dependency jar is
              turbine.jar
              velocity.jar
              commons-logging.jar
              commons-fileupload.jar etc.
              There is no single jar which contains java.lang.* classes.

              If I remove jboss-app.xml from meta-inf then it doen't give java.lang.NoClassDefFoundError: java/lang/Object
              but static variable of turbine servlet gets shared between 2 applications.

              Please suggest if anybody has any solution.

              Thanks in advance

              • 4. Re: Static variable in servlet gets shared between 2 applica
                jaikiran pai Master

                Which exact version of JBoss AS 5 do you use?

                • 5. Re: Static variable in servlet gets shared between 2 applica
                  jaikiran pai Master

                  And please post the entire exception stacktrace and the logs that you see on the console (not the server.log)



                  While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.

                  • 6. Re: Static variable in servlet gets shared between 2 applica
                    sada abc Newbie

                    I am using JBoss 4.0.4GA not JBoss5

                    Thanks,

                    • 7. Re: Static variable in servlet gets shared between 2 applica
                      jaikiran pai Master

                       

                      "sada1977" wrote:
                      I am using JBoss 4.0.4GA not JBoss5

                      Thanks,


                      Then, this is a wrong forum for this question :) This forum is for JBoss AS5 questions. Please create a new thread in the Installation & Deployment forum here http://www.jboss.org/index.html?module=bb&op=viewforum&f=61 and provide the details that we asked for.


                      • 8. Re: Static variable in servlet gets shared between 2 applica
                        sada abc Newbie

                        Stacktrace is like this,

                        java.lang.NoClassDefFoundError: java/lang/Object
                        at java.lang.ClassLoader.defineClass1(Native Method)
                        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
                        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
                        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
                        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
                        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                        at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:672)
                        at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:652)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:190)
                        at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
                        at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:517)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                        at java.lang.ClassLoader.defineClass1(Native Method)
                        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
                        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
                        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
                        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
                        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                        at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:672)
                        at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:652)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:190)
                        at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
                        at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:517)
                        at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                        at java.lang.ClassLoader.defineClass1(Native Method)
                        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
                        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

                        • 9. Re: Static variable in servlet gets shared between 2 application
                          Mohamed Azoor Newbie

                          set true of following in ear-deployer.xml in deployment folder

                           

                          <attribute name="Isolated">true</attribute>

                          <attribute name="CallByValue">true</attribute>

                           

                          it should resolve your problem.