Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Workspace is closed error
Workspace is closed error [message #297346] Thu, 12 January 2006 09:39 Go to next message
Eclipse UserFriend
Originally posted by: jcarter.ma4.com

I am getting the following error when I try to get the Workspace in my
plugin using:

IWorkspace workspace = ResourcesPlugin.getWorkspace();

This is happening in the createPartControl() call for a navigator view
which is inherited from ViewPart. Everything else seems ok for the view
and the plugin has been activated ok as the plugin start method is
definately called.

java.lang.IllegalStateException: Workspace is closed.
at
org.eclipse.core.resources.ResourcesPlugin.getWorkspace(Reso urcesPlugin.java:320)

Does anyone have any ideas?
Re: Workspace is closed error [message #297370 is a reply to message #297346] Thu, 12 January 2006 15:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jcarter.m4.com

Found an answer to this just in case anyone else has a similar problem...

I had org.eclipse.core.resources in the build path rather than having it
as a dependent plugin in the plugin manifest.mf file. So the
ResourcePlugin was not being instantiated by eclipse although the I could
still make calls to the ResourcePlugin class with the code.
Re: Workspace is closed error [message #297792 is a reply to message #297370] Thu, 19 January 2006 18:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manodud.gmail.com

Thanks John. That was useful.

But I encountered with this problem when I tried doing what you suggested.

I have a simple hello world plugin which has a new menu 'AutoTest' with an item 'Auto Test' on the menu-bar and when I click on it, I get the following error.

Could not create action delegate for id: autoTestAction
Reason:
Plug-in com.myplugin.simpletool was unable to load class com.myplugin.simpletool.TestDriver.

My plugin's start() method looks lke the following.

public void start(BundleContext context) throws Exception {
super.start(context);
//SimpletoolPlugin sp = SimpletoolPlugin.getDefault();
//sp.initTesting("examples/ECalculator.java");

initTesting("examples/ECalculator.java");
}

The method initTesting() is as follows:

private void initTesting(String fileName) {
try {
File f = new File(fileName);
IPath path = new Path(f.getAbsolutePath());
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path);
ICompilationUnit cUnit = JavaCore.createCompilationUnitFrom(iFile);
IResource resource = cUnit.getUnderlyingResource();
// IMarker[] markers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MAR KER,
//true, IResource.DEPTH_INFINITE);

}
// catch (JavaModelException jme)
// {
// jme.printStackTrace();
// }
catch (CoreException ce)
{
ce.printStackTrace();
}
}


When I try to run the piece of code in the start() method from the method run(IAction action) in the other class in plugin src, I get the following error.

Unhandled event loop exception
Reason:
java.lang.NullPointerException

So I'm kind of totally lost here. Any help greatly appreciated.

Thanks
-Manohar
Re: Workspace is closed error [message #297796 is a reply to message #297792] Thu, 19 January 2006 21:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Manohar Dudda <manodud@gmail.com> wrote:
> Thanks John. That was useful.
>
> But I encountered with this problem when I tried doing what you
> suggested.
>
> I have a simple hello world plugin which has a new menu 'AutoTest'
> with an item 'Auto Test' on the menu-bar and when I click on it, I
> get the following error.
>
> Could not create action delegate for id: autoTestAction
> Reason:
> Plug-in com.myplugin.simpletool was unable to load class
> com.myplugin.simpletool.TestDriver.
>
> My plugin's start() method looks lke the following.
>
> public void start(BundleContext context) throws Exception {
> super.start(context);
> //SimpletoolPlugin sp = SimpletoolPlugin.getDefault();
> //sp.initTesting("examples/ECalculator.java");
>
> initTesting("examples/ECalculator.java");
> }
>

This is where your problem lies.
You have specified a relative path.
Relative to what? The workspace? A project? A folder? The plugin
installation location? The plugin state location? The filesystem?
Relative to what?

[snip]

--
Sunil
Re: Workspace is closed error [message #297809 is a reply to message #297792] Fri, 20 January 2006 03:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Firstly, this is doing a lot more than it needs to. You don't need to find a full path on the system, then try and convert it back to find an IFile; you can just get an IFile straight away. It's not even clear whether your File object would work; you're using a relative path ("examples/ECalculator.java") and there's no guarantee that that's going to be in any particular directory on your file system. Perhaps you were expecting it to be relative to a project?

Secondly, an IFile *is* an IResource, so going via the JavaCore compilation stage is a waste of time if all you want to do is get the markers.

Lastly, if you get a null pointer exception, find out which line it's on. You've got the code (and the debugger) in front of you; it could be on almost any line of the code that you've pasted (though I'm going to bet it's on the first few lines). You can either step through in the debugger (read the help on how to debug programs) or stick in System.out.println() messages. Then you'll know what the return code is for each call. Heck, even if you just printed out (1), (2), (3) in strategic places you'd have a good idea of where the code was running succesfully up to.

Unfortunately, because of the number (and nature) of threads being invoked, you don't always get a decent exception stack trace. But my money would be on your IFile being returned from the getFileForLocation() being null, because I really don't see any way that "examples/ECalculator.java" is going to point to a file, despite what you think it should point to. It's not psychic, you know :-)

Ultimately, I suspect that your bundle's start() method is failing because your file can't be found (and causing a NullPointerException). If your bundle doesn't start, then any extensions inside the bundle won't be started, so any actions that you've got won't be executable. (The menu item is there because Eclipse knows to stick an icon there; but it doesn't load the class -- or even start the bundle -- until the first time you click on it).

Eclipse has a massively powerful debugger, and it's also a lot more interactive than this newsgroup is; if you learn to use it (double click on the left hand side of the line in the super.start() of your plugin, then click on the bug icon which is next to the green play icon) then you'll get the most out of developing for Eclispe.

Alex.

PS It's generally pretty bad practice to do stuff with files in a startup method of a bundle, for exactly this reason; if the startup fails, your bundle doesn't start.
Re: Workspace is closed error [message #297833 is a reply to message #297809] Fri, 20 January 2006 14:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manodud.gmail.com

Thank you so much Alex, for the reply. Thanks to you too, Sunil. I looked it up in the log file in .metadata. And the file was the cause for NPE :) I'll get back upon further hickups...

Thanks again.
-Manohar
Re: Workspace is closed error [message #305047 is a reply to message #297370] Thu, 22 June 2006 07:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kja.eswar.gmail.com

How do I include in org.eclipse.core.resources
as a dependent plugin in the plugin manifest.mf file? I am new to eclipse. Your help would be greatly appreciated.
Re: Workspace is closed error [message #305080 is a reply to message #305047] Thu, 22 June 2006 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Open the Manifest, go to Dependencies page, and add it as a required plugin.


Eswar K wrote:
> How do I include in org.eclipse.core.resources
> as a dependent plugin in the plugin manifest.mf file? I am new to eclipse. Your help would be greatly appreciated.

--
Thanks,
Rich Kulp
Re: Workspace is closed error [message #305082 is a reply to message #305080] Thu, 22 June 2006 14:13 Go to previous message
Eclipse UserFriend
Originally posted by: kja.eswar.gmail.com

Thanks a lot...

that helped.

Eswar
Previous Topic:load the editor programatically
Next Topic:Unhandled event loop exception --> java.lang.NullPointerException
Goto Forum:
  


Current Time: Thu Mar 28 11:06:56 GMT 2024

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

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

Back to the top