0

I am deploying an EAR with a utility jar, say A.jar located in the EAR's lib folder. My EAR's application.xml is:

<application ...>
<library-directory>lib</library-directory>

<module><ejb>cashflow-ejb.jar</ejb></module>

<module>
    <web>
    <web-uri>cashflow-war.war</web-uri>
    <context-root>cashflow</context-root>
    </web>
</module>
</application>

However, my WAR can't see the classes in the EAR's lib/A.jar and the deployment fails with a ClassNotFound exception. I went through these two similar posts: a and b, but none of the solutions offered there seemed to work. Basically I think I need the WAR's MANIFEST file to have a Class-Path: entry pointing to the EAR's lib. Can someone provide an ANT target for that? I've tried "../lib", as in:

<war
needxmlfile="false"
basedir="${webroot.dir}"
warfile="${build.dir}/${project.distname}.war">
<exclude name="WEB-INF/src/**"/>
<manifest>
    <attribute name="Class-Path" value="../lib"/>
</manifest>
</war> 

But it didn't seem to work and neither did "lib/A.jar", "../lib/A.jar" or "/lib" for the Class-Path value. The only solution that deploys in JBoss AS 7.1.1 is to copy A.jar both in the EAR's /lib location and in the WAR's WEB-INF/lib but then I have two copies of the same JAR in my EAR.

Community
  • 1
  • 1
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • 1
    Your WAR should be able to access all class files located inside JAR files placed in the EAR directory. Rather than play around with manifest files, I'd open a bug report with your JavaEE container provider and have them fix it or provide a workaround. Unless you didn't define your EAR as an EAR 5.0? – Isaac Oct 16 '12 at 06:13
  • My application.xml's tag specifies a version attribute of "5" and an xsi:schemaLocation attributes that points to an application_5.xsd file. My understanding is that that qualifies as a 5.0 EAR. – Marcus Junius Brutus Oct 16 '12 at 07:04
  • 1
    Ok. Then, there's either a bug in your JavaEE container, or another unrelated class loading problem. Try starting your container with the `-verbose:class` flag and see where things fail. – Isaac Oct 16 '12 at 18:18

0 Answers0