I am currently using Eclipse Indigo and have two Dynamic Web Projects: Project A and Project B.
Project A has Project B as a required project on the build path and also has it ticked on Properties -> Java Build Path -> Order and Export
.
I then have a method in Project A, which calls a method in Project B that has the line:
FileUtils.writeStringToFile(file, data);
This line throws the following Exception:
java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at my.package.projectB.Class.createAndWriteToFile(FileUtil.java:62)
at my.package.projectA.Class.saveCurrentDialog(UIResponseStrategy.java:99)
...
Project B has commons-io-2.4.jar
in WEB-INF\lib
and when Project B is run and calls a method using methods from the Commons IO jar, no exception is thrown.
Project A throws this exception whether or not it has commons-io-2.4.jar
in it's own WEB-INF\lib
folder.
I have checked and Eclipse is indeed deploying the jar with the projects.
Is there a way to fix this problem?
EDIT: I'm currently using Eclipse Indigo, not Juno.
EDIT 2: I made a new Java Project that only has a main and the line:
FileUtil.createAndWriteToFile(new File("./test.txt"), "test-data");
As well as Project B as a required project on the build path. No exception is thrown.