Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Ant: NoClassDEfFoundError while accessing another plugin(When I access a class of my test application => NoClassDefFoundError)
icon5.gif  Ant: NoClassDEfFoundError while accessing another plugin [message #515577] Fri, 19 February 2010 12:52 Go to next message
Andreas Baumgartner is currently offline Andreas Baumgartner
Messages: 4
Registered: February 2010
Junior Member
Hi,

I have the following two plugins:

org.rcp.mail
org.rcp.mail.test

org.rcp.mail.test has org.rcp.mail as required plugin.

When I try to access a class of the "org.rcp.mail" plugin from ~.MyFirstTestCase I get a NoClassDefFoundError exception.

This is my build.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project name="testsuite" default="run" basedir=".">
<property name="eclipse-home" value="c:\tools\eclipseGeny\eclipseMailWorks" />
<property name="plugin-name" value="org.rcp.mail.test" />
<property name="test-classname" value="org.rcp.mail.test.MyFirstTestCase"/>
<property name="library-file" value=" ${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.he adless_2.0.0.486-de
v-e34/library.xml"/>

<target name="suite">

<property name="jvmOption" value=""></property>

<property name="temp-workspace" value="workspace" />
<delete dir="${temp-workspace}" quiet="true" />

<ant target="swtbot-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${temp-workspace}" />
<property name="testProduct" value="org.rcp.mail.product" />
<property name="plugin-name" value="${plugin-name}" />
<property name="os" value="win32"/>
<property name="ws" value="win32"/>
<property name="arch" value="x86" />
<property name="classname" value="${test-classname}" />
<property name="vmargs" value=" -Xms128M -Xmx512M -XX:MaxPermSize=512M ${jvmOption} " />
</ant>
</target>

<target name="cleanup" />

<target name="run" depends="suite,cleanup">
<ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
<property name="includes" value="*.xml" />
<property name="output-file" value="${plugin-name}.xml" />
</ant>
</target>

</project>

Then I added the org.rcp.mail.jar to the classpath fileset in the library.xml but this makes no difference.

<java fork="true" dir="." timeout="${timeout}" jvm="${jvm}" logError="true"
classname="org.eclipse.core.launcher.Main" output="${junit-report-output}/${classname}.txt">
<classpath>
<fileset dir="${eclipse-home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
<include name="org.rcp.mail_*.jar" />
</fileset>
</classpath>
<arg line="${launcher-arg-line}" />
<jvmarg line="${jvm-arg-line}" />
<sysproperty key="PLUGIN_PATH" value="${plugin-path}" />
</java>

Does anyone how to access classes outside the test plugin?

Thanks a lot.



Re: Ant: NoClassDEfFoundError while accessing another plugin [message #515595 is a reply to message #515577] Fri, 19 February 2010 13:57 Go to previous messageGo to next message
Andreas Baumgartner is currently offline Andreas Baumgartner
Messages: 4
Registered: February 2010
Junior Member
Hi,

when I run the test inside Eclipse with the run configuration everything works fine. Then I debugged the run from eclipse and the ant run to compare the classloaders.

In eclipse the classloader of my PluginTest.class has as "delegate" as BundleLoader with "requiredBundles". One of the "requiredBundles" is a BundleLoader for my "org.rcp.mail" plugin which have a exported package "org.rcp.mail".

When I debug the ant run this BundleLoader for my plugin "org.rcp.mail" has no exportedPackages.

I think this must be the reason because the ant run fails.

I compared my plugin with other plugins like "org.eclipse.swtbot.eclipse.finder" which contains the SwtWorkbenchBot because accessing the SwtWorkbenchBot is possible but I can't find a difference.

Here is my MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mail Plug-in
Bundle-SymbolicName: org.rcp.mail; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.rcp.mail.Activator
Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.rcp.mail
Bundle-ClassPath: .

Has anyone an idea why the exportedPackages are empty?
icon14.gif  Re: Ant: NoClassDEfFoundError while accessing another plugin [message #515663 is a reply to message #515595] Fri, 19 February 2010 16:49 Go to previous message
Andreas Baumgartner is currently offline Andreas Baumgartner
Messages: 4
Registered: February 2010
Junior Member
Hi me again,

a simple eclipse.exe -clean -install fixed this issue.

When I exported the "orc.rcp.mail" plugin the first time I declared no export packages.

On the second export I added the export package. To make this change active I have to do a clean install on eclipse.

Previous Topic:Manage SWTBot and JUnit tests
Next Topic:Renaming a node in a tree
Goto Forum:
  


Current Time: Sat Oct 25 20:43:35 GMT 2014

Powered by FUDForum. Page generated in 0.01634 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software