Casting problems with Google Maps API - java

I'm trying to run the following line:
Directions.loadFromWaypoints((Waypoint[])waypoints.toArray(), opts);
But I'm getting:
23:41:44.595 [ERROR] [carathome] Uncaught exception escaped
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.google.gwt.maps.client.geocode.Waypoint;
at com.presasystems.gwt.carathome.client.widgets.MostrarLinhasPanel$1$1.onSuccess(MostrarLinhasPanel.java:72)
at com.presasystems.gwt.carathome.client.widgets.MostrarLinhasPanel$1$1.onSuccess(MostrarLinhasPanel.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Unknown Source)
Why? Shouldn't this cast work? How can I do this in an elegant fashion?
Thanks in advance

Try
Directions.loadFromWaypoints((Waypoint[])(waypoints.toArray()), opts);
Alternatively
Waypoint[] array = new Waypoint[0];
array = waypoints.toArray(array);
Directions.loadFromWaypoints(array, opts);
Or more simply
Waypoint[] array = waypoints.toArray(new Waypoint[0]);
Directions.loadFromWaypoints(array, opts);
See also List#toArray(T[] a).
Addendum: Initially, I thought your cast was a precedence problem. The generic parameter T in List#toArray(T[] a) eliminates the need for an explicit cast by ensuring that the "runtime type of the returned array is that of the specified array." In effect, it "acts as bridge between array-based and collection-based APIs."

Related

How to fix Minecraft 1.12 Null pointer exception error with entities?

I've been trying to fix it for ages, im stumped, everytime i open it it crashes with the same error message "java.lang.NullPointerException", heres the full error message:
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from The Human Tools Mod (sword)
Caused by: java.lang.NullPointerException
at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:207)
at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:192)
at com.example.examplemod.init.EntityInit.registerEntity(EntityInit.java:18)
at com.example.examplemod.init.EntityInit.registerEntities(EntityInit.java:13)
at com.example.examplemod.util.handlers.RegistryHandler.preInitRegistries(RegistryHandler.java:62)
at com.example.examplemod.util.ExampleMod.preInit(ExampleMod.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
at net.minecraft.client.Minecraft.init(Minecraft.java:513)
at net.minecraft.client.Minecraft.run(Minecraft.java:421)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:25)**
as well as some of my code:
the code that is trying to register the entity:
public class EntityInit
{
public static void registerEntities()
{
registerEntity("human", EntityHuman.class, ExampleMod.ENTITY_HUMAN, 50, 3093151, 16287108);
}
private static void registerEntity(String name, Class<? extends Entity> entity, int id, int range, int color1, int color2 )
{
EntityRegistry.registerModEntity(new ResourceLocation("sword:" + name), entity, name, id, ExampleMod.instance, range, 1, true, color1, color2);
}
}
I had the same issue. I debugged it and found it to be caused by what I assume is a version mismatch between class net.minecraftforge.fml.common.network.NetworkRegistry and enum net.minecraftforge.fml.relauncher.Side.
Side has 3 values but the NetworkRegistry code appears to assume there are only 2, CLIENT and SERVER.
I fixed this by taking a copy of the NetworkRegistry class, and editing it as follows:
In the private, parameterless constructor, add the following line:
channels.put(Side.BUKKIT, Maps.<String,FMLEmbeddedChannel>newConcurrentMap());
Code change
Then you just need to make sure that your version of the class in on the classpath before the original version (if you're using eclipse then it will be automatically). You also need to make sure that you use the exact same package name for your version of the class.

Java WebStart java.lang.NullPointerException at java.awt.Window.getWindows

i'm currently attaching to a java webstart application (anything from here: https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/index.html#security) using the Java Attach API.
That works without problems, but now i want to iterate over all available Frames using
for (Frame f : java.awt.Frame.getFrames())
But this results in
java.lang.NullPointerException
at java.awt.Window.getWindows(Unknown Source)
at java.awt.Window.getWindows(Unknown Source)
at java.awt.Frame.getFrames(Unknown Source)
at com.asc.screen.scan.javascan.javascanagent.util.GuiWalkerTexasRanger.walkGui(GuiWalkerTexasRanger.java:151)
at com.asc.screen.scan.javascan.javascanagent.ComponentRegistry.initialScan(ComponentRegistry.java:124)
at com.asc.screen.scan.javascan.javascanagent.ComponentRegistry.init(ComponentRegistry.java:76)
at com.asc.screen.scan.javascan.javascanagent.JavaScanAgent.loadFilter(JavaScanAgent.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
...
Maybe i'm missing something here, but shouldn't it be possible to access all frames within the applet? This method works fine for non applet applications.
The problem is that the error is thrown inside the java code, so there is no way for me to avoid or handle this nullpointer, and i'm not getting any frames back.
Thanks in advance.

Java - Casting typed list to array

This is my method
public AuctionItem[] getOpenAuctions() throws RemoteException {
return itemList.toArray((AuctionItem[]) java.lang.reflect.Array
.newInstance(itemList.getClass(), itemList.size()));
}
and this is my error
Exception in thread "main" java.lang.ClassCastException: [Ljava.util.LinkedList; cannot be cast to [LAuction.AuctionItem;
at Auction.AuctionImpl.getOpenAuctions(AuctionImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getOpenAuctions(Unknown Source)
at Seller.SellerMain.main(SellerMain.java:38)
What's wrong with it?
Try:
return itemList.toArray(new AuctionItem[itemList.size()]);
The problem with the code you wrote is that itemList.getClass() returns the class LinkedList. So the Array.newInstance() method is creating a LinkedList[], which you are then trying to typecast to an AuctionItem[]. Since these two types are incompatible for assignment, it throws a ClassCastException.
itemList.getClass() returns LinkedList.class, because it is a LinkedList. itemList.peek().getClass() would fix this, but only if the list has at least one element.
Why not just:
public AuctionItem[] getOpenAuctions() {
return itemList.toArray(new AuctionItem[itemList.size()]);
}

GWT strange serialization exception

I have application that calculates 9 statistictics that are stored in complex data structures as HashMap<String, TreeMap<String, Integer>> or even more complex. Every statistic implements interface IStatistic. Results are stored in List<IStatistic> and its size (for largest example) is 3.5MB (I have serialized it manually and put it to the file). When I send results to client sometimes (usually when data size goes over 1.5MB, i.e. when is less than some limit exception does not occur) strange exception occurs and it is never in same place..
I have read and tried every similar solution to the problem that I found here and at GWT official page like:
" https://developers.google.com/web-toolkit/doc/latest/tutorial/RPC
http://stackoverflow.com/questions/2122798/gwt-occasional-com-google-gwt-user-client-rpc-serializationexception
did you check
http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html#serialize
the article says: It has a default (zero argument) constructor with
any access modifier (e.g. private Foo(){} will work) I'm allways
forgetting zeroargument const. when I am making a serializable object
:D "
but nothing really helped. Also tried to debug it but it breaks down somewhere in GWT source and I can't see the source. It is interesting that for smaller data samples everything goes smooth.
I am using GWT 2.4.0. without appengine.
Does anyone had similar problem or has some advice to deal with this?
Here are some example exceptions:
FIRST EXAMPLE:
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:221)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Caused by: com.google.gwt.user.client.rpc.SerializationException: 2AS (6)
at com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:153)
at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:114)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:111)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.deserialize(Map_CustomFieldSerializerBase.java:38)
at com.google.gwt.user.client.rpc.core.java.util.TreeMap_CustomFieldSerializer.deserialize(TreeMap_CustomFieldSerializer.java:36)
at com.google.gwt.user.client.rpc.core.java.util.TreeMap_FieldSerializer.deserial(TreeMap_FieldSerializer.java:15)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.deserialize(Map_CustomFieldSerializerBase.java:39)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.deserialize(HashMap_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_FieldSerializer.deserial(HashMap_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM1Result_FieldSerializer.deserialize(StatisticM1Result_FieldSerializer.java:29)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM1Result_FieldSerializer.deserial(StatisticM1Result_FieldSerializer.java:51)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_FieldSerializer.deserial(ArrayList_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:214)
... 26 more
SECOND EXAMPLE:
com.google.gwt.dev.shell.HostedModeException: Something other than an int was returned from JSNI method '#com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt()': JS value of type string, expected int
at com.google.gwt.dev.shell.JsValueGlue.getIntRange(JsValueGlue.java:266)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:144)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeInt(ModuleSpace.java:247)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeInt(JavaScriptHost.java:75)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.readInt(ClientSerializationStreamReader.java)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.readString(ClientSerializationStreamReader.java:104)
at com.google.gwt.user.client.rpc.core.java.lang.String_CustomFieldSerializer.instantiate(String_CustomFieldSerializer.java:37)
at com.google.gwt.user.client.rpc.core.java.lang.String_FieldSerializer.create(String_FieldSerializer.java:11)
at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:111)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:34)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_CustomFieldSerializer.deserialize(TreeSet_CustomFieldSerializer.java:36)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_FieldSerializer.deserial(TreeSet_FieldSerializer.java:15)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.deserialize(Map_CustomFieldSerializerBase.java:39)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.deserialize(HashMap_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_FieldSerializer.deserial(HashMap_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at hr.fer.zesoi.metals.shared.statistic.IStatisticResult_FieldSerializer.deserialize(IStatisticResult_FieldSerializer.java:13)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM2Result_FieldSerializer.deserialize(StatisticM2Result_FieldSerializer.java:22)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM2Result_FieldSerializer.deserial(StatisticM2Result_FieldSerializer.java:40)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_FieldSerializer.deserial(ArrayList_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:214)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
THIRD EXAMPLE:
java.lang.NullPointerException
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:35)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_CustomFieldSerializer.deserialize(TreeSet_CustomFieldSerializer.java:36)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_FieldSerializer.deserial(TreeSet_FieldSerializer.java:15)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.deserialize(Map_CustomFieldSerializerBase.java:39)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.deserialize(HashMap_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_FieldSerializer.deserial(HashMap_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at hr.fer.zesoi.metals.shared.statistic.IStatisticResult_FieldSerializer.deserialize(IStatisticResult_FieldSerializer.java:13)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM4Result_FieldSerializer.deserialize(StatisticM4Result_FieldSerializer.java:44)
at hr.fer.zesoi.metals.shared.statistic.result.StatisticM4Result_FieldSerializer.deserial(StatisticM4Result_FieldSerializer.java:66)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:34)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_FieldSerializer.deserial(ArrayList_FieldSerializer.java:19)
at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:113)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:214)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
For the first error, this almost certainly indicates that your server and client fell out of sync, and have a different view of what can be serialized and deserialized. Clearing the browser cache, or making sure that the server is running the same code as the client ( by redeploying to the server if running from google's appengine server, or restarting if running locally). From the string "2AS" it looks like you might be obfuscating type names - consider disabling that feature until you get this worked out for sure.
Second error:
com.google.gwt.dev.shell.HostedModeException: Something other than an int was returned from JSNI method '#com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt()': JS value of type string, expected int
at com.google.gwt.dev.shell.JsValueGlue.getIntRange(JsValueGlue.java:266)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:144)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeInt(ModuleSpace.java:247)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeInt(JavaScriptHost.java:75)
Fortunatly, this is a known issue in Chrome+Dev mode. It will not occur in other browsers, and it will not occur in Chrome in web mode. Using a different browser is the easiest way to avoid this - any code which runs a lot of JSNI code (any RPC code for example) will eventually run into this.
java.lang.NullPointerException
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:35)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_CustomFieldSerializer.deserialize(TreeSet_CustomFieldSerializer.java:36)
at com.google.gwt.user.client.rpc.core.java.util.TreeSet_FieldSerializer.deserial(TreeSet_FieldSerializer.java:15)
This is occurring in this code:
#SuppressWarnings("unchecked")
public final class Collection_CustomFieldSerializerBase {
public static void deserialize(SerializationStreamReader streamReader,
Collection instance) throws SerializationException {
int size = streamReader.readInt();
for (int i = 0; i < size; ++i) {
Object obj = streamReader.readObject();
instance.add(obj); //line 35
}
}
This suggests that obj is null at that line, and that you are maybe adding some null object to the TreeSet (within the TreeMap I'd imagine). Might be worth setting a breakpoint in that class, conditional on obj being null to establish if that is why, and if so, how to nail it down.

faultString: java.lang.IllegalArgumentException: argument type mismatch

I am trying to give web service call using Axis genrated stub.
It is running giving below exception when it tryies to get respons.
and when i view my response message using :
String responseMsg = stub._getCall().getMessageContext().getResponseMessage().getSOAPEnvelope().toString();
System.out.println(responseMsg);
it is giving the correct response in SOAP format. can anybody help me where it is creating issue thanks in Advance.
Zuned
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.IllegalArgumentException: argument type mismatch
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.IllegalArgumentException: argument type mismatch
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:157)
at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.hps.webservice.SOAPInterfaceBindingStub.getStatus(SOAPInterfaceBindingStub.java:852)
at com.hps.ws.HPSStatusManagerJob.getApplicationStatusResponse(HPSStatusManagerJob.java:265)
at com.hps.ws.HPSStatusManagerJob.updateStatus(HPSStatusManagerJob.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.utils.BeanPropertyDescriptor.set(BeanPropertyDescriptor.java:142)
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:75)
... 22 more
{http://xml.apache.org/axis/}hostname:admin-PC
java.lang.IllegalArgumentException: argument type mismatch
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:2470)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.hps.webservice.SOAPInterfaceBindingStub.getStatus(SOAPInterfaceBindingStub.java:852)
at com.hps.ws.HPSStatusManagerJob.getApplicationStatusResponse(HPSStatusManagerJob.java:265)
at com.hps.ws.HPSStatusManagerJob.updateStatus(HPSStatusManagerJob.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:157)
at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
... 14 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.utils.BeanPropertyDescriptor.set(BeanPropertyDescriptor.java:142)
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:75)
... 22 more
one more way to generate file as in my case axis 1.4 was not working because of compatibility issue(not sure what it is). we can use wsimport.exe inbuilt in jdk to generate stub
go to your jdk bin folder and run command wsimport -s destinationPath WSDL path
as:
C:\Program Files\Java\jdk1.6.0\bin>wsimport -s C:\sid\ http://?WSDL
after that copy paste generated folder structure and classes
The Problem was the local WSDL was not updated so I first updated the local WSDL and then genrated the classes once again .
:)

Categories