开发者

Error 404 during GWT RPC jetty server

I just written simple RPC call, when i tried i get the below error, could you please help me out to fix this..

[WARN] 404 - POST /com.sribalajiele.gwt.client.SriBalajiEle/e开发者_运维知识库mailRpcService (127.0.0.1) 
Email Failure404 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 NOT_FOUND</title>

The code like below.

/*
 * Copyright (c) Balaji electricals AG 2011, All Rights Reserved
 */
package com.sribalajiele.gwt.client.client;

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

/**
 * @author kdel.
 * This interface provides Email Service.
 *
 */
@RemoteServiceRelativePath("emailRpcService")
public interface EmailRpcService extends RemoteService {

   public WriteToUsForm sendEmail(WriteToUsForm writeToUsForm) throws IllegalArgumentException;
}


/*
 * Copyright (c) Balaji electricals 2011, All Rights Reserved
 */
package com.sribalajiele.gwt.client.client;

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

/**
 * @author kdel
 * Async service for Email.
 */
public interface EmailRpcServiceAsync {
   void sendEmail(WriteToUsForm writeToUsForm, AsyncCallback<WriteToUsForm> asyncCallback)
   throws IllegalArgumentException;
}


public final class EmailRpcServiceImpl extends RemoteServiceServlet implements EmailRpcService {

   /**
    * Default serialVersionUID.
    */
   private static final long serialVersionUID = 1L;

   @Override
   public WriteToUsForm sendEmail(WriteToUsForm writeToUsForm) throws IllegalArgumentException  {  
          System.out.println("send Email called");
    }
}

In web.xml:

<servlet>
    <servlet-name>emailService</servlet-name>
    <servlet-class>com.sribalajiele.gwt.client.server.EmailRpcServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>emailService</servlet-name>
    <url-pattern>sriBalajiEle/emailRpcService</url-pattern>
</servlet-mapping>


Finally i could correct my self, may be this is use full for others.

1) @RemoteServiceRelativePath("emailRpcService")
public interface EmailRpcService extends RemoteService {

2) In *Module*.gwt.xml
<servlet class="com.sribalajiele.ui.server.EmailRpcServiceImpl" path="/emailRpcService"/>

3) Register your servlet in web.xml
<servlet>
        <servlet-name>eamilService</servlet-name>
        <servlet-class>com.sribalajiele.ui.server.EmailRpcServiceImpl</servlet-class>
    </servlet>
    <servlet-mapping> 
        <servlet-name>eamilService</servlet-name> 
        <url-pattern>/com.sribalajiele.ui.SriBalaji/emailRpcService</url-pattern> 
    </servlet-mapping>

4) Usage:

  final EmailRpcServiceAsync emailRpcServiceAsync = (EmailRpcServiceAsync) GWT.create(EmailRpcService.class);
      ServiceDefTarget serviceDef = (ServiceDefTarget) emailRpcServiceAsync;
      serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "emailRpcService");
emailRpcServiceAsync.sendEmail(parameter, new AsyncCall()) {
onSuccess() { }
onFailure() { }
}

Hope this will help...


The problem is that you have the servlet mapped to /sriBalajiEle/emailRpcService, but the request is being sent to /com.sribalajiele.gwt.client.SriBalajiEle/emailRpcService. The URL that the request is being sent to is generated by GWT in the form /${moduleName}/relativePath. If you include the following at the top of your GWT module, it should fix the 404.

<module rename-to="sriBalajiEle">


1) Include annotatation in your interface too.

@RemoteServiceRelativePath("emailRpcService")
public interface EmailRpcServiceAsync {
   void sendEmail(WriteToUsForm writeToUsForm,

AsyncCallback asyncCallback) throws IllegalArgumentException; }

2) And change your url mapping to the following.

    <url-pattern>com.sribalajiele.gwt.EmailRpcService/emailRpcService</url-pattern>

For my case, url mapping gave me headache for hours. Hope this helps.


the 404 error will site a url, I had to make sure the url sited in the 404 message was the url in my web.xml

<servlet-mapping>
    <servlet-name>messageServiceImpl</servlet-name>
    <url-pattern>/com.mbe.site.main/message</url-pattern>
</servlet-mapping>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜