获取" StatusCodeException"在尝试执行操作时

时间:2014-05-15 15:19:32

标签: gwt-rpc gwtp

我正在使用GWT / GWTP(2.6.0 / 1.2.1)。我正在尝试执行一个Action。动作本身只是一个信号(没有逻辑或数据元素)。结果应该带有DTO的ArrayList。 当我使用完全相同的设置与另一个动作(包含一个字符串),它工作正常。 我收到这个错误:

  

[错误] com.google.gwt.user.client.rpc.StatusCodeException:500 Server   错误服务器上的调用失败;请参阅服务器日志了解详情   [错误]在   com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)   [错误]在   com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:259)   [错误]在   com.google.gwt.http.client.RequestBuilder $ 1.onReadyStateChange(RequestBuilder.java:412)   [错误]在sun.reflect.NativeMethodAccessorImpl.invoke0(原生   方法)[ERROR] at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)   [错误]在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   java.lang.reflect.Method.invoke中的[错误](Method.java:606)[错误]     在   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:338)   [错误]在   com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)   [错误]在   com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)   [错误]在   com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)   [错误]在   com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)   [错误]在   com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)   [错误]在com.google.gwt.core.client.impl.Impl.apply(Impl.java)   [错误],电子邮件地址为com.google.gwt.core.client.impl.Impl.entry0(Impl.java:347)   [错误]在sun.reflect.GeneratedMethodAccessor51.invoke(未知   来源)[错误]在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   java.lang.reflect.Method.invoke中的[错误](Method.java:606)[错误]     在   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.reactToMessages(BrowserChannelServer.java:293)   [错误]在   com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)   [错误]在   com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)   [错误]在java.lang.Thread.run(Thread.java:744)

我想念什么? 我的行动看起来像这样:

package testproject.shared.dispatch;

import com.gwtplatform.dispatch.rpc.shared.UnsecuredActionImpl;

public class FetchDevicesAction extends UnsecuredActionImpl<FetchDevicesResult> {

    public FetchDevicesAction() {
    }


}

我的结果是这样的(问题出在哪里?):

package testproject.shared.dispatch;
import java.util.List;

//import org.apache.log4j.xml.DOMConfigurator;

import testproject.shared.dto.DeviceDto;

import com.allen_sauer.gwt.log.client.Log;
import com.gwtplatform.dispatch.rpc.shared.Result;


public class FetchDevicesResult implements Result {
    /**
     * 
     */
    private static final long serialVersionUID = -6478205044537244983L;
    private List<DeviceDto> deviceDtos;

    public FetchDevicesResult(List<DeviceDto> deviceDtos) {
        this.deviceDtos = deviceDtos;
    }

    public List<DeviceDto> getDeviceDtos() {
        return deviceDtos;
    }
}

以下是我的演示者的一部分:

public class DevicesPresenter extends
        Presenter<DevicesPresenter.MyView, DevicesPresenter.MyProxy> implements
        DevicesUiHandlers {
    Logger logger = Logger.getLogger("RootLogger");
    List<Device> devices = null;
    List<DeviceDto> deviceDtos = null;
    /**
     * {@link DevicesPresenter}'s proxy.
     */
    @ProxyCodeSplit
    @NameToken(NameTokens.devicesPage)
    @TabInfo(container = ApplicationPresenter.class, label = "Devices", priority = 1)
    // The third tab in the main page
    public interface MyProxy extends TabContentProxyPlace<DevicesPresenter> {
    }

    /**
     * {@link DevicesPresenter}'s view.
     */
    public interface MyView extends View, HasUiHandlers<DevicesUiHandlers> {
        CellTable<Device> getCellTable();
    }

    private DispatchAsync dispatcher;

    @Inject
    DevicesPresenter(EventBus eventBus, MyView view, MyProxy proxy,
            final DispatchAsync dispatcher) {
        super(eventBus, view, proxy, ApplicationPresenter.SLOT_SetTabContent);

        this.dispatcher = dispatcher;

        view.setUiHandlers(this);
    }
public void fetchDevicesTask() {
    FetchDevicesAction action = new FetchDevicesAction();
    Log.debug("Executing FetchDevices");
    dispatcher.execute(action, new AsyncCallbackImpl<FetchDevicesResult>() {            
        @Override           
        public void onSuccess(FetchDevicesResult result) {
            Log.debug("onSuccess");
            deviceDtos = result.getDeviceDtos();
        }

    });

}

共享库是我的gwt.xml的一部分。

我的DeviceDto:

package testproject.shared.dto;


import java.io.Serializable;


public class DeviceDto implements Serializable {

  private static final long serialVersionUID = 3434148714982575460L;

  protected Long DeviceId;
  protected String Image;
  protected String FirmwareVersion;

  public DeviceDto() {
    this.DeviceId = -1L;
  }

  public DeviceDto(Long DeviceId) {
    this.DeviceId = DeviceId;
  }

  public DeviceDto(Long DeviceId, String Image, String FirmwareVersion) {
      this.DeviceId = DeviceId;
      this.Image = Image;
      this.FirmwareVersion = FirmwareVersion;
  }

  public Long getDeviceId() {
    return DeviceId;
  }

  public void setDeviceId(Long DeviceId) {
    this.DeviceId = DeviceId;
  }

  public String getImage() {
    return Image;
  }

  public void setImage(String Image) {
    this.Image = Image;
  }

  public String getFirmwareVersion() {
    return FirmwareVersion;
  }

  public void setFirmwareVersion(String FirmwareVersion) {
    this.FirmwareVersion = FirmwareVersion;
  }

我的处理程序(尽管我认为它没有达到这个目的):

package testproject.server.dispatch;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.xml.DOMConfigurator;

import testproject.server.dao.DeviceDao;
import testproject.shared.dispatch.FetchDevicesAction;
import testproject.shared.dispatch.FetchDevicesResult;
import testproject.shared.domain.Device;
import testproject.shared.dto.DeviceDto;

import com.allen_sauer.gwt.log.client.Log;
import com.google.inject.Inject;
import com.gwtplatform.dispatch.rpc.server.ExecutionContext;
import com.gwtplatform.dispatch.shared.ActionException;

public class FetchDevicesHandler extends AbstractAction<FetchDevicesAction, FetchDevicesResult> {

    @Inject
    FetchDevicesHandler() {     
        super(FetchDevicesAction.class);
        DOMConfigurator.configure("log4j.xml");
    }

    @Override
    public FetchDevicesResult execute(FetchDevicesAction action, ExecutionContext context) throws ActionException {
        FetchDevicesResult result = null;
        DeviceDao deviceDao = new DeviceDao();

        Log.debug("Retrieve Devices");

        try {
          List<Device> devices = deviceDao.retrieveDevices();

          if (devices != null) {
            List<DeviceDto> deviceDtos = new ArrayList<DeviceDto>(devices.size());

            for (Device device : devices) {
                Log.debug("Adding Device to dto list: " + device.getDeviceId().toString());
              deviceDtos.add(createDeviceDto(device));
            }

            result = new FetchDevicesResult(deviceDtos);
          }
        }
        catch (Exception e) {
          Log.warn("Unable to retrieve Accounts - ", e);

          throw new ActionException(e);
        }

        return result;

    }
    private DeviceDto createDeviceDto(Device device) {
        return new DeviceDto(device.getDeviceId(), device.getImage(), device.getFirmwareVersion());
    }
}
  I googled and searched stackoverflow, but this error message seems not to happen anywhere else.

谢谢你的帮助:)     }

0 个答案:

没有答案