Home » Eclipse Projects » Rich Client Platform (RCP) » How to invoke Eclipse operations?
How to invoke Eclipse operations? [message #453567] |
Wed, 02 August 2006 18:46  |
Eclipse User |
|
|
|
Hi all,
I'm writing my first RCP application. It's a simple one that simply
removes unused imports from a Java file using Eclipse's
OrganizeImportsOperation. My problem is that if my code actually tries
to construct an OrganizeImportsOperation, I get an exception at startup
(whether or not the code is executed!).
My entire log is below. But first, here is my code from
Application.java. Look in removeUnusedImports, a function that is not
called. If I uncomment the line to create a new
OrganizeImportsOperation, I get an "java.lang.IllegalStateException:
Workbench has not been created yet" exception at startup.
Can anyone help out?
Thanks,
David
package edu.wm.cs.javacleanup;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.dom.CompilationUnit;
import
org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImp ortsOperation;
import
org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImp ortsOperation.IChooseImportQuery;
import org.eclipse.jdt.internal.corext.util.TypeInfo;
import org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
* This class controls all aspects of the application's execution
*/
public class Application implements IPlatformRunnable {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Obj ect)
*/
public Object run(Object objectArgs) throws Exception {
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display, new
ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
}
String[] args = (String[]) objectArgs;
if (args.length == 0) {
System.err.println("Provide a java file as an argument");
System.exit(1);
}
// removeUnusedImports(args[0]);
System.out.println("Done with " + args[0] + "!");
return IPlatformRunnable.EXIT_OK;
} finally {
display.dispose();
}
}
private void removeUnusedImports(String filepath) {
// IFile file = null; // How to get this without a project?
// ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
ICompilationUnit cu = createFakeCompilationUnit(filepath);
// ASTParser parser = ASTParser.newParser(AST.JLS3);
// parser.setSource(getSource(filepath).toCharArray());
// CompilationUnit astRoot = (CompilationUnit)parser.createAST(null);
CompilationUnit astRoot = null;
IChooseImportQuery query= new IChooseImportQuery() {
public TypeInfo[] chooseImports(TypeInfo[][] openChoices,
ISourceRange[] ranges) {
throw new RuntimeException();
}
};
try {
OrganizeImportsOperation oi = null;
// The following causes an exception at startup
//OrganizeImportsOperation oi = new OrganizeImportsOperation(cu,
astRoot,
// false, false, true, query);
oi.run(null);
} catch (CoreException core) { core.printStackTrace();}
}
// Inspired by CompilationUnitDocumentProvider.createFakecompiltationUnit
private ICompilationUnit createFakeCompilationUnit(final String
filepath) {
try {
WorkingCopyOwner woc= new WorkingCopyOwner() {
public IBuffer createBuffer(ICompilationUnit workingCopy) {
return new DocumentAdapter(workingCopy, new Path(filepath));
}
};
IClasspathEntry[] cpEntries = new IClasspathEntry[] {
JavaRuntime.getDefaultJREContainerEntry() };
final ICompilationUnit cu= woc.newWorkingCopy(filepath,
cpEntries, null, null);
cu.getBuffer().setContents(getSource(filepath));
// if (!isModifiable(element))
// JavaModelUtil.reconcile(cu);
return cu;
} catch (CoreException ex) {
return null;
}
}
public String getSource(String filepath) {
int READER_CHUNK_SIZE= 2048;
int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
try {
Reader in= new BufferedReader(new FileReader(filepath));
char[] readBuffer= new char[READER_CHUNK_SIZE];
int n;
n= in.read(readBuffer);
while (n > 0) {
buffer.append(readBuffer, 0, n);
n= in.read(readBuffer);
}
} catch (Exception e) {
System.err.println("Problems reading from file " + filepath);
e.printStackTrace();
System.exit(1);
}
return buffer.toString();
}
}
!SESSION 2006-08-02 18:31:31.417
-----------------------------------------------
eclipse.buildId=unknown
java.version=1.5.0_06
java.vendor=Apple Computer, Inc.
BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=en_US
Framework arguments: -product edu.wm.cs.javacleanup.JavaCleanup
Command-line arguments: -product edu.wm.cs.javacleanup.JavaCleanup
-data
/Users/coppit/Documents/eclipse/workspace/../runtime-default .product(2)
-dev
file:/Users/coppit/Documents/eclipse/workspace/.metadata/.pl ugins/org.eclipse.pde.core/default.product
(2)/dev.properties -os macosx -ws carbon -arch ppc
!ENTRY org.eclipse.osgi 4 0 2006-08-02 18:31:37.555
!MESSAGE An error occurred while automatically activating bundle
org.eclipse.jdt.ui (31).
!STACK 0
org.osgi.framework.BundleException: Exception in
org.eclipse.core.internal.compatibility.PluginActivator.star t() of
bundle org.eclipse.jdt.ui.
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:1014)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:970)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:339)
at
org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:388)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:352)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.IllegalStateException: Workbench has not been
created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(A STProvider.java:287)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:278)
at
org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPl ugin.java:622)
at org.eclipse.jdt.internal.ui.JavaPlugin.start(JavaPlugin.java :344)
at
org.eclipse.core.internal.compatibility.PluginActivator.star t(PluginActivator.java:30)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:995)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:989)
... 35 more
Root exception:
java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(A STProvider.java:287)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:278)
at
org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPl ugin.java:622)
at org.eclipse.jdt.internal.ui.JavaPlugin.start(JavaPlugin.java :344)
at
org.eclipse.core.internal.compatibility.PluginActivator.star t(PluginActivator.java:30)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:995)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:989)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:970)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:339)
at
org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:388)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:352)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
!ENTRY org.eclipse.osgi 4 0 2006-08-02 18:31:37.593
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError:
org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImp ortsOperation$IChooseImportQuery
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
|
|
|
Re: How to invoke Eclipse operations? [message #453573 is a reply to message #453567] |
Thu, 03 August 2006 03:01   |
Eclipse User |
|
|
|
David Coppit wrote:
> Hi all,
>
> I'm writing my first RCP application. It's a simple one that simply
> removes unused imports from a Java file using Eclipse's
> OrganizeImportsOperation.
That's a contradiction: Organize imports is part of JDT UI which is no
RCP. If you use that you'll drag in all the IDE related stuff.
> My problem is that if my code actually tries to construct an
> OrganizeImportsOperation, I get an exception at startup (whether or
> not the code is executed!).
JDT UI expects a workbench to be present.
Dani
>
> My entire log is below. But first, here is my code from
> Application.java. Look in removeUnusedImports, a function that is not
> called. If I uncomment the line to create a new
> OrganizeImportsOperation, I get an "java.lang.IllegalStateException:
> Workbench has not been created yet" exception at startup.
>
> Can anyone help out?
>
> Thanks,
> David
>
> package edu.wm.cs.javacleanup;
>
> import java.io.BufferedReader;
> import java.io.FileReader;
> import java.io.Reader;
>
> import org.eclipse.core.runtime.CoreException;
> import org.eclipse.core.runtime.IPlatformRunnable;
> import org.eclipse.core.runtime.Path;
> import org.eclipse.jdt.core.IBuffer;
> import org.eclipse.jdt.core.IClasspathEntry;
> import org.eclipse.jdt.core.ICompilationUnit;
> import org.eclipse.jdt.core.ISourceRange;
> import org.eclipse.jdt.core.WorkingCopyOwner;
> import org.eclipse.jdt.core.dom.CompilationUnit;
> import
> org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImp ortsOperation;
>
> import
> org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImp ortsOperation.IChooseImportQuery;
>
> import org.eclipse.jdt.internal.corext.util.TypeInfo;
> import org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter;
> import org.eclipse.jdt.launching.JavaRuntime;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.ui.PlatformUI;
>
> /**
> * This class controls all aspects of the application's execution
> */
> public class Application implements IPlatformRunnable {
>
> /* (non-Javadoc)
> * @see
> org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Obj ect)
> */
> public Object run(Object objectArgs) throws Exception {
> Display display = PlatformUI.createDisplay();
> try {
> int returnCode = PlatformUI.createAndRunWorkbench(display, new
> ApplicationWorkbenchAdvisor());
> if (returnCode == PlatformUI.RETURN_RESTART) {
> return IPlatformRunnable.EXIT_RESTART;
> }
>
> String[] args = (String[]) objectArgs;
>
> if (args.length == 0) {
> System.err.println("Provide a java file as an argument");
> System.exit(1);
> }
>
> // removeUnusedImports(args[0]);
>
> System.out.println("Done with " + args[0] + "!");
>
>
> return IPlatformRunnable.EXIT_OK;
> } finally {
> display.dispose();
> }
> }
>
> private void removeUnusedImports(String filepath) {
> // IFile file = null; // How to get this without a project?
> // ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
>
> ICompilationUnit cu = createFakeCompilationUnit(filepath);
>
> // ASTParser parser = ASTParser.newParser(AST.JLS3);
> // parser.setSource(getSource(filepath).toCharArray());
> // CompilationUnit astRoot =
> (CompilationUnit)parser.createAST(null);
> CompilationUnit astRoot = null;
>
> IChooseImportQuery query= new IChooseImportQuery() {
> public TypeInfo[] chooseImports(TypeInfo[][] openChoices,
> ISourceRange[] ranges) {
> throw new RuntimeException();
> }
> };
>
> try {
> OrganizeImportsOperation oi = null;
>
> // The following causes an exception at startup
> //OrganizeImportsOperation oi = new OrganizeImportsOperation(cu,
> astRoot,
> // false, false, true, query);
>
> oi.run(null);
> } catch (CoreException core) { core.printStackTrace();}
> }
>
> // Inspired by
> CompilationUnitDocumentProvider.createFakecompiltationUnit
> private ICompilationUnit createFakeCompilationUnit(final String
> filepath) {
> try {
> WorkingCopyOwner woc= new WorkingCopyOwner() {
> public IBuffer createBuffer(ICompilationUnit workingCopy) {
> return new DocumentAdapter(workingCopy, new Path(filepath));
> }
> };
>
> IClasspathEntry[] cpEntries = new IClasspathEntry[] {
> JavaRuntime.getDefaultJREContainerEntry() };
>
> final ICompilationUnit cu= woc.newWorkingCopy(filepath,
> cpEntries, null, null);
>
> cu.getBuffer().setContents(getSource(filepath));
>
> // if (!isModifiable(element))
> // JavaModelUtil.reconcile(cu);
>
> return cu;
> } catch (CoreException ex) {
> return null;
> }
> }
>
> public String getSource(String filepath) {
> int READER_CHUNK_SIZE= 2048;
> int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
> StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
>
> try {
> Reader in= new BufferedReader(new FileReader(filepath));
> char[] readBuffer= new char[READER_CHUNK_SIZE];
> int n;
>
> n= in.read(readBuffer);
> while (n > 0) {
> buffer.append(readBuffer, 0, n);
> n= in.read(readBuffer);
> }
> } catch (Exception e) {
> System.err.println("Problems reading from file " + filepath);
> e.printStackTrace();
> System.exit(1);
> }
>
> return buffer.toString();
> }
> }
>
>
>
> !SESSION 2006-08-02 18:31:31.417
> -----------------------------------------------
> eclipse.buildId=unknown
> java.version=1.5.0_06
> java.vendor=Apple Computer, Inc.
> BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=en_US
> Framework arguments: -product edu.wm.cs.javacleanup.JavaCleanup
> Command-line arguments: -product edu.wm.cs.javacleanup.JavaCleanup
> -data
> /Users/coppit/Documents/eclipse/workspace/../runtime-default .product(2)
> -dev
> file:/Users/coppit/Documents/eclipse/workspace/.metadata/.pl ugins/org.eclipse.pde.core/default.product
> (2)/dev.properties -os macosx -ws carbon -arch ppc
>
> !ENTRY org.eclipse.osgi 4 0 2006-08-02 18:31:37.555
> !MESSAGE An error occurred while automatically activating bundle
> org.eclipse.jdt.ui (31).
> !STACK 0
> org.osgi.framework.BundleException: Exception in
> org.eclipse.core.internal.compatibility.PluginActivator.star t() of
> bundle org.eclipse.jdt.ui.
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:1014)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:970)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:339)
>
> at
> org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:388)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:352)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
> at java.lang.Class.getConstructor0(Class.java:2640)
> at java.lang.Class.newInstance0(Class.java:321)
> at java.lang.Class.newInstance(Class.java:303)
> at
> org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
>
> at
> org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
>
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
>
> 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:585)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
> Caused by: java.lang.IllegalStateException: Workbench has not been
> created yet.
> at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
> at
> org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(A STProvider.java:287)
>
> at
> org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:278)
>
> at
> org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPl ugin.java:622)
>
> at org.eclipse.jdt.internal.ui.JavaPlugin.start(JavaPlugin.java :344)
> at
> org.eclipse.core.internal.compatibility.PluginActivator.star t(PluginActivator.java:30)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:995)
>
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:989)
>
> ... 35 more
> Root exception:
> java.lang.IllegalStateException: Workbench has not been created yet.
> at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
> at
> org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(A STProvider.java:287)
>
> at
> org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:278)
>
> at
> org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPl ugin.java:622)
>
> at org.eclipse.jdt.internal.ui.JavaPlugin.start(JavaPlugin.java :344)
> at
> org.eclipse.core.internal.compatibility.PluginActivator.star t(PluginActivator.java:30)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:995)
>
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:989)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:970)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:339)
>
> at
> org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:388)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:352)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
> at java.lang.Class.getConstructor0(Class.java:2640)
> at java.lang.Class.newInstance0(Class.java:321)
> at java.lang.Class.newInstance(Class.java:303)
> at
> org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
>
> at
> org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
>
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
>
> 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:585)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
>
> !ENTRY org.eclipse.osgi 4 0 2006-08-02 18:31:37.593
> !MESSAGE Application error
> !STACK 1
> java.lang.NoClassDefFoundError:
> org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImp ortsOperation$IChooseImportQuery
>
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
> at java.lang.Class.getConstructor0(Class.java:2640)
> at java.lang.Class.newInstance0(Class.java:321)
> at java.lang.Class.newInstance(Class.java:303)
> at
> org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:157)
>
> at
> org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
>
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
>
> 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:585)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
|
|
| | |
Re: How to invoke Eclipse operations? [message #453663 is a reply to message #453587] |
Mon, 07 August 2006 17:56  |
Eclipse User |
|
|
|
Paul Webster wrote:
> Also, you can check out how the standalone update manager works ... they
> must instantiate most of the workbench and then run whatever command was
> passed in on the command line. You can check out their code to see how
> they do it (you are looking for the org.eclipse.update.* plugins).
Thanks for the excellent suggestion. However, are you sure they
instantiate the workbench? I did a search for "workbench" in
org.eclipse.update.core and got nothing. I also compiled their
standalone app and ran it, then tried inserting my code. I got the same
error as before during plugin startup:
Root exception:
java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(A STProvider.java:287)
at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:278)
at
org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPl ugin.java:622)
at org.eclipse.jdt.internal.ui.JavaPlugin.start(JavaPlugin.java :344)
David
|
|
|
Goto Forum:
Current Time: Sun Aug 31 14:21:47 EDT 2025
Powered by FUDForum. Page generated in 0.03960 seconds
|