2 Replies Latest reply on Oct 27, 2003 11:45 AM by Joshua Davis

    ClassNotFoundException - Struts/Commons in WEB-INF/lib

    Joshua Davis Expert

      Hi,

      I'm deploying a .war file with Struts and the required Jakarta Commons jars for struts in the WEB-INF/lib directory. This works fine for the first deployment, but when I deploy again and the deployment scanner picks up the new .war file, I get a ClassNotFoundException referencing some of the 'bean utils' code in one of the commons jars. So, here's my question:

      What is the 'best practice' for adding third party libraries to an application:
      1) Add the libraries to the EAR file, as Java modules?
      2) Add the libraries to /lib?

        • 1. Re: ClassNotFoundException - Struts/Commons in WEB-INF/lib
          Jon Barnett Master

          It depends on many things. Struts has a particular problem in that it tends to get locked in memory - it is possible that objects are not released or otherwise expired so the JBoss undeployment process cannot eject the existing class. In this case, it is probably generally better to place the library in the lib directory (usually the instance lib rather than the common/bootstrap lib).

          In general, if you are using the library with many applications, you can save memory by sharing the library - you may have problems in certain instances where the library tries to read a configuration that you expect to be in your application context but because the library is shared, it does not do as expected.

          If your WAR/EAR may be deployed on an application server that doesn't have the library (for example deploying on many app servers besides JBoss), you may want to consider packing with the library - on the proviso you don't have the issue as per Struts. Also note that some app servers do have these types of resources already bundled with them as well.

          YMMV. My advice based on deployment experience is to have a flexible build process (Ant is good).

          • 2. Re: ClassNotFoundException - Struts/Commons in WEB-INF/lib
            Joshua Davis Expert

            Thanks for your reply, it's good to hear that this is actually a problem and that I was not imagining the whole thing. :)

            I am using ANT, and I already have some targets that set up JBoss configuration directories properly (i.e. <jboss_home>/server/). I modified these to detect struts/commons and place the jars in <jboss_home>/server//lib, which works fine. You are correct in that I will need to make some equivalent change in order to deploy on a different app server.