1

在从旧的 SmartGWT (2.5) 迁移到 SmartGWT 3.1 时,我们遇到了 TreeNode 类的问题。这是一个例外:

java.lang.ClassCastException: com.google.gwt.core.client.JavaScriptObject$ cannot be cast to java.util.List     
  at my.domain.gwt.client.documents.components.structure.dto.ArchiveTreeNode.getChildrens(ArchiveTreeNode.java:262)     
  at my.domain.gwt.client.documents.file_archive.folder_content.FolderContentList.showFolderContent(FolderContentList.java:1003)    
  at my.domain.gwt.client.documents.file_archive.FileArchive$17.onSuccess(FileArchive.java:607)     
  at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)     
  at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) 
  at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)    
  at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)   
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
  at java.lang.reflect.Method.invoke(Method.java:597)   
  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:338)  
  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)  
  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)  
  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)    
  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)  
  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:242)     
  at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)   
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
  at java.lang.reflect.Method.invoke(Method.java:597)   
  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:338)  
  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)  
  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)  
  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)    
  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:299)    
  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)  
  at com.google.gwt.user.client.Window.alert(Window.java)   
  at com.smartgwt.client.SmartGwtEntryPoint$1.onUncaughtException(SmartGwtEntryPoint.java:310)  
  at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:244)     
  at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)   
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
  at java.lang.reflect.Method.invoke(Method.java:597)   
  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:293)   
  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)     
  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)   
  at java.lang.Thread.run(Thread.java:662)

方法:

   public void setChildrens(List<ArchiveTreeNode> list) {
        if (list != null) {
            setAttribute(ArchiveElementDataSource.CHILDRENS, list);
        }
    }

    public List<ArchiveTreeNode> getChildrens() {
        return (List<ArchiveTreeNode>) getAttributeAsObject(ArchiveElementDataSource.CHILDRENS);
    }

应用程序很旧并且写得不好,但我们不能重写它(业务......)

ArchiveTreeNode 类扩展了 TreeNode。在我们的实现中,这个 get/set 方法没有什么特别之处。当用户单击树的任何节点(每次)时都会引发异常。

如何解决?

4

0 回答 0