1

我正在eclipse上开发一个GWT项目,当我运行开发模式时一切正常。但是当我在我的 tomcat 服务器上部署 WAR 文件(按照本指南单击http://localhost:8080/myproj/生成)时,只显示一个空白页面。我试图添加Window.alert("..")onModuleLoad()方法中的第一行,它确实显示正确。清除浏览器缓存是没有用的。服务器启动执行没有问题也没有异常。我应该怎么做才能解决这个问题?

这是我的入口点类

public class Segnalazioni_Degrado implements EntryPoint {

protected static List<Macrocategoria> listaMacrocategorie;
protected static List<Segnalazione> segnalazioniAttiveCached = new ArrayList<Segnalazione>();
protected static List<SegnalazioneRisolta> segnalazioniRisolteCached = new ArrayList<SegnalazioneRisolta>();

protected static final DataLayerServiceAsync dataLayerService = GWT
        .create(DataLayerService.class);
protected static final LoginServiceAsync loginService = GWT
        .create(LoginService.class);
protected static final MailServiceAsync mailService = GWT
        .create(MailService.class);

protected static Properties props;
private final String TITOLO = "PORTALE SEGNALAZIONI DEGRADO";

private LatLng romaLatLng;

private DockLayoutPanel mainPnl;

private HorizontalPanel northPnl;
private HorizontalPanel southPnl;
private VerticalPanel westPnl;
private AbsolutePanel centerPnl;

protected static StatsPanel statsPnl;
protected static MenuPanel menuPnl;
protected static LoginPanel loginPnl;
protected static LegendPanel legendPnl;

protected static MapWidget map;
private Label titoloLbl;
private/* Button */FocusWidget areaRiservataBtn;
private Button followUsOnTwitterBtn;
private HTML mailto;

/**
 * TODO tweet segnalazione inserita o risolta, porta su .css tutto il
 * possibile, prendi tutto da config, fai log su server, crea mail, leggenda
 * icone, elimina file foto non solo link
 */

public void onModuleLoad() {
    loadProps();
    buildUI();
}

void loadProps() {
    props.set("scarsa manutenzione manto stradale", "images/red.png");
    props.set("veicolo abbandonato", "images/red.png");
    props.set("discarica abusiva", "images/green.png");
    props.set("accumulo spazzatura", "images/green.png");
}

void buildUI() {
    Maps.loadMapsApi("", "2", false, new Runnable() {
        public void run() {
            buildHomePage();
        }
    });
}

private void buildHomePage() {

    mainPnl = new DockLayoutPanel(Unit.PCT);
    mainPnl.setStyleName("mainPanel");
    northPnl = new HorizontalPanel();
    northPnl.setStyleName("northPanel");
    southPnl = new HorizontalPanel();
    southPnl.setStyleName("southPanel");
    westPnl = new VerticalPanel();
    westPnl.setStyleName("westPanel");
    centerPnl = new AbsolutePanel();
    centerPnl.setStyleName("centerPnl");

    loginPnl = new LoginPanel();
    statsPnl = new StatsPanel();
    menuPnl = new MenuPanel();

    Segnalazioni_Degrado.dataLayerService
    .getListaMacrocategorie(new AsyncCallback<List<Macrocategoria>>() {

        @Override
        public void onFailure(Throwable caught) {
            caught.printStackTrace();
        }

        @Override
        public void onSuccess(List<Macrocategoria> result) {

            Segnalazioni_Degrado.listaMacrocategorie = result;
            centerPnl.add(new LegendPanel());
        }

    });


    /**
     * costruisco la Google Map
     */
    Size mapSize = Size.newInstance(500, 500);
    MapOptions mapOpts = MapOptions.newInstance();
    mapOpts.setSize(mapSize);
    romaLatLng = LatLng.newInstance(41.8902624, 12.4923096);
    map = new MapWidget(romaLatLng, 12, mapOpts);
    map.checkResizeAndCenter();
    map.setSize("99%", "99%");
    map.addControl(new LargeMapControl());
    map.setDoubleClickZoom(true);
    map.setScrollWheelZoomEnabled(true);
    map.setStyleName("map");

    /**
     * costruisco il titolo del portale
     */
    titoloLbl = new Label(TITOLO);
    titoloLbl.setStyleName("titolo");

    /**
     * costruisco bottone per accedere ad area riservata
     */
    /* areaRiservataBtn = new Button("Accedi all'area riservata"); */
    areaRiservataBtn = new Button("AREA RISERVATA");
    areaRiservataBtn.setStyleName("bottomBtn");
    areaRiservataBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            new AreaRiservataDialog();
        }
    });

    /**
     * costruisco bottone twitter
     */

    followUsOnTwitterBtn = new Button();

    followUsOnTwitterBtn.addStyleName("bottomBtn");
    followUsOnTwitterBtn.addStyleName("twitter");


    followUsOnTwitterBtn
            .getElement()
            .appendChild(
                    new HTML(
                            "<div><img src=images/twitter.gif><b>segui @stop_degrado</b></div>")
                            .getElement());
    followUsOnTwitterBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Window.open("https://twitter.com/stop_degrado", "_blank", "");
        }

    });

    /**
     * costruisco bottone mailto
     */
    mailto = new HTML("<a href=mailto:dummy@fake.foo> Contattaci </a>");
    mailto.setStyleName("bottomBtn");

    /**
     * creo bottone ABOUT US
     */
    Button aboutus = new Button("ABOUT US");
    aboutus.setStyleName("bottomBtn");
    aboutus.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            new AboutUsPopup();
        }

    });



    northPnl.add(titoloLbl);
    northPnl.add(loginPnl);

    westPnl.add(menuPnl);

    westPnl.add(statsPnl);

    southPnl.add(followUsOnTwitterBtn);
    southPnl.add(aboutus);
    southPnl.add(areaRiservataBtn);
    southPnl.add(mailto);

    centerPnl.add(map);


    mainPnl.addNorth(northPnl, 8);
    mainPnl.addWest(westPnl, 30);
    mainPnl.addSouth(southPnl, 3.5);
    mainPnl.add(centerPnl);

    RootLayoutPanel.get().add(mainPnl);

    MenuPanel.refreshBtn.click();

}
}
4

1 回答 1

1

我认为这是一个NullPointer

protected static Properties props; // << NULL

public void onModuleLoad() {
    loadProps(); // props is still NULL
    buildUI();
}

void loadProps() {
    // props is still NULL
    props.set("scarsa manutenzione manto stradale", "images/red.png"); // BANG!
[...]

顺便说一句:你为​​什么要制作props静态的?您的入口点只有一个实例。所以不能共享任何状态。

于 2013-09-07T21:10:08.263 回答