5 Replies Latest reply on Aug 6, 2010 5:10 AM by jaikiran pai

    Difficulty loading jars from lib under EAR in JBOSS 5.1

    Sharma Kuchi Newbie

      Hi,

       

      I am newbie to Jboss and need some help. sorry if this question has been posted else where or if its really simple.

       

      I have an application that I am trying to deploy in Jboss 5.1.0 and keep getting java.lang.ClassNotFoundExceptions.

      The required jars are all present in the lib directory of the EAR and I want Jboss classloader to look into that location rather than lib under WEB-INF. On doing some research, I found that setting EnablelibDirectoryByDefault" to true will resolve it. but where should I be setting that property in JBOSS 5.1

      I tried to put that property in ear-deployer-jboss-beans.xml (as I could not find ear-deploy.xml) and  the value to true. But server is throwing errors during startup as the xml does not have "org.jboss.deployment.EARDeployer" service. Is that the right place/way to put the property.

       

      Is there any other configuration I need to set up for the server to identify the jars under lib folder of the EAR.

       

      Currently the structure is:

       

      Ear:

      |

      |

      -------lib

              |-------jar1

              |-------jar2

      |

      --------META-INF

                     |

                      -----application.xml

       

       

      please let me know if you need any other information.
      Any help is greatly appreciated.

        • 1. Re: Difficulty loading jars from lib under EAR in JBOSS 5.1
          jaikiran pai Master

          Sharma Kuchi wrote:

           

          On doing some research, I found that setting EnablelibDirectoryByDefault" to true will resolve it. but where should I be setting that property in JBOSS 5.1

          I tried to put that property in ear-deployer-jboss-beans.xml (as I could not find ear-deploy.xml) and  the value to true. But server is throwing errors during startup as the xml does not have "org.jboss.deployment.EARDeployer" service. Is that the right place/way to put the property.

           

          You shouldn't be doing that. I haven't heard of that property before (and I didn't bother trying to search for its details). By default without any changes, the jars within the .ear/lib folder of the application should be available in the classpath of the entire ear.

           

           

           

           

          Sharma Kuchi wrote:

           

          Hi,

           

          I am newbie to Jboss and need some help. sorry if this question has been posted else where or if its really simple.

           

          I have an application that I am trying to deploy in Jboss 5.1.0 and keep getting java.lang.ClassNotFoundExceptions.

          Please post the entire exception stacktrace and bit more detail about when the exception occurs.

          • 2. Re: Difficulty loading jars from lib under EAR in JBOSS 5.1
            jaikiran pai Master

            Also post the contents of your application.xml file.

            • 3. Re: Difficulty loading jars from lib under EAR in JBOSS 5.1
              Sharma Kuchi Newbie

              Hi Jaikiran,

               

              Firstly, I really apologize for the late reply. Caught up with other things.Thanks much for replying.

               

              After your reply I revisited the approach of deploying the EAR with library files included and found the cause. When I right lick on the war project, make it run on server, Eclipse builds the EAR and moved it to deploy folder of JBoss and that EAR didnt have my library files in it and thus application was faiing to start.

              But when I use an ANT script to build the EAR manually including libraries in it and copy the EAR to deploy folder and start the server, there were no problems and application ran smoothly.

               

              The question I have is why does Eclipse not recognise the libraries inside my lib folders while building automatically.Or how can I make Eclipse build the EAR in the way I wanted.( as I have jars inside EAR/lib/folder1/jar1 )

               

              I think I am missing some simple configuration. Any help is greatly appeciated.

               

              thanks again Jai

               

               

              P.S: I found the "Enablelibdirectorybydefault" attribute from the following link:

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

              • 4. Re: Difficulty loading jars from lib under EAR in JBOSS 5.1
                Sharma Kuchi Newbie

                Also Jay, below is the application.xml and also the structure of the EAR

                 

                <?xml version="1.0" encoding="ASCII"?>
                <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
                  <display-name>app_ear</display-name>
                  <module>
                    <web>
                      <web-uri>app1.war</web-uri>
                      <context-root>app1.war</context-root>
                    </web>
                  </module>
                <library-directory>lib</library-directory>
                </application>

                 

                |

                • 5. Re: Difficulty loading jars from lib under EAR in JBOSS 5.1
                  jaikiran pai Master

                  Sharma Kuchi wrote:

                   

                  After your reply I revisited the approach of deploying the EAR with library files included and found the cause. When I right lick on the war project, make it run on server, Eclipse builds the EAR and moved it to deploy folder of JBoss and that EAR didnt have my library files in it and thus application was faiing to start.

                  But when I use an ANT script to build the EAR manually including libraries in it and copy the EAR to deploy folder and start the server, there were no problems and application ran smoothly.

                   

                  The question I have is why does Eclipse not recognise the libraries inside my lib folders while building automatically.Or how can I make Eclipse build the EAR in the way I wanted.( as I have jars inside EAR/lib/folder1/jar1 )

                   

                  I don't use Eclipse (or any other IDE) for anything more than editing files. I rely on build scripts/tools to package/deploy the applications. Maybe someone with better experience with IDEs will answer your question.

                   

                  Sharma Kuchi wrote:

                   

                  P.S: I found the "Enablelibdirectorybydefault" attribute from the following link:

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

                    You won't have to do that for AS-5 (as you already noticed).