单击按钮时发生UmbrellaException [英] UmbrellaException when button is clicked

查看:93
本文介绍了单击按钮时发生UmbrellaException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GWT,当我单击创建类的按钮时,我收到UmbrellaException. 这是有问题的代码:

guys I am working with GWT and when I click a button which creates a class I receive an UmbrellaException. Here is the problematic code:

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来源:

The exception appears when I click the oneMoreButton. Here is the getPerson source:

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");
        }

    }

ploymentLeader和Reviewer类相同,但名称不同,以便于处理.这是他们的代码:

The diplomaLeader and the Reviewer class are the same but with different names for easier treatment. This is their code:

    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) ;
    }

}

一切都是自动生成的.我对集合不太满意,所以问题可能出在构造函数中.

Everything is autogenerated. I am not verry good with collections so maybe the problem is comming from the constructor.

错误日志:

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)

推荐答案

@ malkoto1,您在评论中提供的代码段并不表明评论者正在初始化.

@malkoto1, the code snippet you've provided in comment doesn't show that Reviewers is being initialized.

Reviewers = new HashSet<Reviewer>();

请确保您已正确初始化审阅者,并且在第190行不为空.

Please make sure that you've intialized Reviewers properly & it's not null at line 190.

这篇关于单击按钮时发生UmbrellaException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆