1

I have searched the Web almost for hours, but I didn't find an answer. The Problem is that i want to the test the gwt RPC. So I generate with the Eclipse Plugin a GWT remote Service. But everytime I get the following Failure: "[WARN] No file found for: /kuss_projekt/SpeicherService"

I have tryed a lot, but I dont knwo what is the Problem. Thats my Code:

web.xml:
<web-app>

<servlet>
    <servlet-name>SpeicherService</servlet-name>
    <servlet-class>de.fhdo.kuss.server.SpeicherServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>SpeicherService</servlet-name>
    <url-pattern>/kuss_projekt/SpeicherService</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
    <welcome-file>Kuss_Projekt.html</welcome-file>
</welcome-file-list>


</web-app>

-

Speicherservice:
@RemoteServiceRelativePath("SpeicherService")
public interface SpeicherService extends RemoteService {

String getName(String name);


public static class Util {
    private static SpeicherServiceAsync instance;
    public static SpeicherServiceAsync getInstance(){
        if (instance == null) {
            instance = GWT.create(SpeicherService.class);
        }
        return instance;
    }
}
}

-

SpeicherServiceAsync:
public interface SpeicherServiceAsync {

void getName(String name, AsyncCallback<String> callback);

}

-

SpeicherServiceImpl
public class SpeicherServiceImpl extends RemoteServiceServlet implements SpeicherService {

@Override
public String getName(String name) {
    return("Server meldet sich " + name);
}
}

-

Test():
    public void test() {
    AsyncCallback<String> callback = new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(String result) {
            Window.alert(result);
        }
    };

    SpeicherService.Util.getInstance().getName("test",callback);
}
ph09
  • 1,052
  • 2
  • 20
  • 31

2 Answers2

3

Have you tried removing /kuss_projekt from servlet mapping to make it:

<servlet-mapping>
    <servlet-name>SpeicherService</servlet-name>
    <url-pattern>/SpeicherService</url-pattern>
</servlet-mapping>

GWT client is expecting the service to be available at the URL defined via @RemoteServiceRelativePath. When you are running in browser, the path is resolved relative to your module base url. As you have given:

@RemoteServiceRelativePath("SpeicherService")

the client will make request to the URL made by concatenating

GWT.getModuleBaseURL() + "SpeicherService"

If your servlet is not mapped at this url, the request will fail. Try printing GWT.getModuleBaseURL()+ "SpeicherService" on console to see what is the base url in your test case. Once you have got this, open the browser and go to that url. If the response says something like "Get method is not supported" everything is mapped correctly. On the other hand if you get a 404 you got to fix your servlet mapping

Tahir Akhtar
  • 11,385
  • 7
  • 42
  • 69
  • Thank you for your help. It was automatically build by the plugin and so I think it have to be correct. I tried the request and get a 404 response. So I fixed my servlet mapping and now the Services has been found. But then I get the following Exception: [ERROR] [kuss_projekt] Line 6: No source code is available for type com.google.gwt.user.server.rpc.RemoteServiceServlet; did you forget to inherit a required module? But there I have got code. Whats wrong? Sry but I am new to this and have never been work with Servlets and this. – ph09 Jul 21 '11 at 13:05
  • @ph09, accept the answer and post a new question. At stackoverflow answers and comments are supposed to remain focused on a single question. – Tahir Akhtar Jul 21 '11 at 13:50
  • I still have the problem that I get this: [WARN] No file found for: /kuss_projekt/SpeicherService I am overextended... – ph09 Jul 21 '11 at 17:29
2

Does your application xml file contain

<module rename-to='kuss_projekt'>
maneesh
  • 1,692
  • 1
  • 14
  • 18
  • Thats in my Kuss_Projekt.gwt.xml file. What does this change? – ph09 Jul 21 '11 at 13:00
  • In my case it was a combination of this answer (.xml file contained a rename that had a case-sensitive mistake) and the answer above. – Mercious Sep 01 '16 at 12:12