[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re-running applications via EclipseStarter

Currently I am trying to make a new plugin application that is to be run on the eclipse platform from Java. I have an existing one that performs, as I want it under eclipse 3.2. I have written a new plugin, using Eclipse 3.5, and defined the necessary parts of the plugin.xml and MANIFEST.MF for the plugin to load and be run as an application.

Basic Outline

The Java program I have sets up the necessary eclipse environemnt variables and creates a class loader to load the class
org.eclipse.core.runtime.adaptor.EclipseStarter
from the org.eclipse.osgi_3.5.0.v20090520.jar plugin.


  clazz        = clazzLoader.loadClass("org.eclipse.core.runtime.adaptor.EclipseStarter ");
   isRunning    = clazz.getDeclaredMethod("isRunning", new Class[] {});
   iterationRun = clazz.getDeclaredMethod("run", new Class[] {Object.class});
   startup      = clazz.getDeclaredMethod("startup", new Class[] { String[].class, Runnable.class });
   shutdown     = clazz.getDeclaredMethod("shutdown", new Class[] {});


The platform is started by: startup.invoke(null, new Object[] { passThruArgs, splashHandler }); and successfully starts, loading all required plugins to perform its tasks.

The application (specified in the eclipse.application property) is run by:
  iterationRun.invoke(null, new Object[] { null });

Eventually the platform is shutdown with a through shutdon.

Question/Issues

I want to be able to re-run the application multiple times.  In the 3.2 version I was able to set the platform up once, and call (through) iterationRun multiple times, however, not I am unable to do this.  First call is successful, but the 2nd call onward will fail as the runnable (reference internally used is set to null) and the call will fail (trace given below).

This seems to be due to org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(Object defaultContext) code setting it's runnable to null in the finally block after the line return runnable.run(appContext != null ? appContext : defaultContext);
call to the application has returned.


The only way around this that I have been able to do is to shutdown (EclipseStarter.shutdown) the platform and start it up again (EclipseStarter.startup) then I can run the application again.

Any information reguarding this issue would be appreciated


Trace (abreviated)

java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
       at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at MyApp.iterate(MyApp.java:264)
Caused by: java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
       at  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:74)
       at  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .reStart(EclipseAppLauncher.java:155)
       at  org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:370)
       ... 9 more