ActiveMQMessageConsumer dispatch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQMessageConsumer dispatch

Juleian
Hello,

I used ActiveMQ to send JSON Strings form a publisher to a subscriber via
Topic "iCASA".
Eventhough the message is published and also received by the subscriber,
theres an error message showing up I do not undertsand. I tired to google
the problem but without any concrete hints. This error message is showing up
every time a message is received:

PM org.apache.activemq.ActiveMQMessageConsumer dispatch
SCHWERWIEGEND: ID:LAPTOP-65SHJU9S-56930-1508417075291-0:1:1:1 Exception
while processing message: java.lang.RuntimeException: Failed to invoke
public org.apache.activemq.command.ActiveMQDestination() with no args
java.lang.RuntimeException: Failed to invoke public
org.apache.activemq.command.ActiveMQDestination() with no args
        at
com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:111)
        at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:206)
        at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116)
        at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216)
        at com.google.gson.Gson.fromJson(Gson.java:879)
        at com.google.gson.Gson.fromJson(Gson.java:844)
        at com.google.gson.Gson.fromJson(Gson.java:793)
        at com.google.gson.Gson.fromJson(Gson.java:765)
        at
de.mannheim.wifo2.fesas.sasStructure.data.adaptationLogic.knowledge.KnowledgeRecord.getData(KnowledgeRecord.java:61)
        at logicElements.monitor.Monitor.callLogic(Monitor.java:130)
        at logicElements.monitor.Monitor$3.onMessage(Monitor.java:211)
        at
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:967)
        at
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:122)
        at
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:192)
        at
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
        at
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.InstantiationException
        at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at
com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:108)
        ... 18 more

The String das is sent is similar to this:

{"Tulips_1":{"Zone":"Tulips","PresenceSensor":false,"Thermometer":289,"Illuminance":1146,"CO2-Level":400,"CO-Level":440,"FloodSensor":true},"Roses_1":{"Zone":"Roses","PresenceSensor":true,"Thermometer":290,"Illuminance":214,"CO2-Level":300,"CO-Level":430,"FloodSensor":true}}

Do somebody know what the error means?

Best regards,

Julian




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQMessageConsumer dispatch

Tim Bain
>
> java.lang.RuntimeException: Failed to invoke
> public org.apache.activemq.command.ActiveMQDestination() with no args
> java.lang.RuntimeException: Failed to invoke public
> org.apache.activemq.command.ActiveMQDestination() with no args
>

This error message means that Gson is trying to deserialize an
ActiveMQDestination object but doesn't know how to because it doesn't have
a constructor that takes no arguments. Of course, your code isn't supposed
to be deserializing objects of that time, so the real question is why
that's happening.

        at

> com.google.gson.internal.ConstructorConstructor$3.construct(
> ConstructorConstructor.java:111)
>         at
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(
> ReflectiveTypeAdapterFactory.java:206)
>         at
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(
> ReflectiveTypeAdapterFactory.java:116)
>         at
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(
> ReflectiveTypeAdapterFactory.java:216)
>         at com.google.gson.Gson.fromJson(Gson.java:879)
>         at com.google.gson.Gson.fromJson(Gson.java:844)
>         at com.google.gson.Gson.fromJson(Gson.java:793)
>         at com.google.gson.Gson.fromJson(Gson.java:765)
>

Gson code is being invoked. Did you manually configure a
serializer/unserializer? (In Jackson, you'd make an ObjectMapper that knew
how to serialize and deserialize, but I've not used Gson so I'm not sure
how it works.) If so, might you have configured something about it
incorrectly?


>         at
> de.mannheim.wifo2.fesas.sasStructure.data.adaptationLogic.knowledge.
> KnowledgeRecord.getData(KnowledgeRecord.java:61)
>

Is this your code, or at least code to which you have the source? What is
it doing? Also, what text is being passed to Gson.fromJson()? If you have
this source, you can use a debugger to answer that question; if not, set a
breakpoint on the fromJson() method (for which the source code is
definitely available) and look at the value of the passed argument. I
suspect you'll find it contains more content than just the JSON you listed
below.


>         at logicElements.monitor.Monitor.callLogic(Monitor.java:130)
>         at logicElements.monitor.Monitor$3.onMessage(Monitor.java:211)
>

How about these two methods? Are they yours? What are they doing? How are
they turning an ActiveMQMessage into text that is getting passed to the
Gson.fromJson() method?


>         at
> org.apache.activemq.ActiveMQMessageConsumer.dispatch(
> ActiveMQMessageConsumer.java:967)
>         at
> org.apache.activemq.ActiveMQSessionExecutor.dispatch(
> ActiveMQSessionExecutor.java:122)
>         at
> org.apache.activemq.ActiveMQSessionExecutor.iterate(
> ActiveMQSessionExecutor.java:192)
>         at
> org.apache.activemq.thread.PooledTaskRunner.runTask(
> PooledTaskRunner.java:122)
>         at
> org.apache.activemq.thread.PooledTaskRunner$1.run(
> PooledTaskRunner.java:43)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
>         at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.InstantiationException
>         at
> sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(
> InstantiationExceptionConstructorAccessorImpl.java:48)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>         at
> com.google.gson.internal.ConstructorConstructor$3.construct(
> ConstructorConstructor.java:108)
>         ... 18 more
>

None of the code in this final block is relevant to your problem.


> The String das is sent is similar to this:
>
> {"Tulips_1":{"Zone":"Tulips","PresenceSensor":false,"
> Thermometer":289,"Illuminance":1146,"CO2-Level":400,"CO-
> Level":440,"FloodSensor":true},"Roses_1":{"Zone":"Roses","
> PresenceSensor":true,"Thermometer":290,"Illuminance"
> :214,"CO2-Level":300,"CO-Level":430,"FloodSensor":true}}
>

What do you get when you call Gson.fromJson() on this input string?

Tim
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQMessageConsumer dispatch

Juleian
Thanks for the externsive answer, it lead me to the write part of the code.
The error was I passed the JMS message to a method but needed to convert it
to a string before.




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html