Bug 244735 - An internal error occurred during: "Export Features".
Summary: An internal error occurred during: "Export Features".
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 1.6.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6.0   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 235174 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-20 14:42 EDT by Reto Urfer CLA
Modified: 2012-04-03 14:21 EDT (History)
3 users (show)

See Also:


Attachments
Small patch that probably addresses this bug (2.25 KB, patch)
2008-08-22 12:56 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
patch to allow export of plugins and products without AJDE in target platform (4.73 KB, patch)
2008-08-25 12:21 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
patches the manifest file for adjt core (754 bytes, patch)
2008-08-26 12:21 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
patch which solve the problem in my environment (1.93 KB, patch)
2008-08-26 15:17 EDT, Reto Urfer CLA
andrew.eisenberg: iplog+
Details | Diff
Adapted patch from Reto (2.36 KB, patch)
2008-08-26 17:12 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
Patch which concates install location and relative bundle location (1.44 KB, patch)
2008-08-28 11:41 EDT, Reto Urfer CLA
andrew.eisenberg: iplog+
Details | Diff
Patch which concates install location and relative bundle location (1.44 KB, patch)
2008-08-28 11:41 EDT, Reto Urfer CLA
andrew.eisenberg: iplog+
Details | Diff
Final patch to fix bug (3.49 KB, patch)
2008-08-29 13:27 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Reto Urfer CLA 2008-08-20 14:42:09 EDT
I tried to use the funtions 'Create Ant Build File with AspectJ Support' and 'Export -> Deployable plug-ins and fragments with AspectJ support' with the latest AJDT Build for Eclipse 3.4 (1.6.0.200808191733). Both fail with a NullPointerException:

eclipse.buildId=I20080617-2000
java.version=1.6.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH
Framework arguments:  -showlocation
Command-line arguments:  -os win32 -ws win32 -arch x86 -data D:\Daten\eclipse34\Logica\workspace -showlocation


Error
Wed Aug 20 20:29:30 CEST 2008
An internal error occurred during: "Export Features".

java.lang.NullPointerException
at org.eclipse.ajdt.core.exports.AJModelBuildScriptGenerator.bundleToCP(AJModelBuildScriptGenerator.java:1535)
at org.eclipse.ajdt.core.exports.AJModelBuildScriptGenerator.generateCompilationTarget(AJModelBuildScriptGenerator.java:1199)
at org.eclipse.ajdt.core.exports.AJModelBuildScriptGenerator.generateBuildJarsTarget(AJModelBuildScriptGenerator.java:1036)
at org.eclipse.ajdt.core.exports.AJModelBuildScriptGenerator.generateBuildScript(AJModelBuildScriptGenerator.java:367)
at org.eclipse.ajdt.core.exports.AJModelBuildScriptGenerator.generate(AJModelBuildScriptGenerator.java:241)
at org.eclipse.ajdt.core.exports.AJBuildDirector.generateModels(AJBuildDirector.java:107)
at org.eclipse.ajdt.core.exports.AJBuildDirector.generateChildrenScripts(AJBuildDirector.java:127)
at org.eclipse.ajdt.core.exports.AJBuildDirector.generate(AJBuildDirector.java:46)
at org.eclipse.pde.internal.build.builder.BuildDirector.generate(BuildDirector.java:168)
at org.eclipse.ajdt.core.exports.AJBuildScriptGenerator.generateFeatures(AJBuildScriptGenerator.java:267)
at org.eclipse.ajdt.core.exports.AJBuildScriptGenerator.generate(AJBuildScriptGenerator.java:150)
at org.eclipse.ajdt.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:239)
at org.eclipse.ajdt.internal.core.exports.FeatureBasedExportOperation.run(FeatureBasedExportOperation.java:48)
at org.eclipse.ajdt.internal.ui.wizards.exports.AJFeatureExportJob.run(AJFeatureExportJob.java:54)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Andrew Eisenberg CLA 2008-08-20 16:41:22 EDT
Will look into this.
Comment 2 Andrew Eisenberg CLA 2008-08-20 19:16:18 EDT
Tell me more about.  Does it happen all the time, or only for certain projects?  (I tried it on simple cases and it works.) 

If only for certain projects, then please attach a project that fails or describe in detail a failing project.
Comment 3 Reto Urfer CLA 2008-08-21 16:55:35 EDT
It happens all the time, independent if i try with an AspectJ plugn or fragment.

I created a new test AspectJ plugin and a test AspectJ fragment and in both cases i can not create the build.xml file completely. It starts creating the build.xml and stops with a NullPointerException

Here the fragment of the build.xml created before the exception:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test.aspectj.fragment" default="build.jars" basedir=".">

	<property name="basews" value="${ws}"/>
	<property name="baseos" value="${os}"/>
	<property name="basearch" value="${arch}"/>
	<property name="basenl" value="${nl}"/>
	<property name="bundleId" value="test.aspectj.fragment"/>
	<property name="bundleVersion" value="1.0.0"/>

	<!-- Compiler settings. -->
	<property name="javacFailOnError" value="false"/>
	<property name="javacDebugInfo" value="on"/>
	<property name="javacVerbose" value="false"/>
	<property name="logExtension" value=".log"/>
	<property name="compilerArg" value=""/>
	<property name="javacSource" value="1.3"/>
	<property name="javacTarget" value="1.2"/>
	<condition property="dir_bootclasspath" value="${java.home}/../Classes">
		<os family="mac"/>
	</condition>
	<property name="dir_bootclasspath" value="${java.home}/lib"/>
	<path id="path_bootclasspath">
		<fileset dir="${dir_bootclasspath}">
			<include name="*.jar"/>
		</fileset>
	</path>
	<property name="bootclasspath" refid="path_bootclasspath"/>
<condition property="bundleBootClasspath" value="${JavaSE-1.6}"	>
		<isset property="JavaSE-1.6"/>
	</condition>
<condition property="bundleJavacSource" value="1.6"	>
		<isset property="JavaSE-1.6"/>
	</condition>
<condition property="bundleJavacTarget" value="1.6"	>
		<isset property="JavaSE-1.6"/>
	</condition>
	<property name="bundleJavacSource" value="${javacSource}"/>
	<property name="bundleJavacTarget" value="${javacTarget}"/>
	<property name="bundleBootClasspath" value="${bootclasspath}"/>

	<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"		>
			<isset property="buildTempFolder"/>
		</condition>
		<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/test.aspectj.fragment_1.0.0"		>
			<isset property="buildTempFolder"/>
		</condition>
		<property name="build.result.folder" value="${basedir}"/>
		<property name="temp.folder" value="${basedir}/temp.folder"/>
		<property name="plugin.destination" value="${basedir}"/>
	</target>

	<target name="properties" if="eclipse.running">
		<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>

	</target>

	<target name="build.update.jar" depends="init" description="Build the plug-in: test.aspectj.fragment for an update site.">
		<delete dir="${temp.folder}"/>
		<mkdir dir="${temp.folder}"/>
		<antcall target="build.jars"/>
		<antcall target="gather.bin.parts">
			<param name="destination.temp.folder" value="${temp.folder}/"/>
		</antcall>
		<jar destfile="${plugin.destination}/test.aspectj.fragment_1.0.0.jar" basedir="${temp.folder}/test.aspectj.fragment_1.0.0" filesetmanifest="merge"/>
		<delete dir="${temp.folder}"/>
	</target>

	<target name="@dot" depends="init" unless="@dot" description="Create jar: test.aspectj.fragment @dot.">
		<delete dir="${temp.folder}/@dot.bin"/>
		<mkdir dir="${temp.folder}/@dot.bin"/>
		<path id="@dot.classpath">
			<pathelement path="../test.aspectj.plugin/bin"/>
			<pathelement path="../test.aspectj.plugin/@dot"/>
			<pathelement path="../../../../../Tools/eclipseGanymede/pde-target/rcp-target/eclipse/plugins/org.aspectj.runtime_1.6.2.20080807114600/aspectjrt.jar"/>
		</path>
		<!-- compile the source code -->
Comment 4 Andrew Eisenberg CLA 2008-08-21 17:51:43 EDT
Still can't reproduce the problem.  I am able to generate the script myself.  

I have an idea of what the problem might be, though.  Do you have any other custom plugins installed?

In the version that you are running, line AJModelBuildScriptGenerator.java line 1535 is this test:

if (bundle.getName().equals("org.apache.ant")) {

For most plugins/bundles the name field is *not* null, but it is possible.  Should be a check for null or use the getSymbolicName() method instead.

Can you run the export with all custom plugins disabled?  If it works, then we can assume that was the problem.  I will submit a patch for it.  Thanks for your help.
Comment 5 Andrew Eisenberg CLA 2008-08-22 12:56:31 EDT
Created attachment 110701 [details]
Small patch that probably addresses this bug

Although I couldn't reproduce this bug on my own, it is likely that this patch will address it.  Even if it doesn't address the bug, this patch is a good idea to commit because it prevents failures in odd cases (eg- when a plugin has no bundle-name property).

Note that this bug is related to (but not a duplicate of 218751
Comment 6 Andrew Clement CLA 2008-08-22 13:08:32 EDT
patch from comment 5 is in. iplog.
Comment 7 Reto Urfer CLA 2008-08-22 13:59:20 EDT
I tried now once with a complete new installation, just Eclipse SDK and AJDT, and in this environment I can also generate the build.xml and export the AspectJ plugin project.

I checked also all the plugins installed in the other environment but i could not find any with no bundle name specified.
Comment 8 Reto Urfer CLA 2008-08-24 06:05:51 EDT
I was now able to localize the problem. I use a special target platform to build the plugins against. This target platform does not contain the plugin 'org.aspectj.ajde'. The result is that the method AJModelBuildScriptGenerator.getModel("org.aspectj.ajde") does not find the bundle and therefore the method AJModelBuildScriptGenerator.bundleToCP with a 'null' parameter value.

I copied then the plugin 'org.aspectj.ajde' to my target platform. But this did not help because this bundle is not resolved and the method AJModelBuildScriptGenerator.getModel looks for a resolved bundle.

After i replaced the call the getResolvedBundle(modelId) in the method AJModelBuildScriptGenerator.getModel with getBundle(modelId, null, false) and getBundle(modelId, modelVersion, false) i did not have the execption anymore and the build.xml file was generated properly.
Comment 9 Andrew Eisenberg CLA 2008-08-24 23:27:30 EDT
Here's what's going on...

The export process requires AJDE to be on the classpath so that the build script can generate the iajc taskdef directive with the proper attributes (its classpath, not just the path to ajde.jar but everything that ajde.jar relies on). However, when the target is actually built, these need not be on the runtime path.

So, a less than optimal solution is to add ajde and its required bundles to your target platform, generate the build file (or export the feature), and then remove them when you are done.  Once the build is completed, the extra bundles are not needed any more.

An ideal solution would be for the build process to detect this situation and add the bundles automatically.
Comment 10 Andrew Eisenberg CLA 2008-08-25 12:21:49 EDT
Created attachment 110811 [details]
patch to allow export of plugins and products without AJDE in target platform

This patch allows exporting without ajde in the target.  When generating th build script, if ajde is found not to be in the target platform, then we look for the ajde plugin in the current platform, temporarily add that to the target and all of its dependencies.

In order for this to work, ajde must be resolvable in the currently running instance of Eclipse.  This however, I think is always true because ajdt can't run if ajde is not present.

Andy is away right now, so the earliest that this will be committed to AJDT is tomorrow.  But, you can apply this patch yourself and try it out if you like.

Please let me know if this works for you.
Comment 11 Andrew Eisenberg CLA 2008-08-25 12:23:51 EDT
Andy, there are two patches here.  Have you already committed the first?  The second patch does *not* include the first.  They are separate and both can be applied independently (although they should be applied together).
Comment 12 Reto Urfer CLA 2008-08-25 16:02:32 EDT
Unfortunately it still does not work properly. There is no exception anymore because you catch it now but the ajde.classpath in the generated build.xml is completly empty.

PluginRegistry.findEntry(bundleName) does also return null for the bundleName "org.aspectj.ajde". The method also seems only to find plugins defined either in the current workspace or in the target but not the ones from the current platform.

I replaced once in the new method addBundleAndRequired the statement:
BundleDescription tempBundle = PluginRegistry .findEntry(bundleName).getModel().getBundleDescription();
with:
Bundle tempBundle = Platform.getBundle(bundleName);

Then the bundle can be found but statement: 
state.addBundle(new File(tempBundle.getLocation()));
does not add the bundle because it can not locate the manifest
Comment 13 Andrew Eisenberg CLA 2008-08-25 17:07:13 EDT
Hmmmm...Not sure what is going on.  It's working on my end, so there must be something different with how your platform is set up.

I am running this in a runtime workspace, but I am disabling the workspace ajde plugin and using the installed version instead (ie- from eclipse/plugins directory).  So the runtime workspace, uses the same plugin as the base workspace.  In the runtime workspace, the target workspace does not include the ajde plugin.  In the runtime workspace, I have an AspectJ PDE project that I export (using the runtime's target workspace to compile against, which does not include ajde).  Here the build file correctly generates the proper classpath for ajde.

What is your set up like?  Where is the ajde plugin for the runtime workspace located?  Are you even running this in a runtime workspace?  Are you runnning things differently from the way I am?

Where is your ajde plugin located?  Is it in your eclipse/plugins directory?  Are you running this as part of a runtime workspace?
Comment 14 Andrew Clement CLA 2008-08-26 11:23:55 EDT
patch from comment 10 is in
Comment 15 Andrew Clement CLA 2008-08-26 11:43:30 EDT
*** Bug 235174 has been marked as a duplicate of this bug. ***
Comment 16 Andrew Eisenberg CLA 2008-08-26 12:21:14 EDT
Created attachment 110955 [details]
patches the manifest file for adjt core

Forgot to add this file to the previous patch.  This caused the build to fail.
Comment 17 Andrew Clement CLA 2008-08-26 12:26:49 EDT
244735: comment 16 in
Comment 18 Reto Urfer CLA 2008-08-26 14:13:45 EDT
I have an Eclipse SDK installed with Equinox Installer in a shared location. With the p2 software installer i updated today AJDT to the latest available version (1.6.0.200808261244) from http://download.eclipse.org/tools/ajdt/34/dev/update.

In my development workspace i have some Java and AspectJ plugins but no plugins from AJDT. The development workspace uses a special target platform to compile against which does not contain any plugin from AJDT, only org.aspectj.runtime and org.aspectj.weaver. 

If i now create the build.xml with AspectJ support i get a build.xml with an empty ajde.classpath! If i copy the plugin org.aspectj.ajde into my target platform the genrated build.xml looks fine.

I have the same behaviour when i get the latest copy of the plugin org.eclipse.ajdt.core into my development workspace and launch the Eclipse IDE with this plugin version instead the installed one.

The JavaDoc about PluginRegistry.findEntry(bundleName) says: 
"Returns a model entry containing all workspace and target plug-ins by the given ID". If i understand this correct, your patch can not work because the plugin org.aspectj.ajde is neither in my workspace not in my active target, its only in the running platform, the Eclipse IDE.
Comment 19 Reto Urfer CLA 2008-08-26 15:17:02 EDT
Created attachment 110989 [details]
patch which solve the problem in my environment

With this patch i can do both, create only the build.xml and also export the plugin with AspectJ support. 
It takes all plugins which can not be found in the workspace or target from the actual running platform. Maybe you can use it.
Comment 20 Andrew Eisenberg CLA 2008-08-26 15:47:58 EDT
Thanks for the patch.  I'll try it out.

I see what the difference was.  Your target platform is in a different location from your development platform, and the target platform does not have the ajde plugin.  Whereas for me, the target platform was in the same location.  I just removed the ajde and weaver plugins from the target using the preferences page.  It's likely that even though ajde was excluded from the target, since it is still present, PluginRegistry.findEntry could still find it.
Comment 21 Andrew Eisenberg CLA 2008-08-26 17:12:13 EDT
Created attachment 111003 [details]
Adapted patch from Reto

Thanks for the patch.  It works.  I tried it out on my workspace and I adapted it a bit.

Andy, can you please commit this patch?

Reto, if you are happy with this fix, then we will close this bug.
Comment 22 Andrew Clement CLA 2008-08-26 17:21:57 EDT
patch from comment 21 is in.
Comment 23 Reto Urfer CLA 2008-08-28 11:41:05 EDT
Created attachment 111218 [details]
Patch which concates install location and relative bundle location

Unfortunately it does still not work properly under all circumstances. It is working fine if i checkout or.eclipse.ajdt.core from CVS and start a second IDE instance from within Eclipse IDE.

It does NOT work, if i install the latest deployed AJDT. The reason is that in this case the getLocation() method of the ajde bundle returns relative path to the install location and therefore the manifest file can not be found. I added another patch which solves this problem and which is working in my environment.
Comment 24 Reto Urfer CLA 2008-08-28 11:41:22 EDT
Created attachment 111219 [details]
Patch which concates install location and relative bundle location

Unfortunately it does still not work properly under all circumstances. It is working fine if i checkout or.eclipse.ajdt.core from CVS and start a second IDE instance from within Eclipse IDE.

It does NOT work, if i install the latest deployed AJDT. The reason is that in this case the getLocation() method of the ajde bundle returns relative path to the install location and therefore the manifest file can not be found. I added another patch which solves this problem and which is working in my environment.
Comment 25 Andrew Eisenberg CLA 2008-08-29 11:21:38 EDT
After installing your patch in a clean workspace and attempting to export an AJ aware plugin, I am still getting errors.

I'll have to look at this some more.
Comment 26 Andrew Eisenberg CLA 2008-08-29 13:27:21 EDT
Created attachment 111317 [details]
Final patch to fix bug

This is essentially the same patch as before, but I added some more comments and also included a small change to AJBuildDirector that will ensure that source plugins are created properly.

I tested this on a clean workspace with a target platform that does not include ajde or weaver plugins and the result is a proper build file and proper exported features.

Thanks for the patch, Reto.
Comment 27 Andrew Clement CLA 2008-08-29 14:34:03 EDT
comment 26 patch in. iplog
Comment 28 Andrew Clement CLA 2008-10-24 20:03:36 EDT
done