Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343640

Summary: API use scan NPE with ant (PDE core not initialized)
Product: [Eclipse Project] PDE Reporter: Nicolas Bros <nicolas.bros>
Component: API ToolsAssignee: PDE API Tools Inbox <pde-apitools-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: emft.facet-inbox, Michael_Rennie
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
stacktrace none

Description Nicolas Bros CLA 2011-04-22 04:28:45 EDT
Created attachment 193905 [details]
stacktrace

I am trying to run an API use scan as described in:
http://wiki.eclipse.org/PDE/API_Tools/Resources#Running_an_API_use_scan_.28commandline.29

But I am blocked by a NPE apparently due to PDE Core not being initialized (see attached stacktrace).

I get this exception both in my local installation when running ant in a separate JRE, and on the Hudson instance on build.eclipse.org, but not when running ant in the same JRE as my Eclipse instance (in this case, I suppose Eclipse already properly initialized the bundles).

When the static variable LocalTargetHandle#LOCAL_TARGET_CONTAINER_PATH is initialized, PDECore#inst is still null, leading to a NPE in "PDECore.getDefault().getStateLocation()"

What I don't understand is that the wiki page describes running the API scan like a standard Java application. Shouldn't it be run as an Eclipse application instead? Otherwise, how are the bundles supposed to be started if there is no Equinox running?
Comment 1 Michael Rennie CLA 2011-04-25 11:03:01 EDT
This is a known issue and has been fixed in bug 342193.

> What I don't understand is that the wiki page describes running the API scan
> like a standard Java application. 

I am not sure what you mean. The section describes how to run the tasks from the commandline; there is no Java nor running Eclipse involved at all.

> Shouldn't it be run as an Eclipse application
> instead? 

It *could* be run that way as well. But we also support running the Ant tasks from the commandline using only Ant like the following:

   root%>ant -buildfile <build file name>

> Otherwise, how are the bundles supposed to be started if there is no
> Equinox running?

The bundles do not get started in the commandline case. The cause of this issue is that there is no OSGi running and the target platform service was not working as expected without OSGi.

*** This bug has been marked as a duplicate of bug 342193 ***