1

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.

0

1 Answer 1

0

Can you call any method from project B that is in project A?

Are both project folders open when you try running this? I've had this issue when using google maps api in eclipse while debugging android projects.

3
  • Project A calls a few methods from Project B without a problem. It's just this method that has a problem since it is using FileUtils. Both Projects are open in Eclipse.
    – Ivan
    Commented Aug 19, 2013 at 22:32
  • I just read your second edit now. I will have to look at this when I get home. Hopefully someone can answer you sooner than that.
    – eddiecubed
    Commented Aug 19, 2013 at 22:43
  • But can project A call methods in any of the jars in project B? commons-io-2.4.jar is deployed into A's WEB-INF/lib folder at runtime?
    – nitind
    Commented Aug 19, 2013 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.