java - Log4j not being added to classpath in Ant -


i'm attempting add log4j project's classpath in ant creates executable jar, appears it's not being added properly.

here path component of ant build script:

<path id="classpath.compile">   <fileset dir="${dir.mylibs}">     <include name="**/*.jar"/>   </fileset>   <pathelement location="${dir.webcontent}/web-inf/lib/log4j.jar" /> </path> 

the compile target looks this:

<target name="-compile">   <javac destdir="${dir.binaries}" source="1.6" target="1.6" debug="true" includeantruntime="false">     <src path="${dir.source}"/>     <classpath refid="classpath.compile"/>   </javac> </target> 

tthe target creates jar:

<target name="-createjar" >   <jar jarfile="${path.jarfile}"      manifest="${dir.source}\meta-inf\manifest.mf">     <fileset dir="${dir.binaries}" casesensitive="yes">       <exclude name="**/*.java"/>     </fileset>   </jar> </target> 

lastly, manifest.mf:

manifest-version: 1.0 class-path: ../../../webcontent/web-inf/lib/log4j.jar (what pathing relative to?) main-class: foo.bar 

the jar created, when execute it, get:

exception in thread "main" java.lang.noclassdeffounderror: org/apache/log4j/logger...

any thoughts i'm doing wrong?

it looks classpath in manifest trying reference jar inside jar. 2 ways make work afaik 1) special classloader, @infosec812 mentions, or 2) exploding jar dependencies directly root of jar. either workable, don't see either of them happening in ant script.

if you're trying reference jar outside of jar, relative classpath relative location of jar executing. make sure referenced jar exists in location.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -