Reputation:
My old laptop is failing, so I transferred a java program to a new computer, but am having difficulty executing the program. I'm using eclipse, and in order to remove the "missing main class" error added the target directory to the build path. Now, I get the error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at source.Application.<clinit>(Application.java:447)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(Unknown Source)
...
The class path file includes the line
classpathentry kind="lib" path=".../log4j/log4j-1.2.17/apache-log4j-1.2.17/log4j-1.2.17.jar" sourcepath=".../log4j/log4j-1.2.17/apache-log4j-1.2.17/log4j-1.2.17-sources.jar">
So, I'm not sure about what to try next.
In the java build path / libraries tab, the entries are:
External jar: C:\Users\John\Documents\java\log4j\log4j-1.2.17\apache-log4j-1.2.17\log4j-1.2.17.jar source attachment: C:\Users\John\Documents\java\log4j\log4j-1.2.17\apache-log4j-1.2.17\log4j-1.2.17-sources.jar javadoc location: C:\Users\John\Documents\java\log4j\log4j-1.2.17\apache-log4j-1.2.17\log4j-1.2.17-javadoc.jar
The main class has a class member
private static final Logger LOGGER = Logger.getLogger(Application.class);
The main function has the lines
PropertyConfigurator.configure("log4j.properties"); LOGGER.error(e);
Upvotes: 0
Views: 1850
Reputation:
First, I created a new eclipse workspace on a different drive, and copied the java source file directories into the new workspace, and the necessary libraries. The program executed in the new workspace.
Since the prevous workspace was checked out of the transferred svn repository, I went to the previous eclipse workspace directory and deleted the .metadata directory, and restarted eclipse with the previous workspace. Eclipse rebuilt the .metadata directory, and allowed the previous workspace to run.
So, it appears the error was a corrupted eclipse workspace, that became apparent after transferring the svn repository between computers.
Upvotes: 0