Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361202 - Run As > Generate Xtext Artifacts fails with NoClassDefFoundError for org/apache/log4j/Logger
Summary: Run As > Generate Xtext Artifacts fails with NoClassDefFoundError for org/apa...
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-18 01:39 EDT by Barrie Treloar CLA
Modified: 2017-10-31 11:19 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barrie Treloar CLA 2011-10-18 01:39:52 EDT
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
  at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.<clinit>(Mwe2Launcher.java:31)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  ... 1 more
Exception in thread "main"

  The workaround is to open the Run > Run Configurations ... > Mwe2 Launch > GenerateST.mwe2 and click on the Classpath tab.
  Click User Entries and then the Advanced... button, select Add Library and click Ok.
  Select the User Library and click Next.
  Select the log4j user library (that you added earlier) and click Finish.
Comment 1 Sebastian Zarnekow CLA 2011-11-10 16:07:15 EST
I cannot reproduce this. Could you please provide more information and reopen if the problem persists with the released version 2.1.
Comment 2 Jesper Eskilson CLA 2013-06-04 04:56:55 EDT
I managed to get this problem as well. The mwe2 launch configuration had its classpath set up using dependencies from its containing plugin, and for some reason log4j was not included there (not sure if this was user error on my part, or cosmic radiation).

Anyway, I solved the problem by simply adding a dependency on org.apache.log4j in the plugin containing the xtext grammar file.
Comment 3 Karsten Thoms CLA 2013-06-05 08:54:43 EDT
Note that it is better to use Import-Package instead of Require-Bundle for a dependency on log4j. There are alternative implementations like slf4j which provide this package.
Comment 4 Eclipse Webmaster CLA 2017-10-31 11:07:57 EDT
Requested via bug 522520.

-M.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:19:28 EDT
Requested via bug 522520.

-M.