0

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);

1
  • In the java build path / libraries tab, the entries are:\n 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 Commented Oct 6, 2013 at 12:41

2 Answers 2

2

The classpathentry has three dots. try two dots

Sign up to request clarification or add additional context in comments.

1 Comment

The three dots represent a portion of the path that was deleted. The path is absolute, and contains the complete path, and is correct. But thanks for the suggestion.
1

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.

Comments

Your Answer

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