4 Replies Latest reply on Oct 29, 2003 9:23 AM by dkl01

    Location of libraries

    dkl01

      Hi,

      Under what circumstances we place libraries (such as jars) under jboss\lib\ext ? Will it be a problem if we deploy jars along with ear file as well as keep in jboss\lib\ext which is common place to all apps ?

      I really appreciate any suggestions. Thanks

        • 1. Re: Location of libraries
          mikefinn

          Do you mean jboss/lib? I am not familiar w/ lib/ext. If you put JARs in both, make sure you use a scoped classloader in your EAR. Otherwise, I have seen the classloader complain with ClassNotFoundExceptions, when it actually finds more than one class. The only thing we put in lib are JARs that are *very* static over time, such as 'extra' 3rd party libs that all apps use (jakarta-commons, JDBC driver JARs, etc), and we don't generally package those in the EAR.

          Mike

          • 2. Re: Location of libraries
            dkl01

            Mike, Thanks for the quick response. If I delete xercesImpl.jar, xml-apis.jar, xmlParserAPIs.jar,
            and struts.jar from jboss\lib and deploy these files with my ear file the application
            works fine. But I keep these files in jboss\lib and exclude in ear file the JBOSS
            is giving following message.

            This class file exists under jboss\tmp\deploy\Default\myapption.ear\web1002\WEB-INF\
            classes\com\test\myapption.formbean. I'm not sure why I'm getting class not found
            error.

            [13:41:48,430,STDOUT] JBoss-2.4.9 Started in 0m:49s.401
            [13:42:31,913,Engine] action: Processing a POST for /Login
            [13:42:31,953,Engine] action: Setting locale 'en_US'
            [13:42:31,963,Engine] action: Looking for ActionForm bean under attribute 'loginForm'
            [13:42:31,963,Engine] action: Creating new ActionForm instance of class 'com.test.myapption.formbean.LoginForm'
            [13:42:31,973,Engine] action: Error creating ActionForm instance of class 'com.test.myapption.formbean.LoginForm'
            java.lang.ClassNotFoundException: com.test.myapption.formbean.LoginForm
            java.lang.Class javax.management.loading.MLet.findClass(java.lang.String)
            MLet.java:800
            java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean)
            ClassLoader.java:299
            java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)
            ClassLoader.java:255
            java.lang.Class java.lang.ClassLoader.loadClassInternal(java.lang.String)
            ClassLoader.java:315
            java.lang.Class java.lang.Class.forName0(java.lang.String, boolean, java.lang.ClassLoader)
            native code
            java.lang.Class java.lang.Class.forName(java.lang.String)
            Class.java:120

            • 3. Re: Location of libraries
              mikefinn

              Yes - I think this is something unique to Struts and the way it loads classes. I think the Struts action form class (the parent of your form) is found in multiple places, when the struts jar is in lib and in the EAR. If you need it in both places, use a scoped classloader in your EAR (jboss-app.xml), so you get no conflict.

              Mike

              • 4. Re: Location of libraries
                dkl01

                Mike,

                Actually the problem is I don't want to include these jars in my ear file because these are common to all applications and should be in jboss\lib. If I do this my app is my *not* working. I tried having d:\jboss\jboss\lib\struts.jar in CLASSPATH. Didn't help either.

                App works fine if I keep all my application classes including action classes in jboss\lib also. I know this is very bad idea to keep classes in multiple places. As you mentioned this could be scoping issue.
                Here is the package and import statements from my formbean.

                package com.test.myapption.formbean;
                import org.apache.struts.action.ActionForm;
                import org.apache.struts.action.ActionErrors;
                import org.apache.struts.action.ActionError;
                import org.apache.struts.action.ActionMapping;
                import javax.servlet.http.HttpServletRequest;

                I don't have to use scoped classloader if I'm not having jars in ear as well as in jboss\lib, isn't it ? Could you please send me the syntax of scoped classloader in EAR for future reference.

                Thanks