# GWT & MYSQL - Exception while dispatching incoming RPC call



## aaron_k (8. Mrz 2010)

Hallo Zusammen, 

bei dem Versuch, Daten aus einer Datenbank auszulesen, erhalte ich die folgende Fehlermeldung:



```
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.ExceptionInInitializerError
at com.google.gwt.i18n.client.DateTimeFormat.getDefaultDateTimeConstants(DateTimeFormat.java:628)
at com.google.gwt.i18n.client.DateTimeFormat.getFormat(DateTimeFormat.java:452)
at de.aaron.birthdayreminder.client.model.Entry.<init>(Entry.java:17)
at de.aaron.birthdayreminder.server.persistence.core.DataAccess.getUserEntriesFunction(DataAccess.java:45)
at de.aaron.birthdayreminder.server.persistence.EntriesDAOImpl.getUserEntries(EntriesDAOImpl.java:12)
at de.aaron.birthdayreminder.server.EntriesServiceImpl.entries(EntriesServiceImpl.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
... 22 more
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you 

are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:92)
at com.google.gwt.i18n.client.LocaleInfo.<clinit>(LocaleInfo.java:35)
... 33 more
[ERROR] 500 - POST /birthdayreminder/entries (127.0.0.1) 57 bytes
Request headers
  Host: 127.0.0.1:8888
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729)
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer: [url]http://127.0.0.1:8888/birthdayreminder/hosted.html?birthdayreminder[/url]
  X-GWT-Permutation: HostedMode
  X-GWT-Module-Base: [url]http://127.0.0.1:8888/birthdayreminder/[/url]
  Content-Type: text/x-gwt-rpc; charset=utf-8
  Content-Length: 157
  Pragma: no-cache
  Cache-Control: no-cache
Response headers
  Content-Type: text/plain
```



Der Fehler wird durch die folgende Methode verursacht:



```
public ArrayList<Entry> getUserEntriesFunction(long userid) {
	
	ArrayList<Entry> entries = new ArrayList<Entry>();

	try {

		ps = conn.prepareStatement("SELECT id, firstname, lastname, birthday, reminder FROM entries WHERE userid=?;");
		ps.setLong(1, userid);

		res = ps.executeQuery();

		while (res.next()) {
			Entry entry = new Entry(res.getLong("id"), res.getString("firstname"), res.getString("lastname"), res.getString("birthday"), res.getString("reminder"));
			entries.add(entry);
		}
		
		return entries;

	} catch (SQLException e) {
		e.printStackTrace();
		return null;
	} finally {
		closeSetAndStatement(res, ps);
	}

}
```


Die Methode wird serverseitig innerhalb der Klasse EntriesServiceImpl aufgerufen:


```
@Override
public ArrayList<Entry> entries(long userid) {
	
	final EntriesDAO entriesDAO = EntriesDAOFactory.getInstance();
	ArrayList<Entry> entries = entriesDAO.getUserEntries(userid);
	
	if(entries!=null) {
		return entries;
	} else {
		return null;
	}
}
```
 

AppEngine habe ich bereits unter Google -> App Engine Settings deaktiviert.

Hat jemand eine Idee, was die Ursache sein könnte? Bin für JEDEN Hinweis dankbar!

Gruß,
Aaron

Screenshot 
http://img62.imageshack.us/img62/4743/errorlz.jpg


----------



## stockhausen (9. Mrz 2010)

Was passiert, wenn du zunächst einmal die DateTimeFormat Exception validierst?


----------



## aaron_k (9. Mrz 2010)

@Stockhausen: Danke für deine Antwort!

Ich habe mittlerweile 'DateFormatException' validiert. Ich hatte auch vergessen, innerhalb der Klasse Entry 'Serializable' zu implementieren.

Ich erhalte mittlerweile die unten aufgeführte Fehlermeldung. Eventuell wird jemand schlau daraus. Ich bin noch am experimentieren.

Gruß,
Aaron



```
Starting Jetty on port 8888
   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:760)
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:723)
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:612)
	at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
	at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:609)
	at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:467)
	at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:564)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
	at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:742)
	... 30 more
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'de.aaron.birthdayreminder.client.model.Entry' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = de.aaron.birthdayreminder.client.model.Entry@6e7443
	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:610)
	at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
	at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:43)
	at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:36)
	... 35 more
[ERROR] 500 - POST /birthdayreminder/entries (127.0.0.1) 57 bytes
   Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729)
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
      Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 300
      Connection: keep-alive
      Referer: [url]http://127.0.0.1:8888/birthdayreminder/hosted.html?birthdayreminder[/url]
      X-GWT-Permutation: HostedMode
      X-GWT-Module-Base: [url]http://127.0.0.1:8888/birthdayreminder/[/url]
      Content-Type: text/x-gwt-rpc; charset=utf-8
      Content-Length: 157
      Pragma: no-cache
      Cache-Control: no-cache
   Response headers
      Content-Type: text/plain
```



Info: GWT Server Library Documentation | GWT Widget Library


----------



## aaron_k (9. Mrz 2010)

Lösung des Problems:  
http://www.extjs.com/forum/showthread.php?t=40944

Gruß,
Aaron


----------

