My java application uses log4j for logging. Using ant the project builds successfully, but I am unable to run it. The error I get is
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/Log
.........
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
My classpath contains the log4j jar.
[echo] ..../apache-log4j-1.2.15/log4j-1.2.15.jar: .....
My ant version is 1.7.1. What am I missing?
[Edit] My application is referencing another project which required the commons logging jar. So I tried creating an executable jar of the referenced project so that all the dependencies are carried over. The ant task to create the executable jar is as follows:
<target name="executablejar" depends="compile">
<delete file="${dist}/app.jar" />
<javac debug="true" srcdir="${src}" destdir="${classes}" classpath="${javac.classpath}"/>
<copy todir="classes" flatten="true">
<path>
<pathelement path="${javac.classpath}"/>
</path>
</copy>
<jar jarfile="${dist}/app.jar" basedir="${classes}" />
</target>
However the error still persists. Am I creating the executable jar correctly?