2

我编写了自己的异常类型(从 java Exception 扩展)。我在 GWT 生成的类 xxx_FieldSerializer 上遇到了异常。错误消息如下所示:

    Object reference not set to an instance of an object.    
    com.xxx.shared.csharpsystem.exception.MyException_FieldSerializer   Method name : instantiate  LINE_NUMER : 16 
            com.xxx.shared.csharpsystem.exception.MyException_FieldSerializer   Method name : create  LINE_NUMER : 25 
            com.google.gwt.user.client.rpc.impl.SerializerBase   Method name : instantiate  LINE_NUMER : 115 
            com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader   Method name : deserialize  LINE_NUMER : 111 
            com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader   Method name : readObject  LINE_NUMER : 119 
            com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter   Method name : onResponseReceived  LINE_NUMER : 216 
            com.google.gwt.http.client.Request   Method name : fireOnResponseReceived  LINE_NUMER : 287 
            com.google.gwt.http.client.RequestBuilder$1   Method name : onReadyStateChange  LINE_NUMER : 395 
            sun.reflect.NativeMethodAccessorImpl   Method name : invoke0  LINE_NUMER : -2 
            sun.reflect.NativeMethodAccessorImpl   Method name : invoke  LINE_NUMER : 57 
            sun.reflect.DelegatingMethodAccessorImpl   Method name : invoke  LINE_NUMER : 43 
            java.lang.reflect.Method   Method name : invoke  LINE_NUMER : 601 
            com.google.gwt.dev.shell.MethodAdaptor   Method name : invoke  LINE_NUMER : 103 
            com.google.gwt.dev.shell.MethodDispatch   Method name : invoke  LINE_NUMER : 71 
            com.google.gwt.dev.shell.OophmSessionHandler   Method name : invoke  LINE_NUMER : 172 
            com.google.gwt.dev.shell.BrowserChannelServer   Method name : reactToMessagesWhileWaitingForReturn  LINE_NUMER : 337 
            com.google.gwt.dev.shell.BrowserChannelServer   Method name : invokeJavascript  LINE_NUMER : 218 
            com.google.gwt.dev.shell.ModuleSpaceOOPHM   Method name : doInvoke  LINE_NUMER : 136 
            com.google.gwt.dev.shell.ModuleSpace   Method name : invokeNative  LINE_NUMER : 561 
            com.google.gwt.dev.shell.ModuleSpace   Method name : invokeNativeObject  LINE_NUMER : 269 
            com.google.gwt.dev.shell.JavaScriptHost   Method name : invokeNativeObject  LINE_NUMER : 91 
            com.google.gwt.core.client.impl.Impl   Method name : apply  LINE_NUMER : -1 
            com.google.gwt.core.client.impl.Impl   Method name : entry0  LINE_NUMER : 213 
            sun.reflect.NativeMethodAccessorImpl   Method name : invoke0  LINE_NUMER : -2 
            sun.reflect.NativeMethodAccessorImpl   Method name : invoke  LINE_NUMER : 57 
            sun.reflect.DelegatingMethodAccessorImpl   Method name : invoke  LINE_NUMER : 43 
            java.lang.reflect.Method   Method name : invoke  LINE_NUMER : 601 
            com.google.gwt.dev.shell.MethodAdaptor   Method name : invoke  LINE_NUMER : 103 
            com.google.gwt.dev.shell.MethodDispatch   Method name : invoke  LINE_NUMER : 71 
            com.google.gwt.dev.shell.OophmSessionHandler   Method name : invoke  LINE_NUMER : 172 
            com.google.gwt.dev.shell.BrowserChannelServer   Method name : reactToMessages  LINE_NUMER : 292 
            com.google.gwt.dev.shell.BrowserChannelServer   Method name : processConnection  LINE_NUMER : 546 
            com.google.gwt.dev.shell.BrowserChannelServer   Method name : run  LINE_NUMER : 363 
            java.lang.Thread   Method name : run  LINE_NUMER : 722 

并且文件 MyException.java 的代码是:

   public class MyException extends Exception implements java.io.Serializable
    {
         public MyException ()
         {
              super();
         }

public MyException (String Exception, String StackTrace)
{
    super(Exception);
    if (!StackTrace.equals(""))
    {
        StackTraceElement[] xStackTraceElementColl = new StackTraceElement[1];

        String strDeclaringClass = "";
        String strMethodName = StackTrace;
        String strFileName = "";
        int iLineNo = 0;
        xStackTraceElementColl[0] = new StackTraceElement(strDeclaringClass, strMethodName, strFileName, iLineNo);
        this.setStackTrace(xStackTraceElementColl);
    }
}

}

我不知道为什么会这样。感谢您的帮助。

4

0 回答 0