单击按钮时出现UmbrellaException

时间:2012-04-16 11:08:37

标签: java eclipse gwt smartgwt

伙计们我正在使用GWT,当我点击一个创建类的按钮时,我收到了一个UmbrellaException。 这是有问题的代码:

private void addPerson(){
        final HashSet<Date> dates = new HashSet();

        HorizontalPanel horizontalPanel = new HorizontalPanel();
        HorizontalPanel buttonsPanel = new HorizontalPanel();

        final TextItem textBox = new TextItem();
        textBox.setTitle("Name");

        DynamicForm form = new DynamicForm();

        final ListBox listBox = new ListBox();
        listBox.addItem("DiplomaManager");
        listBox.addItem("Reviewer");
        //listBox.setVisibleItemCount(2);

        DatePicker datePicker = new DatePicker();
        datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
              public void onValueChange(ValueChangeEvent<Date> event) {
                  dates.add(event.getValue());
                  SC.say(event.getValue().toString() + " Added to unavailable dates ");
              }
            });

        Button oneMoreButton = new Button("One More");
        oneMoreButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {

                //SC.say(listBox.getValue(0));
                getPerson(dates,textBox,listBox);
                RootPanel.get("mainDiv").clear();
                addPerson();
            }

        });

        Button back = new Button("Back");
        back.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                RootPanel.get("mainDiv").clear();
                onModuleLoad();
            }               
        });

        Button next = new Button("Next");
        next.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                RootPanel.get("mainDiv").clear();
                addDiploma();

            }           
        });

        form.setFields(textBox);

        horizontalPanel.add(form);
        horizontalPanel.add(datePicker);
        horizontalPanel.add(listBox);


        buttonsPanel.add(oneMoreButton);
        buttonsPanel.add(back);
        buttonsPanel.add(next);

        RootPanel.get("mainDiv").add(horizontalPanel);
        RootPanel.get("mainDiv").add(buttonsPanel);
    }

单击oneMoreButton时会出现异常。 这是getPerson来源:

private void getPerson(HashSet<Date> set, TextItem box, ListBox list){
        if(list.getSelectedIndex()==0){
            DiplomaLeader leader = new DiplomaLeader(box.getValueAsString(), set);
            DiplomaLeaders.add(leader);
        }else if(list.getSelectedIndex()==1){
            Reviewer reviewer = new Reviewer(box.getValueAsString(), set);
            Reviewers.add(reviewer);
        }else {
            SC.say("Error accured :) Maybe nothing was entered");
        }

    }

diplomaLeader和Reviewer类是相同的,但名称不同,以便于治疗。这是他们的代码:

    package org.elsys.salvation.client;

import java.util.Date;
import java.util.HashSet;

public class Reviewer {
    private String name;
    private HashSet<Date> unavailableDates;

    public Reviewer(String name, HashSet<Date> unavailableDates) {
        super();
        this.name = name;
        this.unavailableDates = unavailableDates;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public HashSet<Date> getUnavailableDates() {
        return unavailableDates;
    }

    public void setUnavailableDates(HashSet<Date> unavailableDates) {
        this.unavailableDates.addAll(unavailableDates) ;
    }

}

一切都是自动生成的。我对收集不太好,所以问题可能来自构造函数。

错误日志:

16:10:12.218 [ERROR] [Salvation] 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.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
    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 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:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    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:213)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: null
    at org.elsys.salvation.client.Salvation.getPerson(Salvation.java:190)
    at org.elsys.salvation.client.Salvation.access$2(Salvation.java:184)
    at org.elsys.salvation.client.Salvation$5.onClick(Salvation.java:145)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:96)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.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.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
    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 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:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    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:213)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)

2 个答案:

答案 0 :(得分:1)

你的UmbrellaException的相关部分是:

Caused by: java.lang.NullPointerException: null
    at org.elsys.salvation.client.Salvation.getPerson(Salvation.java:190)

您在第190行引用的对象为空。

答案 1 :(得分:1)

@ malkoto1,您在评论中提供的代码段并未显示正在初始化审核者

即。 Reviewers = new HashSet<Reviewer>();

请确保您已正确初步确定审核人员&amp;在第190行它不是空的。