Note that there are some explanatory texts on larger screens.

plurals
  1. POAbstractUIPlugin causing NoClassDefFoundError
    text
    copied!<p>I am writing an Eclipse plugin that supports automated testing like JUnit. I have a Launch Configuration Delegate that launches my Main class, which will run the tests on the class the user provides.</p> <p>I want to programmatically show a custom View from my Eclipse plugin when I launch it with my Launch Configuration Delegate. I keep getting a NoClassDefFoundError for the AbstractUIPlugin class when I try to launch it even though I have included both org.eclipse.ui and org.eclipse.core.runtime in my plugin dependencies.</p> <p><strong>Stack Trace</strong></p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/ui/plugin/AbstractUIPlugin at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) 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 eoo.thefamilycoder.specj.internal.launching.delegate.SpecJMain.main(SpecJMain.java:8) Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.plugin.AbstractUIPlugin 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) ... 13 more </code></pre> <p><strong>MANIFEST.MF</strong></p> <pre><code>Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SpecJ Bundle-SymbolicName: eoo.thefamilycoder.specj;singleton:=true Bundle-Version: 1.0.0.alpha Bundle-Activator: eoo.thefamilycoder.specj.internal.Activator Require-Bundle: org.eclipse.ui;bundle-version="3.105.0", org.eclipse.core.runtime;bundle-version="3.9.0", org.eclipse.jdt.launching;bundle-version="3.7.0", org.eclipse.debug.core;bundle-version="3.8.0", org.eclipse.jdt.core;bundle-version="3.9.1", org.eclipse.debug.ui;bundle-version="3.9.0", org.eclipse.jdt.ui;bundle-version="3.9.1", org.eclipse.jdt.debug.ui;bundle-version="3.6.200" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy </code></pre> <p><strong>Main class</strong></p> <pre><code>import eoo.thefamilycoder.specj.internal.Activator; public class SpecJMain { public static void main(String[] args) { Activator.getDefault().showView(); } } </code></pre> <h2>What is causing the error, and how can I fix it?</h2> <p><strong>Edit:</strong> Adding launch code</p> <p><strong>Launch Configuration Delegate</strong></p> <pre><code>public class SpecJLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate { private static final int UNITS_OF_WORK = 4; @Override public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException { final IProgressMonitor pm = monitor != null ? monitor : new NullProgressMonitor(); pm.beginTask(configuration.getName(), UNITS_OF_WORK); if (pm.isCanceled()) return; try { preLaunchCheck(configuration, mode, pm); if (pm.isCanceled()) return; final VMRunnerConfiguration runConfig = new VMRunnerConfigurationFactory().create(configuration, monitor, this); if (pm.isCanceled()) return; getVMRunner(configuration, mode).run(runConfig, launch, pm); if (pm.isCanceled()) return; } finally { pm.done(); } } @Override public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { final String[] initialClasspath = super.getClasspath(configuration); final String pluginClasspath = new SpecJClasspathLocator().getClasspath(); System.out.println(pluginClasspath); if (pluginClasspath == null) return initialClasspath; final String[] classpath = new String[initialClasspath.length + 1]; classpath[0] = pluginClasspath; System.arraycopy(initialClasspath, 0, classpath, 1, initialClasspath.length); return classpath; } } </code></pre> <p><strong>VMRunnerConfigurationFactory</strong></p> <pre><code>public class VMRunnerConfigurationFactory { public VMRunnerConfiguration create(final ILaunchConfiguration configuration, final IProgressMonitor monitor, final AbstractJavaLaunchConfigurationDelegate delegate) throws CoreException { final ExecutionArguments execArgs = new ExecutionArguments(delegate.getVMArguments(configuration), ""); // Activator.MAIN_TYPE_NAME is the main class above final VMRunnerConfiguration runConfig = new VMRunnerConfiguration(Activator.MAIN_TYPE_NAME, delegate.getClasspath(configuration)); runConfig.setBootClassPath(delegate.getBootpath(configuration)); runConfig.setEnvironment(delegate.getEnvironment(configuration)); runConfig.setProgramArguments(new ProgramArgumentsFactory().create(configuration, monitor)); runConfig.setVMArguments(execArgs.getVMArgumentsArray()); runConfig.setVMSpecificAttributesMap(delegate.getVMSpecificAttributesMap(configuration)); runConfig.setWorkingDirectory(getWorkingDirectoryName(delegate.verifyWorkingDirectory(configuration))); return runConfig; } private String getWorkingDirectoryName(final File workingDir) throws CoreException { return workingDir != null ? workingDir.getAbsolutePath() : null; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload