[GWT] StatusCodeException: Unable to find/load mapped servlet class

2 respostas
lucascaton

Pessoal,

Estou aprendendo GWT e tentando chamar um método do server-side usando o RPC. Porém, tenho recebido o seguinte erro:
com.google.gwt.user.client.rpc.StatusCodeException:
Unable to find/load mapped servlet class 'br.com.sclink.server.PessoaServiceImpl'
A parte relevante do meu App.gwt.xml é
<module>

      <!-- ... -->
      <!-- Server-side code.-->
      <servlet path="/service" class="br.com.sclink.server.PessoaServiceImpl"/>
      <!-- ... -->

</module>
Minha classe PessoaServiceImpl:
package br.com.sclink.server;

import br.com.sclink.client.PessoaService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class PessoaServiceImpl extends RemoteServiceServlet implements PessoaService{

	public String getIdAndName(){
		return "teste";
	}

}
Minha interface PessoaService:
package br.com.sclink.client;

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

@RemoteServiceRelativePath("/service")
public interface PessoaService extends RemoteService{

	public String getIdAndName();

}
Minha interface PessoaServiceAsync:
package br.com.sclink.client;

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

public interface PessoaServiceAsync{

	public void getIdAndName(AsyncCallback<String> callback);

}
Finalmente, no meu módulo que renderiza as coisas (classe App):
package br.com.sclink.client;

import com.extjs.gxt.ui.client.event.*;
import com.extjs.gxt.ui.client.widget.*;
import com.extjs.gxt.ui.client.widget.button.*;
import com.extjs.gxt.ui.client.widget.layout.*;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public class App implements EntryPoint{
	
	private PessoaServiceAsync pessoaService;
	private AsyncCallback<String> callback1;

	public PessoaServiceAsync getPessoaSvc(){
	    if(pessoaService == null){
	    	pessoaService = (PessoaServiceAsync) GWT.create(PessoaService.class);
	    }
	    return pessoaService;
	}

	public void onModuleLoad(){

		final ContentPanel panel = new ContentPanel();
		panel.setCollapsible(false);
		panel.setFrame(true);
		panel.setHeading("Aplicação de teste");
		panel.setLayout(new FitLayout());
		panel.setSize("100%", "100%");

		LayoutContainer c = new LayoutContainer();
		c.setStyleAttribute("backgroundColor", "white");
		c.setBorders(true);
		c.setSize("100%", "100%");
		
		Button button = new Button("Ok", new SelectionListener<ButtonEvent>(){
			@Override
			public void componentSelected(ButtonEvent ce){
				getPessoaSvc().getIdAndName(callback1);
			}
		});

		c.add(button);		
		panel.add(c);
		
		RootPanel.get().add(panel);

		// Set up the callback object
		callback1 = new AsyncCallback<String>(){

			public void onFailure(Throwable caught){
				System.out.println("[x] "+caught.toString());
			}

			public void onSuccess(String result){
				System.out.println("Success!");
				MessageBox.alert("result", result, null);
			}

		};

	}

}

[size=14]Alguém sabe o que pode ser?[/size]

Obrigado!

2 Respostas

RichardNatal

Lucas, estou tendo o mesmo problema… Você conseguiu resolver o seu?

lucascaton

Cara, eu resolvi, mas sinceramente não me lembro como fiz.
Faz um tempo já que não programo em Java (estou desenvolvendo em Ruby on Rails).

Eu criei um grupo para ajudar que trabalha com GXT (GWT + EXT):
http://groups.google.com/group/gxt-br

Entra lá e pergunta que o pessoal te ajuda!

Abraço.

Criado 9 de março de 2009
Ultima resposta 6 de jul. de 2009
Respostas 2
Participantes 2