4 Replies Latest reply on Mar 18, 2009 8:13 AM by aroeder

    ClassNotFoundException: EAR file containing multiple WAR fil

    aroeder

      We deployed an EAR file on JBoss 4.2.3 which contains multiple WAR files.

      e.g.:

      EAR
      |---WAR1
      |---WAR2
      |---WAR3

      Our problem is: When a class inside WAR3 tries to create an instance of a class included in WAR1 we keep getting a ClassNotFoundException. The same EAR file works without any problems under JBoss 4.0.5.

      What do we miss here?


        • 1. Re: ClassNotFoundException: EAR file containing multiple WAR
          jaikiran

          Each WAR has its own isolated classloader (by default). So classes in WAR1 are not visible in WAR2. If you want the classes to be visible to all WARs in that EAR then create an jar containing those classes and place that jar in the EAR/lib folder.

          • 2. Re: ClassNotFoundException: EAR file containing multiple WAR
            aroeder

            Thanx a lot! We thought so already. But we hoped to find a more simple solution than changing our whole application for that.

            But anyway now we know which way we have to go.

            Thanx again!

            • 3. Re: ClassNotFoundException: EAR file containing multiple WAR
              jaikiran

               

              "aroeder" wrote:
              But we hoped to find a more simple solution than changing our whole application for that.



              Option#2 (which is really a workaround if fixing the application packaging is not feasible): The jboss-service.xml file under %JBOSS_HOME%/server/< serverName>/deploy/jboss-web.deployer/META-INF contains this:
               <!-- A flag indicating if the JBoss Loader should be used. This loader
               uses a unified class loader as the class loader rather than the tomcat
               specific class loader.
               The default is false to ensure that wars have isolated class loading
               for duplicate jars and jsp files.
               -->
               <attribute name="UseJBossWebLoader">false</attribute>
              


              You can change it to true.


              • 4. Re: ClassNotFoundException: EAR file containing multiple WAR
                aroeder

                Thanx again! That works too, so we can use it as workaround till we changed the packaging of our applications.