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 :
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 :
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?
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.
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.