开发者

GWT/JAVA Uncaught exception escaped

I have got a problem with my code and i cant seem to fix it. I want to add some customer data to a array list in java/GWT when submitting a button.

the form from which i add the data.

ok.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (!voornaamTB.getText().equalsIgnoreCase("") && !achternaamTB.getText().equalsIgnoreCase("") && !emailTB.getText().equalsIgnoreCase("") && !geboortedatumTB.getText().equalsIgnoreCase("")) {
                boolean addVG;
                System.out.println(voornaamTB.getText());
                System.out.println(tussenvoegselTB.getText());
                System.out.println(achternaamTB.getText());
                System.out.println(emailTB.getText());
                System.out.println(geboortedatumTB.getText());
--> the error is generated here addVG = VGC.addVakantieganger(voornaamTB.getText(), tussenvoegselTB.getText(), achternaamTB.getText(), emailTB.getText(), geboortedatumTB.getText());
                if (addVG) {
                    Window.alert("Vakantieganger toegevoegd.");
                } else {
                    Window.alert("Vakantieganger niet toegevoegd.");
                }
            } else {
                voornaamTB.addStyleName("invalide-TextBox");
                tussenvoegselTB.开发者_高级运维addStyleName("invalide-TextBox");
                achternaamTB.addStyleName("invalide-TextBox");
                emailTB.addStyleName("invalide-TextBox");
                geboortedatumTB.addStyleName("invalide-TextBox");
            }
        }
    });

the controller class.

import java.util.ArrayList;

import com.vakantievibes.client.domein.Vakantieganger;

public class VakantiegangerController {
    private String msg;
    private ArrayList<Vakantieganger> vakantiegangers = new ArrayList<Vakantieganger>();

    public VakantiegangerController(){

    }

@SuppressWarnings("static-access")
public boolean heeftVakantieganger(String email) {
    boolean result = false;
    for (Vakantieganger v : vakantiegangers) {
        if (v.getEmail().equalsIgnoreCase(email)){
            result = true;
        }
    }
    return result;
}

public boolean addVakantieganger(String voornaam, String tussenvoegsel, String achternaam, String email, String geboortedatum) {
    //boolean result = false;

    //if (!heeftVakantieganger(email)) {
        Vakantieganger v = new Vakantieganger(voornaam, tussenvoegsel, achternaam, email, geboortedatum);
        vakantiegangers.add(v);
        boolean result = true;
        System.out.println("klant toegevoegd");
    //}
        return result;
    }

}

with the methode addVakantieganger it should add the data to the arraylist. but it doesn't seem to do that it should then report true back to the form. the !heeftVakantieganger(email) should check if the person is already in the array list but is disabled now for testing purpose's

the errors i recieve in eclipse.

14:17:03.207 [ERROR] [vakantie_vibes] Uncaught exception escaped

com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:124)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:172)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1321)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1277)
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:167)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    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:214)
    at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:167)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.NullPointerException: null
    at com.vakantievibes.client.GUI.FormToevoegenVakantieganger$8.onClick(FormToevoegenVakantieganger.java:153)
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
    at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
    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:124)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:172)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1321)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1277)
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:167)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    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:214)
    at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    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:167)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:679)


You get a NullPointerException. This happens because you are using a reference which is null. In your case this is one of the fields in the line that you marked.

Use a debugger, put a breakpoint on that line, and inspect which field in null.


Since you use all the variables, only VGC can be null at this time.

But I suspect this is a class name. My first guess is that the type VGC is part of the server API and not of the client API or something along these lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜