HashMap argument type mismatch

334 views
Skip to first unread message

Palani

unread,
Oct 26, 2009, 1:21:44 AM10/26/09
to Google Web Toolkit
Hello,
I am in the process of converting from gwt 1.5 to 1.7.1 and
getting the following error
when I am trying to get a HashMap from the server.

Any idea why this might happen?
I am using JDK 1.6.0_13.

The request looks like

5|0|4|http://localhost:54002/Webclient/webclient/|
E2C9084EB9E82F1F373FDB40DF5D423D|
com.client.web.client.WebClientService|getPropertiesMapNew|1|2|3|4|0|


method Return Type shows as class java.util.HashMap

typeSignature is java.util.HashMap/962170901

customSerializar is class
com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer

args is [[1,["java.util.HashMap/962170901"],0,5], {XXX=xxxx}] looks
like in Method.invoke


public static void
com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serialize
(com.google.gwt.user.client.rpc.SerializationStreamWriter,java.util.HashMap)
throws com.google.gwt.user.client.rpc.SerializationException






=========================================================
Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException:
java.lang.IllegalArgumentException: argument type mismatch
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer
(ServerSerializationStreamWriter.java:690)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl
(ServerSerializationStreamWriter.java:659)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize
(ServerSerializationStreamWriter.java:593)
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:146)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue
(ServerSerializationStreamWriter.java:530)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass
(ServerSerializationStreamWriter.java:636)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl
(ServerSerializationStreamWriter.java:666)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize
(ServerSerializationStreamWriter.java:593)
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:146)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue
(ServerSerializationStreamWriter.java:530)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess
(RPC.java:441)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse
(RPC.java:529)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall
(RemoteServiceServlet.java:166)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost
(RemoteServiceServlet.java:86)
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.ContextHandlerCollection.handle
(ContextHandlerCollection.java:206)
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.BoundedThreadPool$PoolThread.run
(BoundedThreadPool.java:450)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
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:678)

Sudeep S

unread,
Oct 26, 2009, 1:49:11 PM10/26/09
to google-we...@googlegroups.com
 
2 quick questions.
 
1. are u using generics.
2. have all the objects of your hashmap implemented isSeriliazable or Serilizable interface.

Palani

unread,
Oct 26, 2009, 2:08:46 PM10/26/09
to Google Web Toolkit

Thanks for the reply.
(1) Yes, I am using generics.

(2) I am putting only String in the map

Below is how the code looks like



// method that gets the data from the server
public void getPropertiesMap {
AsyncCallback<HashMap<String, String>> callback = new
AsyncCallback<HashMap<String, String>>() {
public void onSuccess(HashMap<String, String> result) {

}
public void onFailure(Throwable caught) {
System.out.println(caught);

}

};
service.getPropertiesMap(callback);
}


// Method declartion in the service ( I tried without the
@gwt.typeArgs declaration also).

/**
* @gwt.typeArgs <HashMap<String, String>>
*/
HashMap<String, String> getPropertiesMap() throws
InvalidSessionException;


//Method declaration in ServiceAsync
void getPropertiesMap(AsyncCallback<HashMap<String, String>>
callback);




// Service Impl method

public HashMap<String, String> getPropertiesMap()
throws InvalidSessionException {
HashMap m = new HashMap();
m.put("XXX", "xxxx");
return m;
}




On Oct 26, 12:49 pm, Sudeep S <sudee...@gmail.com> wrote:
> 2 quick questions.
>
> 1. are u using generics.
> 2. have all the objects of your hashmap implemented isSeriliazable or
> Serilizable interface.
>
> On Mon, Oct 26, 2009 at 10:51 AM, Palani <pas...@gmail.com> wrote:
>
> > Hello,
> >        I am in the process of converting from gwt 1.5 to 1.7.1 and
> > getting the following error
> > when I am trying to get a HashMap from the server.
>
> > Any idea why this might happen?
> > I am using JDK 1.6.0_13.
>
> > The request looks like
>
> > 5|0|4|http://localhost:54002/Webclient/webclient/|
> > E2C9084EB9E82F1F373FDB40DF5D423D|<http://localhost:54002/Webclient/webclient/%7CE2C9084EB9E82F1F373FDB4...>

Sudeep S

unread,
Oct 26, 2009, 2:17:07 PM10/26/09
to google-we...@googlegroups.com
in your service impl you have not used a generic version of  hashmap.
try the below code
 
public HashMap<String, String> getPropertiesMap()
                       throws InvalidSessionException {
change from      HashMap m = new HashMap(); to       HashMap<String,String> m = new HashMap<String,String>();
                       m.put("XXX", "xxxx");
                       return m;
               }

Thanks
Sudeep

 

Palani

unread,
Oct 26, 2009, 9:21:22 PM10/26/09
to Google Web Toolkit
Sudeep,
I believe that the problem has been resolved now. The
problem was that I had the gwt-servlet.jar file in two different
locations. One in WEB_INF\lib folder and same copy in another folder
which was the main classpath.

This was causing the problem.

Thank you.


=========

On Oct 26, 1:17 pm, Sudeep S <sudee...@gmail.com> wrote:
> in your service impl you have not used a generic version of  hashmap.
> try the below code
>
> public HashMap<String, String> getPropertiesMap()
>                        throws InvalidSessionException {
> change from      *HashMap m = new HashMap(); to       HashMap<String,String>
> m = new HashMap<String,String>();
> *                       m.put("XXX", "xxxx");
> >                        *HashMap m = new HashMap();
> > *                       m.put("XXX", "xxxx");
> >                        return m;
> >                }
>
> > On Oct 26, 12:49 pm, Sudeep S <sudee...@gmail.com> wrote:
> > > 2 quick questions.
>
> > > 1. are u using generics.
> > > 2. have all the objects of your hashmap implemented isSeriliazable or
> > > Serilizable interface.
>
> > > On Mon, Oct 26, 2009 at 10:51 AM, Palani <pas...@gmail.com> wrote:
>
> > > > Hello,
> > > >        I am in the process of converting from gwt 1.5 to 1.7.1 and
> > > > getting the following error
> > > > when I am trying to get a HashMap from the server.
>
> > > > Any idea why this might happen?
> > > > I am using JDK 1.6.0_13.
>
> > > > The request looks like
>
> > > > 5|0|4|http://localhost:54002/Webclient/webclient/|<http://localhost:54002/Webclient/webclient/%7C>
Reply all
Reply to author
Forward
0 new messages