Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [swtbot-dev] NoClassDefFoundError for a class in runtime plugin dependency

It has been solved by generating the deliverables of the plugins as jar files, deploying them  under the eclipse plugins directory and creating the swtbot test plugin as the only project in the workspace. It looks like the plugin projects in the workspace are loaded by a different classloader than the plugins deployed in the eclipse installation.

On Fri, Feb 25, 2011 at 10:41 AM, Jordi Fernandez <jordi.fernandez@xxxxxxxxxxxxxxx> wrote:
Here's the stack trace:

java.lang.NoClassDefFoundError: es/liberty/isis/core/ui/swt/widgets/ComboSearchSelector
    at es.liberty.swtbot.test.TestProducts.canCreateAMessage(TestProducts.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
    at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
    at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
    at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
    at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
    at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
    at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:68)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: es.liberty.isis.core.ui.swt.widgets.ComboSearchSelector
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 24 more



And test source code:

/*
 * es.liberty.swtbot.plugin/es.liberty.swtbot.test/TestProducts.java 23/02/2011
 */
package es.liberty.swtbot.test;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Test;

import es.liberty.isis.core.ui.swt.widgets.ComboSearchSelector;


import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.junit.Assert.assertTrue;

public class TestProducts {
    private SWTWorkbenchBot bot;

    @Test
    public void canCreateAMessage() throws Exception {

    SWTBotPreferences.TIMEOUT = 10000;
    bot.menu("Aplicacion").menu("Comercial").menu("Posición Global").click();
   
    Matcher matcher = allOf(
            widgetOfType(ComboSearchSelector.class)            
          );
   
    ComboSearchSelector combo = (ComboSearchSelector) bot.widget(matcher);
    assertTrue(combo.getItemCount() > 0);
    }

    @Before
    public void setup() {
    bot = new SWTWorkbenchBot();
    }
}

I have already checked that the plugin holding the ComboSearchSelector class is exporting the corresponding package (es.liberty.isis.core.ui.swt.widgets).

Regards,
Jordi.

On Thu, Feb 24, 2011 at 6:20 PM, Ketan Padegaonkar <ketanpadegaonkar@xxxxxxxxx> wrote:

Could you please share the stack trace and the complete unit test that causes thus issue?

- Ketan
studios.thoughtworks.com | eclipse.org/swtbot | @ketanpkr

On Feb 24, 2011 7:37 AM, "Jordi Fernandez" <jordi.fernandez@xxxxxxxxxxxxxxx> wrote:
> I'm developing a test with SWTBot that is throwing NoClassDefFoundError when
> trying to load a class that is present in a runtime plugin dependency.
>
> I'm using Eclipse 3.4.2. My workspace has several plugin projects for the
> product under development plus the SWTBot test plugin. Initially I code a
> simple test which just clicked in a menu. It runs fine:
>
> ---------
> public void menuTest() throws Exception {
>
> bot.menu("A").menu("B").menu("C").click();
>
> }
> ----------
>
>
> Then I tried to access a custom developed widget using the following code:
>
>
> ----------------
>
> public void menuTest() throws Exception {
> SWTBotPreferences.TIMEOUT = 10000;
> bot.menu("Aplicacion").menu("Comercial").menu("Posición
> Global").click();
> System.out.println("Hola");
>
> Matcher matcher = allOf(
> widgetOfType(ComboSearchSelector.class)
> );
>
> ComboSearchSelector combo = (ComboSearchSelector) bot.widget(matcher);
> assertTrue(combo.getItemCount() > 0);
> }
>
> --------------------
>
> This second test fails with a NoClassDefFoundError for the
> ComboSearchSelector class. This class is in one of the plugin projects of my
> workspace and is included as a plugin to load in the run configuration (as
> it is a required plugin for the product under development) . In order to
> compile my test, I added this plugin project as a project dependency in the
> java build path.
>
> How come I'm getting a NoClassDefFoundError at runtime when the referenced
> class is loaded (because the plug-in that holds it is present at runtime)?
>
> Thanks in advance.

_______________________________________________
swtbot-dev mailing list
swtbot-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/swtbot-dev




Back to the top