The javac
task in my compile
target fails despite the required jars being on the classpath. Could anyone help me figure out why this is happening?
The error below is caused because IOUtils.lineIterator()
is not recognized. However, commons-io-1.3.1.jar is on the build path (in ${app.lib.dir}
). So, it's strange that the build fails.
<target name="compile">
<mkdir dir="${classes.dir}" />
<javac destdir="${classes.dir}" debug="true" classpathref="dependency.path"
excludes="/../security/**" >
<src path="${java.src.dir}" />
</javac>
</target>
<path id="dependency.path">
<fileset dir="${spring.lib.dir}" includes="*.jar" />
<fileset dir="${spring.depends.dir}" includes="**/*.jar" />
<fileset dir="${app.lib.dir}" includes="*.jar" />
<fileset dir="${tomcat.dir}/.." includes="**/*.jar" />
</path>
ant -f build-dev.xml compile
Buildfile: C:\..\build-dev.xml compile:
[mkdir] Created dir: C:\..\classes
[javac] Compiling 348 source files to C:\..\classes
[javac] C:\..\UploadUtil.java:132: cannot find symbol
[javac] symbol : method lineIterator(java.io.InputStream,java.lang.String)
[javac] location: class org.apache.commons.io.IOUtils
[javac] Iterator<String> it = IOUtils.lineIterator(is, charSet);
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
BUILD FAILED
C:\..\build-dev.xml:54: Compile failed; see the compiler error output for details.
Total time: 11 seconds
IOUtils
because Eclipse shows it in the contents of the jar. The most likely explanation is that the jar containing the class is not on the classpath.
I double-checked Maven Central, just in case there was a jar called "commons-io-1.3.1" that does not contain this class, but sadly no:
So I'd suggest is that you add the following diagnostic target into your build so that you can confirm that the jar is in fact on the classpath:
<target name="diagnostics">
<pathconvert property="classpathProp" refid="dependency.path"/>
<echo>Classpath is ${classpathProp}</echo>
</target>