2 Replies Latest reply: Jan 8, 2011 9:57 AM by 654421 RSS

    Utility project jars

    654421
      In Eclipse, I've created a Java EE Utility project(SSUtility) and SSAppWeb web project and add them to the ear project reference. SSUtility, utility project, has also jars, including log4j-1.2.15.jar, commons-logging.jar etc. I exported the EAR project as .ear file. When I look into ear file I can see the SSUtility.jar and SSAppWeb.war are embedded and this is normal. I'm listing the files under SSUtility.jar :

      com/
      lib/
      META-INF/

      At runtime, a class(PropertyHandler.class) in the com package uses Logger class of log4j-1.2.15.jar package under lib. But it says it cannot find it. Error message is below :

      java.lang.NoClassDefFoundError: org/apache/log4j/Logger
           at com.logasis.ss.common.PropertyHandler.<init>(PropertyHandler.java:11)
           at com.logasis.ss.common.RuntimeService.<init>(RuntimeService.java:7)
           at jsp.index__jsp._jspService(header.jsp:10)
           at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
           at com.caucho.jsp.Page.pageservice(Page.java:578)
           at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:195)
           at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
           at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)
           at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)
           at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)
           at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)
           at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)
           at java.lang.Thread.run(Thread.java:595)

      How can I tell the ear package that the utility project has dependency to lib folder jars, so that ear could be exported with this dependency rule? I mean why cannot SSUtility.jar see its jar files under its lib folder?

      Thanks
      Serdar
        • 1. Re: Utility project jars
          gimbal2
          It seems you have nested jar files.

          That is not possible. Any dependencies either go in:

          - a /lib directory of your EAR (visible to the entire application including WARs and EJBs)
          - the WEB-INF/lib directory of a WAR (visible only to that web module)

          As far as I know jars put in a /lib directory of the EAR are automatically on the EAR classpath; at least this is true on JBoss. If not you need to add references to the libraries in the application.xml file.
          • 2. Re: Utility project jars
            654421
            Yes it was nested jars problem.

            I put the dependent nested jars into EAR's lib directory, and problem solved.
            I'm using Resin 3.1.9 application server, but the problem solved like you said for JBoss.

            Thank you