spring-attic / spring-ide

Spring Development Environment for Eclipse
299 stars 126 forks source link

Double click on any Live Beans Graph node yields to NullPointerException #300

Closed jhartotr closed 5 years ago

jhartotr commented 6 years ago

I'm using Spring IDE Version: 3.9.5.201807030714-RELEASE. Please find the generated error log below:

eclipse.buildId=4.8.0.I20180611-0500 java.version=1.8.0_171 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US Framework arguments: -product org.eclipse.epp.package.java.product Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product

This is a continuation of log file /home/user/workspace/.metadata/.bak_0.log Created Time: 2018-07-13 22:48:27.759

org.eclipse.jface Error Sat Jul 14 00:30:54 CEST 2018 Problems occurred when invoking code from plug-in: "org.eclipse.jface".

java.lang.NullPointerException at org.springframework.ide.eclipse.beans.ui.live.utils.JdtUtils.getJavaProject(JdtUtils.java:41) at org.springframework.ide.eclipse.beans.ui.live.utils.JdtUtils.getJavaType(JdtUtils.java:65) at org.springframework.ide.eclipse.beans.ui.live.model.TypeLookupImpl.findType(TypeLookupImpl.java:65) at org.springframework.ide.eclipse.beans.ui.live.actions.AbstractOpenResourceAction.openInEditor(AbstractOpenResourceAction.java:54) at org.springframework.ide.eclipse.beans.ui.live.actions.OpenBeanClassAction.run(OpenBeanClassAction.java:52) at org.springframework.ide.eclipse.beans.ui.livegraph.views.LiveBeansGraphView$1.doubleClick(LiveBeansGraphView.java:131) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:830) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:827) at org.eclipse.zest.core.viewers.GraphViewer.access$2(GraphViewer.java:1) at org.eclipse.zest.core.viewers.GraphViewer$2.mouseDoubleClick(GraphViewer.java:104) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:197) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5686) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1370) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4940) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4518) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1170) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1059) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:667) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:592) at org.eclipse.equinox.launcher.Main.run(Main.java:1498) at org.eclipse.equinox.launcher.Main.main(Main.java:1471)

kdvolder commented 6 years ago

It seems to work fine for me. This is what I did step by step:

I also tried double-clicking on the 'class' and 'resource' nodes in the tree viewer. These didn't open anything, perhaps they should, but I never got an NPE in the error log.

I also tired opening the beans view from boot dash. I.e. via its 'properties page' by selecting the 'beans' tab. Double-click there doesn't seem to do anything (again, perhaps it should), but it didn't cause any errors.

I think we should probably look into why some of the double-click actions I tested don't actually open anything. We'd probably focus on fixing this in the view opend via boot dash as the other view is a 'legacy' view which is meant to be phased out and replaced with the boot-dash-integrated view.

However, since I've never seen any errors like the one you describe I'm not sure this has anything to do with your reported problem. So it would be nice if you can add further details that might help reproduce this error (e.g a detailed sequence of steps just like the one I posted here and/or a sample project (if you don't use a easy to recreate sample like a fresh app created from the wizard).

sonpth commented 5 years ago

So my setup is different: I have a Spring application deployed on Tomcat 8.5 and is connected to "Live Beans Graph" via JMX. As you can see from the screenshot below, the graph presents correctly what I have in my context. However when I double-click any node (say filterChains in the screenshot), it will yields a NullPointerException.

Selection_077

My STS Selection_078

My OS

Linux 4.20.0-042000-generic #201812232030 SMP Mon Dec 24 01:32:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

My log tail -f /home/user/workspace/bitbucket/.metadata/.log

!ENTRY org.eclipse.jface 4 2 2019-04-02 10:51:49.808
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NullPointerException
    at org.springframework.ide.eclipse.beans.ui.live.utils.JdtUtils.getJavaProject(JdtUtils.java:41)
    at org.springframework.ide.eclipse.beans.ui.live.utils.JdtUtils.getJavaType(JdtUtils.java:65)
    at org.springframework.ide.eclipse.beans.ui.live.model.TypeLookupImpl.findType(TypeLookupImpl.java:65)
    at org.springframework.ide.eclipse.beans.ui.live.actions.AbstractOpenResourceAction.openInEditor(AbstractOpenResourceAction.java:54)
    at org.springframework.ide.eclipse.beans.ui.live.actions.OpenBeanClassAction.run(OpenBeanClassAction.java:52)
    at org.springframework.ide.eclipse.beans.ui.livegraph.views.LiveBeansGraphView$1.doubleClick(LiveBeansGraphView.java:131)
    at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:833)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:47)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:176)
    at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:830)
    at org.eclipse.zest.core.viewers.GraphViewer.access$2(GraphViewer.java:1)
    at org.eclipse.zest.core.viewers.GraphViewer$2.mouseDoubleClick(GraphViewer.java:104)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:200)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5797)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5051)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4583)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:628)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:199)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1474)
kdvolder commented 5 years ago

So my setup is different: I have a Spring application deployed on Tomcat 8.5 and is connected to "Live Beans Graph" via JMX. As you can see from the screenshot below, the graph presents correctly what I have in my context. However when I double-click any node (say filterChains in the screenshot), it will yields a NullPointerException.

Okay, the detailed info about OS and such is somewhat useful. But really, what I need to reproduce this is some rather precise steps to set things up exactly as you did. So something like:

I am going to try to figure some of this out myself right now, but you are really making me guess a lot of the details here.

kdvolder commented 5 years ago

Here's how far I got:

Not sure what to do next to get a live bean graph for the running app.

kdvolder commented 5 years ago

Next steps that I figured out:

kdvolder commented 5 years ago

The NPE is caused by TypeLookupImpl which has a 'null' value for project. So basically it has no idea which project it should use as the scope to lookup the type. The error could easily be avoided with a 'null' check, but this, of course, will not solve the real problem (the type lookup will still not work). Proper solution needs to make sure the TypeLookupImpl receives the project associated with the deployed app somehow.

spring-projects-issues commented 5 years ago

(comment in Pivotal Tracker added by Kris De Volder:)

Fix pushed to master.

sonpth commented 5 years ago

I am going to try to figure some of this out myself right now, but you are really making me guess a lot of the details here.

Sorry, didn't plan to make your life more difficult. :(

I didn't mentioned that because it is quite standard, but here it is

a sample spring app configured in a similar way to yours.

It is just a standard Spring MVC with Spring security wrapping around it. The bean I clicked is the out-of-the box Spring security class. I will try to with a similar sample spring app when I have a chance.

steps to setup the tomcat server (I don't think STS 3 comes with Tomcat server out of the box, so you had to create the server instance somehow and start it up)

A standard tar version from Apache website, I added few additional options to setenv.sh

export JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8 -Xms128m -Xmx2048m -XX:MetaspaceSize=256m -Dlog4j.configuration=file:/home/user/tmp/log4j.xml"

export CATALINA_OPTS="-Dspring.liveBeansView.mbeanDomain -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false     -Djava.rmi.server.hostname=localhost -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

set of exact steps on how you deployed the app.

just drop the war file into the webapps folder

set of steps how you connected the app with JMX to livebean graph.

Selection_079

kdvolder commented 5 years ago

Thanks for extra details. Fortunately I was already able to reproduce the problem using the TcServer that is included by default in STS. Allthough the details of how I did things aren't quite the same as your description, I am fairly confident that the problem is fixed.

If you have the time you could confirm that the fix works for your situation by using a nightly distribution build, which you can download here:

http://dist.springsource.com/snapshot/STS/nightly-distributions.html

PS: For future reference, when it comes to 'sample' apps it best to actually attach a sample app rather than provide a general description. Yes, I could probably coble something together based on that description but, the point is, it will cost some time. Time I could otherwise spend on debugging and fixing the problem (or other problems). Also I would still be guessing about many details. These details may not matter... or they might. Anyhow... in the end, I think all is well since I think I was able to figure out and fix the problem already.