Community
Participate
Working Groups
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.
I cannot reproduce this. Could you please provide more information and reopen if the problem persists with the released version 2.1.
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.
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.
Requested via bug 522520. -M.