Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 2.0.1Release
-
Fix Version/s: 2.1.0Release
-
Component/s: None
-
Labels:None
-
Environment:Windows 7, Eclipse JEE 3.5.2, GRE 2.0.1
-
Patch Submitted:Yes
-
Number of attachments :3
Description
I've recently started experiencing problems running Groovy files as Groovy Scripts. When I right click on a groovy file and select "Run As Groovy Script", nothing happens. The same applies to the "Groovy Console" option. Below is the error/stacktrace written to the .log file each time I do this.
FYI, I've tried to install a brand new version of Eclipse J2EE 3.5.2 and then install GRECLIPSE 2.0.1 and 2.0.0 plugins again. The problem won't go away even on a fresh install. I've also tried to point to a different workspace. Same thing. Please help.
!ENTRY org.eclipse.ui 4 0 2010-07-05 15:05:33.154
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.createLaunchProperties(AbstractGroovyLaunchShortcut.java:225)
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.launchGroovy(AbstractGroovyLaunchShortcut.java:187)
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.launch(AbstractGroovyLaunchShortcut.java:112)
at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:434)
at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.run(LaunchShortcutAction.java:73)
at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.runWithEvent(LaunchShortcutAction.java:121)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
-
- GRE_789_Launch_Script_From_PackageExplorer_NPE.patch
- 06/Jul/10 2:52 PM
- 2 kB
- Kris De Volder
-
Hide
- groovy-libs.zip
- 06/Jul/10 1:16 PM
- 8.22 MB
- Dmitri
-
- commons-lang-2.4.jar 256 kB
- commons-logging-1.1.1.jar 59 kB
- cxf-2.2.8.jar 4.59 MB
- groovyws-0.5.2.jar 60 kB
- jaxb-impl-2.1.12.jar 847 kB
- jaxb-xjc-2.1.12.jar 2.95 MB
- neethi-2.0.4.jar 32 kB
- wsdl4j-1.6.2.jar 145 kB
- xml-resolver-1.2.jar 82 kB
- XmlSchema-1.4.5.jar 143 kB
-
Hide
- TestGroovy.zip
- 06/Jul/10 1:03 PM
- 6 kB
- Dmitri
-
- TestGroovy/.classpath 0.4 kB
- TestGroovy/.project 0.4 kB
- TestGroovy/.../org.eclipse.jdt.core.prefs 0.6 kB
- TestGroovy/bin/TestGroovy.class 8 kB
- TestGroovy/src/TestGroovy.groovy 0.5 kB
Issue Links
- is related to
-
GRECLIPSE-565
Pick up libraries in .groovy/lib
-
Activity
BTW, if you could try adding the script to the classpath, and confirm that this is (or is not) the problem. That would be helpful.
Thanks,
Kris
Thank you for your prompt reply, Kris. I've checked the Project Build Path and the src/ folder where the script is located is already on the build classpath. The script is just a one line:
println "hello"
Please note, that this worked before and now I can't even launch the Groovy console--it fails with the same NPE. I've noticed this started to happen after I've installed soapUI, but it could've been a coincidence, since I've tried a brand new installation of Eclipse with GRE plugin, no soapUI, and pointing to a new workspace. Same problem. Maybe the issue is outside of the Eclipse realm?
Let me know if there is anything else you need me to try. I am on a tight deadline with my current project and can't do anything at the moment.
I believe Andrew has done some work around this code lately so if you'd be willing to try out the most recent development build of Greclipse and see if the problem still occurs it would be helpful as well.
You can grab dev builds from one of these two update sites:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5/
The 3.5 and 3.6 versions are in synch at the moment, but in the future we will probably start supporting 3.6 and the 3.5 version will receive less and less attention and fall behind. So at the moment it doesn't matter all that much which version you try. But I'd encourage you to move to Eclipse 3.6. if you want to make it easier / quicker to get bugfixes from us.
It's good to know this is not a classpath related issue.
I want to get to the bottom of this. But I need somehow to be able to reproduce this on my local setup to be able to diagnose precisely what is going on.
Let me play around with it a little here. I'll report back if I can / cannot reproduce it. In the mean time please try a snaphsot build and see if that changes anything (if I'm going to submit a fix, this is also where you'd get the fix... so, setting that up now is useful anyway ![]()
I just tried in Greclipse, latest dev build in Eclipse 3.6.
Create a new clean workspace, create a simple test project (using the "File > New > Groovy Project" menu). Then create a Test.groovy file in the new project's source folder. And then when I run it "as groovy script" it seems to work fine.
So, I'm not having any luck to reproduce this bug yet.
I'll also give it a try in Eclipse 3.5, but haven't got an E35 install ready to try this in at the moment. So bare with me.
I'm going to get an E35 to be more similar to your setup. Also I'm downloading the JEE version to see if maybe it is specific to that. In the mean time, can you post the more recent stacktrace (with the dev snapshot). At least that one we know line numbers correspond with the current code base I'm working on.
Kris
Somehow, I have a feeling the problem is outside of the Eclipse. Is there anything on my file system (or absence of such) that could cause that? It's really suspicious that it still doesn't work for me with a brand new install. Maybe some environment variables, settings, 64 bit vs. 32 bit etc.?
Here is the latest stacktrace from the dev snapshot (see below). Also wanted to mention that I am on 64 bit Windows 7. Though, I've tried to make this work on both, 64 and 32 bit Eclipse.
!ENTRY org.eclipse.ui 4 0 2010-07-06 10:21:55.170
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.createLaunchProperties(AbstractGroovyLaunchShortcut.java:225)
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.launchGroovy(AbstractGroovyLaunchShortcut.java:187)
at org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.launch(AbstractGroovyLaunchShortcut.java:112)
at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:434)
at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.run(LaunchShortcutAction.java:73)
at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.runWithEvent(LaunchShortcutAction.java:121)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
I can't think of anything. If you can get the new stacktrace... I could look at where exactly the NPE arose, that may give some hints.
Just to make sure... the project you made is a Groovy project right? Or is it some JEE specific project type?
Just installed Eclipse 3.5 JEE and still no luck in reproducing the problem.
Could you send me the project that has the problem. Simply zip up the whole project directory with everyting in it (.classpath .project etc.).
You can do this by right click on the project and "export as".
While you do that, I'll be setting up my 35 dev environment to take closer look at the stacktrace in the E35 codebase.
I've imported that project in my brand new JEE Eclipse 35. The TestGroovy.groovy file in there has compile errors (import groovyx.net.ws.WSClient can't be resolved). Is that how it was on your end?
Dmitri, I'm looking in the stacktrace now and for some reason the project is null. It gets this project from your selection. So it may have something to do with precisely how you launch the "run" command and exactly what views you have open and what is selected. Maybe I'm not doing it exactly the same way as you are.
Are you launching from the Java package explorer view? Or some other way?
The view in which you click on this, what is it called (i.e. the thing that display the tree in which you click on the file, what name does it display in the tab above it?).
For example does it say "Package Explorer" or "Project Explorer"?
I'm asking, because from looking at the code, I suspect it is something todo exactly with how the UI selection gets processed. I think could probably fix the code to be less fragile in this respect, but it be best if I actually can see the error first, so I can ensure it is really fixed.
If I can't reproduce it, I'll still try to put in a patch, and ask you to try it out instead.
Yes! I've got the error now. It started happening after I copied those groovy libraries into the .groovy/lib folder!
That's good news because now I can actually try to debug this ![]()
Since this bug seems to start happening after some libraries added to the .lib folder, it may have something to do with this issue.
OK, I was jumping to conclusions a bit. The libraries have nothing to do with it. I get the bug with / without libraries if I just select and run the file from the project explorer. If I do "run as" from the Editor window instead, there is no problem. My first guess was right: its to do with the precise selection and the code looks a bit fragile in that respect. I'll fix that up.
In the mean time, I think you can probably get your urgent work done simply by doing "run as" only from the editor window. Let me know if that works ![]()
Kris
This patch fixes the NPE. I prepared this patch against E35 branch. I think it will most likely just work on E36 as well. I'll try that out and if it doesn't seem to work I'll create a 36 patch as well.
PS: Dimitri, before you can update from the snapshot site, someone will have to commit this patch and then we need to wait for automated build to succeed. When that's done, I'll post a message here and mark this issue as "resolved".
Patch is committed into 3.5 and 3.6. Kris, let me know if it needs tweaking for 3.6.
Patch in 3.6 seems to work.
It looks like Andrew turned-off autobuilding on the build server before he left. We haven't had a build since 6 days ago. I don't seem to be able to trigger builds manually.
Andrew kicked of the build and it looks like it was succesfully built last night. Fix should now be available in the latest snapshot (both for E36 and E35).
I'm resolving this issue. Feel free to reopen it if you still have problems after getting the snapshot.
A likely reason for this exception is that the script file is not on the classpath for the project. Admittedly the error could be clearer.
However, the Groovy Eclipse plugin needs you to put files you want to run / compile on the project's classpath. There are quite a number of things that will go wrong when they are not
To some degree this is logical, since we need a classpath in order to be able to resolve dependencies for your script. To another degree this is not so logical, since often scripts in a project would probably need a different classpath than the "regular" code in the project. If that is the case than it may be a good idea to put your scripts in a separate project, so that you can control its classpath independently.
I will have a look at this null pointer exception however, since we don't like NPE, they really should not happen.