Hi:
I using GWT but it get a error(I want to GWT with JPA) :
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract void
org.kuoying.client.GreetingService.save(org.kuoying.client.RpcItem)'
threw an unexpected exception: java.lang.NullPointerException
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
378)
......................
souce code:
public class First implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
sendButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);
String textToServer = nameField.getText();
RpcItem ri = new RpcItem();
ri.setId(7);
ri.setUsername(textToServer);
greetingService.save(ri, new AsyncCallback() {
public void onFailure(Throwable caught)
{
Window.alert("Fail");
}
public void onSuccess(Object result) {
Window.alert("Success");
}
});
}
});
}
}
------------------------------------------
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
// String greetServer(String name) throws IllegalArgumentException;
void save(RpcItem ri);
}
----------------------------------------------
public interface GreetingServiceAsync {
void save(RpcItem ri, AsyncCallback callback);
}
--------------------------------------------
public class GreetingServiceImpl extends RemoteServiceServlet
implements
GreetingService {
private static final long serialVersionUID = 1L;
@Override
public void save(RpcItem ri) {
EntityManagerFactory emf;
EntityManager em = null;
try {
emf = Persistence.createEntityManagerFactory("oo");
em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(ri);
em.getTransaction().commit();
} finally {
em.close();
}
}
}
What can I do?? THX^^
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.