gwt:这个伞例外的原因?

时间:2016-06-25 07:18:11

标签: exception gwt nullpointerexception

在我的项目中,我正在使用gwt和libary gwt-connectors 2.4 ..下面的代码抛出一个NullPointer-Exception,如果有人可以帮我找到这个异常的原因,那就太好了!我该如何解决?

public class Projekt implements EntryPoint {

    private RootPanel rootPanel;
    Image img;
    Shape shapei;
    Connector con;
    Widget connected;
     Image logo;
     Image logo2;


    public void onModuleLoad() {

        rootPanel = RootPanel.get("gwtContainer");
        rootPanel.setSize("1902", "868");

         final AbsolutePanel boundaryPanel = new AbsolutePanel();
         boundaryPanel.setStyleName("frame1");
         boundaryPanel.setSize("1455px", "600px");       

         final Diagram diagram = new Diagram(boundaryPanel);

         RootPanel.get().add(boundaryPanel, 446, 242);

         Button la = new Button("Push");
         la.setSize("200", "200");
         boundaryPanel.add(la);

         Button la2 = new Button("Push2");
         la2.setSize("200", "200");
         boundaryPanel.add(la2);

         Image img2 = new Image("images/variable.svg");
         img2.setSize("200", "200");
         boundaryPanel.add(img2, 200,200);

         final Shape shapei2 = new Shape(img2);
         shapei2.showOnDiagram(diagram);

         la.addClickHandler(new ClickHandler(){

            @Override
            public void onClick(ClickEvent event) {
                 img = new Image("images/concrete.svg");
                 img.setSize("200", "200");
                 boundaryPanel.add(img, 200,200);


                 boundaryPanel.add(img, 100,100);
                  Shape shapei = new Shape(img);
                 shapei.showOnDiagram(diagram);

            }}

         );
         la2.addClickHandler(new ClickHandler(){

                @Override
                public void onClick(ClickEvent event) {
                    con = new Connector(100, 300, 300, 500);
                     con.showOnDiagram(diagram);
                }

             });
         diagram.addDiagramListener(new DiagramListener(){
         public void onElementConnect(ElementConnectEvent event) {
             if (con.startEndPoint.isGluedToConnectionPoint()) {
                connected = con.startEndPoint.gluedConnectionPoint.parentWidget;
                 if(connected.equals(shapei.connectedWidget)){//line 97, think here is the problem
               logo = new Image("images/xor.svg");
               logo.setSize("100", "100");
               boundaryPanel.add(logo);
             }
                 else if(connected.equals(shapei2.connectedWidget)){ 
                      logo2 = new Image("images/and.svg");
                   logo2.setSize("100", "100");
                   boundaryPanel.add(logo2);
                 };
           }}

        @Override
        public void onConnectorClick(ConnectorClickEvent event) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onConnectorDoubleClick(ConnectorDoubleClickEvent event) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onDiagramAdd(DiagramAddEvent event) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onDiagramRemove(DiagramRemoveEvent event) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onElementDrag(ElementDragEvent event) {
            // TODO Auto-generated method stub

        }




});
         }}

这是日志:

09:11:25.249 [ERROR] [projekt] Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: Exception caught: null
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: null
    at com.exa.projekt.client.Projekt$3.onElementConnect(Projekt.java:97)
    at pl.tecna.gwt.connectors.client.Diagram.onElementConnect(Diagram.java:421)
    at pl.tecna.gwt.connectors.client.elements.EndPoint.glueToConnectionPoint(EndPoint.java:71)
    at pl.tecna.gwt.connectors.client.drop.DiagramWidgetDropController.onDrop(DiagramWidgetDropController.java:57)
    at com.allen_sauer.gwt.dnd.client.PickupDragController.dragEnd(PickupDragController.java:130)
    at com.allen_sauer.gwt.dnd.client.MouseDragHandler.drop(MouseDragHandler.java:529)
    at com.allen_sauer.gwt.dnd.client.MouseDragHandler.onMouseUp(MouseDragHandler.java:277)
    at com.google.gwt.event.dom.client.MouseUpEvent.dispatch(MouseUpEvent.java:56)
    at com.google.gwt.event.dom.client.MouseUpEvent.dispatch(MouseUpEvent.java:1)
    at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
    at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
    at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
    at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案