4 Replies Latest reply on Aug 13, 2002 4:14 AM by tbfmicke

    WEB-INF/lib files in war not in classpath

    n_ton

      I've seen a few posts about this problem, but no solution.

      I have an ear that contains a war. In the war, I have some supporting jars in the WEB-INF/lib directory. When I deploy the ear, I get NoClassDefFoundError's for a class in one of the supporting jars. I would assume that would mean that the classpath didn't pick up the supporting jars in the WEB-INF/lib directory.

      When I deploy the war itself, I get a ClassNotFoundException for one of the servlets in my web.xml. The servlet in question is also in a jar in the WEB-INF/lib directory of the war. Again, I would guess this is because the classpath didn't pick up the jars in the WEB-INF/lib directory.

      I'm running JBoss 3.0.1 under the default configuration on Linux.

      As I mentioned above, I've seen multitudes of posts with the same problem dating back to early this year. I'm surprised it hasn't been fixed yet. Is this really a bug? If not, where should I be putting these jars?

      Thanx.

      Norton

        • 1. Re: WEB-INF/lib files in war not in classpath
          crobert



          Hmm... you can try putting the servlet class in WEB-INF/classes. This works for me. However, I don't have any jars in WEB-INF/lib. Of course, the workaround is to put all the "dearchived" classes in the jars from WEB-INF/lib into WEB-INF/classes. By no means an elegant solution, but at least it works ;)

          Robert

          • 2. Re: WEB-INF/lib files in war not in classpath
            joelvogt

            This really should just work. Perhaps you could post your ear structure (pointing out config files) so we can see what is going on?

            • 3. Re: WEB-INF/lib files in war not in classpath
              n_ton

              While putting this reply together, I discovered the problem
              where the servlet wasn't found when I deployed the war.
              It turned out to be a spelling error in my web.xml. I
              hate it when that happens.

              However, I haven't been able to fix the ear deployment.


              Here's my ear:

              n_ton> jar -tf lib/myapp.ear
              META-INF/
              META-INF/MANIFEST.MF
              META-INF/application.xml
              myapp.war
              myapp.jar

              The application.xml looks like this:

              <?xml version="1.0" encoding="ISO-8859-1"?>


              <display-name>MyApp</display-name>


              <web-uri>myapp.war</web-uri>
              <context-root>/myapp</context-root>



              myapp.jar




              Here's my war:

              n_ton> jar -tf myapp.war
              META-INF/
              META-INF/MANIFEST.MF
              WEB-INF/
              WEB-INF/lib/
              WEB-INF/lib/jdom.jar
              WEB-INF/lib/myapp.jar
              WEB-INF/web.xml
              translateTest.jsp


              When deploying the ear, first I get:


              11:04:48,674 ERROR [EJBDeployer] Verfiy failed
              java.lang.NoClassDefFoundError: org/jdom/Element
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getMethods(Class.java:742)
              at org.jboss.verifier.strategy.AbstractVerifier.hasEJBCreateMethod(Abstr
              actVerifier.java:638)
              at org.jboss.verifier.strategy.EJBVerifier11.verifyEntityBean(EJBVerifie
              r11.java:1175)
              at org.jboss.verifier.strategy.EJBVerifier11.checkEntity(EJBVerifier11.j
              ava:124)
              at org.jboss.verifier.BeanVerifier.verify(BeanVerifier.java:129)
              at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:343)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:749)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:741)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:615)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:580)
              at java.lang.reflect.Method.invoke(Native Method)
              at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
              nDispatcher.java:284)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
              at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
              at $Proxy4.deploy(Unknown Source)
              at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
              tScanner.java:427)
              at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
              canner.java:553)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
              loop(AbstractDeploymentScanner.java:202)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
              run(AbstractDeploymentScanner.java:191)


              JBoss then deploys my EJBs successfully and then I get (this is only part of
              the stack trace. Let me know if you need to see more):

              16:33:01,278 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment
              .scanner.URLDeploymentScanner$DeployedURL@a00e4c88{ url=file:/usr/local/jboss-3.
              0.1/server/default/deploy/myapp.ear, deployedLastModified=1029014116000 }
              org.jboss.deployment.DeploymentException: Could not create deployment: file:/usr
              /local/jboss-3.0.1/server/default/tmp/deploy/server/default/deploy/myapp.ear/75.
              myapp.ear-contents/myapp.jar; - nested throwable: (java.lang.NoClassDefFoundErro
              r: org/jdom/Element)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:766)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:741)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:615)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:580)
              at java.lang.reflect.Method.invoke(Native Method)
              at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
              nDispatcher.java:284)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
              at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
              at $Proxy4.deploy(Unknown Source)
              at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
              tScanner.java:427)
              at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
              canner.java:553)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
              loop(AbstractDeploymentScanner.java:202)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
              run(AbstractDeploymentScanner.java:191)
              + nested throwable:
              java.lang.NoClassDefFoundError: org/jdom/Element
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getMethods(Class.java:742)
              at org.jboss.ejb.StatelessSessionContainer.setupBeanMapping(StatelessSes
              sionContainer.java:518)
              at org.jboss.ejb.StatelessSessionContainer.create(StatelessSessionContai
              ner.java:162)
              at org.jboss.ejb.Container.invoke(Container.java:751)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
              ler.java:967)


              The class org.jdom.Element is available in jdom.jar in my war.

              Your help is appreciated.

              Norton

              • 4. Re: WEB-INF/lib files in war not in classpath
                tbfmicke

                Classes inside the war is only reachable from inside the war. You are trying to use the jdom lib from an ejb outside the war.

                You can either put the jdom.jar to be accessible "globally" in your server by putting it in .../server/default/lib (or whatever configuration you use).

                If you want to have it inside the application, put jdom.jar directly in the .ear file and use the Class-Path: entry in the manifest files for the war and ejb to access it.

                Regards