无法找到错误的根本原因(GWT-Umbrella Exception)

时间:2012-10-10 10:05:28

标签: java exception gwt

我正在构建一个登录应用程序。在点击按钮后,我每次都得到 Umbrella Exception ....无法找到根本原因。我提供代码和错误列表。请提供修复程序。使用 GWT-RPC


客户端 1. VinLog.java

package com.login.vinayak.client;

import com.google.gwt.core.client.EntryPoint;

public class VinLog implements EntryPoint {
    private GreetingServiceAsync GreetingService = (GreetingServiceAsync) GWT.create(GreetingService.class);
    public void onModuleLoad() {
        GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
            public void onUncaughtException(Throwable e) {
              Window.alert("uncaught: " +e.getMessage());
              Window.alert("uncaught: " + e.getMessage());
              String s = buildStackTrace(e, "RuntimeExceotion:\n");
              Window.alert(s);
              e.printStackTrace();
              System.out.println(e.getCause());
            }
        });
        RootPanel rootPanel = RootPanel.get();

        SimplePanel simplePanel = new SimplePanel();
        rootPanel.add(simplePanel, 0, 0);
        simplePanel.setSize("450px", "19px");

        Label lblLoginForm = new Label("LOGIN");
        lblLoginForm.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        simplePanel.setWidget(lblLoginForm);
        lblLoginForm.setSize("544px", "41px");

        Label lblUserName = new Label("User Name");
        rootPanel.add(lblUserName, 10, 124);

        Label lblPassword = new Label("Password");
        rootPanel.add(lblPassword, 10, 183);

        final TextBox textBox = new TextBox();
        textBox.setAlignment(TextAlignment.CENTER);
        rootPanel.add(textBox, 112, 114);
        textBox.setSize("139px", "18px");

        final PasswordTextBox passwordTextBox = new PasswordTextBox();
        rootPanel.add(passwordTextBox, 112, 173);
        passwordTextBox.setSize("139px", "18px");

        Button btnClickToEnter = new Button("Click to Enter");
        btnClickToEnter.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String j=textBox.getText();
                String k=passwordTextBox.getText();
                GreetingService.loginuser(j, k, new AsyncCallback<String>() {
                    public void onFailure(Throwable caught) {
                        Window.alert("welcome");
                        }
                    public void onSuccess(String result) {
                        Window.alert("try again");
                    }
                 });
            }
    });
        rootPanel.add(btnClickToEnter, 10, 229);

        final ListBox comboBox = new ListBox();
        comboBox.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                Object ob=comboBox.getElement(); 
                if(ob=="Guest") {
                    Window.alert("Username and Passowrd is: Guest007");
                }
            }               
        });
        comboBox.addItem("User");
        comboBox.addItem("Admin");
        comboBox.addItem("Guest");
        rootPanel.add(comboBox, 10, 51);
        comboBox.setSize("85px", "22px");

        Image image = new Image("home.gif");
        rootPanel.add(image, 310, 98);
        image.setSize("182px", "155px");
    }
    protected String buildStackTrace(Throwable t, String log) {
            if (t != null) {
                log += t.getClass().toString();
                log += t.getMessage(); 
                StackTraceElement[] stackTrace = t.getStackTrace();
                if (stackTrace != null) {
                  StringBuffer trace = new StringBuffer();

                  for (int i = 0; i < stackTrace.length; i++) {
                    trace.append(stackTrace[i].getClassName() + "." + stackTrace[i].getMethodName() + "("
                        + stackTrace[i].getFileName() + ":" + stackTrace[i].getLineNumber());
                  }
                  log += trace.toString();
                }
                Throwable cause = t.getCause();
                if (cause != null && cause != t) {
                  log += buildStackTrace(cause, "CausedBy:\n");
                }
              }
            return log;
    }
}

2.GreetingService.java

package com.login.vinayak.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@SuppressWarnings("unused")
public interface GreetingService extends RemoteService {
    public String loginuser(String username, String password);
}

3.GreetinServiceAsync.java

package com.login.vinayak.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface GreetingServiceAsync {
    public void loginuser(String username, String password, AsyncCallback<String> callback);
}

服务器端 ==&gt; GreetingServiceImpl.java

package com.login.vinayak.server;

import com.login.vinayak.client.GreetingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.sql.DriverManager;
import java.sql.ResultSet;
import com.google.gwt.dev.generator.ast.Statement;

public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService{
    private static final long serialVersionUID = 1L;

    public String loginuser(String username,String password) {
        try {
            java.sql.Connection con = null;
            Class.forName("org.hsqldb.jdbcDriver");
            con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/", "SA", "");
            Statement st=(Statement) con.createStatement();
            ResultSet rs=((java.sql.Statement) st).executeQuery("select username,password from lgfrm");
            String user=rs.getString(1);
            String pass=rs.getString(2);
            boolean b1=username.equals(user);
            boolean b2= password.equals(pass);
            if(b1==b2==true) {
            return "success";
            }
            }
    catch (Exception ae) {}
        return "Success";
    }
}

的web.xml

> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app  PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>   "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> <web-app> <servlet>
>       <servlet-name>GreetingServiceImpl</servlet-name>
>       <servlet-class>com.login.vinayak.server.GreetingServiceImpl</servlet-class>
> </servlet>    <servlet-mapping>
>       <servlet-name>GreetingServiceImpl</servlet-name>
>       <url-pattern>/Login</url-pattern>    </servlet-mapping>     <!-- Default page to serve -->  <welcome-file-list>
>       <welcome-file>VinLog.html</welcome-file>    </welcome-file-list>
> 
> </web-app>

错误列表

  

com.google.gwt.event.shared.UmbrellaException:一个或多个例外   抓住了,看看UmbrellaException中的全套#getCauses at   com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)     在com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)     在   com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)     在   com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)     在com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)     在com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)at   sun.reflect.GeneratedMethodAccessor33.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)     在   com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)     在   com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)     在   com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)     在   com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)     在   com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)     在   com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)     在   com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)     在   com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)     在com.google.gwt.core.client.impl.Impl.apply(Impl.java)at   com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)at at   sun.reflect.GeneratedMethodAccessor31.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)     在   com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)     在   com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

** * ** * ** * 的* 其他错误原因列表 * ** * ** * ** *

  

引起:   com.google.gwt.user.client.rpc.ServiceDefTarget $ NoServiceEntryPointSpecifiedException:   未指定服务实现URL   com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doPrepareRequestBuilderImpl(RemoteServiceProxy.java:430)     在   com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke(RemoteServiceProxy.java:368)     在   com.google.gwt.user.client.rpc.impl.RemoteServiceProxy $ ServiceHelper.finish(RemoteServiceProxy.java:74)     在   com.login.vinayak.client.GreetingService_Proxy.loginuser(GreetingService_Proxy.java:34)     在com.login.vinayak.client.VinLog $ 2.onClick(VinLog.java:82)at   com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)     在   com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)     在com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)at   com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)     在   com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)     在   com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)     在   com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)


向我提供FIX ...... TY

1 个答案:

答案 0 :(得分:2)

......你有它:Service implementation URL not specified...

你需要以某种方式告诉GWT RPC调用应该在后端的哪个位置。您可以使用服务接口上的注释@RemoteServiceRelativePath或在ServiceDefTarget实例(实际上是您的异步​​服务实例)上以编程方式执行此操作。

干杯,