5 Replies Latest reply on Mar 10, 2003 6:06 PM by Joel Vogt

    jboss classloader tutorial?

    Yuri Magrisso Newbie

      Hi everybody,

      I am new to JBoss and Struts. I decided to try them out by doing a simple app with ModelJ.
      When I tried to deploy the ear file I got errors that some classes which were present in the WEB-INF/lib folder are not visible to the classloader.
      When I put the classes to the default/lib folder the errors disappear.
      When I tried to use the app, I got an error that the classloader cannot find my business logic classes present in the WEB-INF/classes directory.
      When I packaged them as a jar file and put them in the default/lib folder the problem disappeared.

      How should I configure JBoss or how should I package the ear file so that the classloader finds everything without me copying libraries to default/lib or somewhere else?
      Is there a tutorial about it?

      Thanx alot!

        • 1. Re: jboss classloader tutorial?
          Yuri Magrisso Newbie

          I forgot to say that I am using JBoss 3.2_RC2 with Tomcat and ModelJ 0.67

          • 2. Re: jboss classloader tutorial?
            Yuri Magrisso Newbie

            This is kinda strange - it gives that the classloader cannot find a class (org.apache.struts.action.ActionFormBean) that is in the same package/jar as class that has already executed code (org.apache.struts.action.ActionServlet) - check this error:

            01:14:44,062 ERROR [Digester] Begin event threw exception
            java.lang.ClassNotFoundException: No ClassLoaders found for: org.apache.struts.action.ActionFormBean

            at org.jboss.mx.loading.LoadMgr.beginLoadTask(LoadMgr.java:155)
            at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:161)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
            at org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:252)
            at org.apache.commons.digester.Digester.startElement(Digester.java:1237)
            at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:434)
            at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParse
            r.java:216)
            at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(XMLNamespaceBinder.java:829)

            at org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:590)
            at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:817)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmen
            tScannerImpl.java:748)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(
            XMLDocumentFragmentScannerImpl.java:1454)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentSca
            nnerImpl.java:333)
            at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.j
            ava:529)
            at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.j
            ava:585)
            at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
            at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
            at org.apache.commons.digester.Digester.parse(Digester.java:1514)
            at org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1354)
            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:471)
            at org.apache.struts.tiles.ActionComponentServlet.init(ActionComponentServlet.java:52)
            at javax.servlet.GenericServlet.init(GenericServlet.java:256)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:934)
            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821)
            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3420)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
            at org.jboss.web.catalina.EmbeddedCatalinaService41.createWebContext(EmbeddedCatalinaService
            41.java:431)
            at org.jboss.web.catalina.EmbeddedCatalinaService41.performDeploy(EmbeddedCatalinaService41.
            java:306)
            at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:304)
            at org.jboss.deployment.MainDeployer.start(MainDeployer.java:827)
            at org.jboss.deployment.MainDeployer.start(MainDeployer.java:819)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:639)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:612)
            at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
            )
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
            at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
            at $Proxy7.deploy(Unknown Source)
            at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:404)
            at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:545)
            at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeplo
            ymentScanner.java:195)
            at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploym
            entScanner.java:206)
            at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeployme
            ntScanner.java:185)

            the error disappears when I put the jar file in default/deploy or default/lib.
            At the same time it doesn't have a problem to find org.apache.commons.digester.Digester the jar of which is not present in default/deploy or default/lib (may be Digester is included with jboss otherwise?)

            • 3. Re: jboss classloader tutorial?
              Joel Vogt Master

              Normally it is best to not have anything going into default/lib.

              You should have struts.jar in your war's WEB-INF/lib. Your action classes and forms should be in WEB-INF/classes.
              If these actions need classes elsewhere in your ear (for example a jar with ejb's) then define a manifest.mf and specify the classpath for the war file.

              Make sure none of the struts classes are set on your environment classpath too to avoid conflicts

              • 4. Re: jboss classloader tutorial?
                Yuri Magrisso Newbie

                Thanx for the reply!

                If I put my action and form classes in WEB-INF/classes the classloader cannot find them. If I put them in default/deploy it works. I don't know why. I'll play around to see what's wrong. Might be a problem with Tomcat

                • 5. Re: jboss classloader tutorial?
                  Joel Vogt Master

                  hmm, could be a few things wrong here. I would be checking the war file in particular the case of WEB-INF. Also make sure that your action classes do not appear in any other jar or location in your ear. The conflict would stop them being picked up and used correctly