HEADS-project / training

Training material to get started with the HEADS technologies
10 stars 16 forks source link

java.lang.NoSuchMethodError: org.kevoree.api.Port.send #75

Closed kgiannakakisATC closed 9 years ago

kgiannakakisATC commented 9 years ago

I am trying to send a message through a kevoree port and I am getting the following message. What could be wrong?

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.kevoree.library.java.command.UpdateCallMethod.execute(UpdateCallMethod.java:54)
        at org.kevoree.core.impl.deploy.KevoreeSeqDeployPhase.runPhase(KevoreeSeqDeployPhase.kt:43)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:79)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.executeStep(PrimitiveCommand
ExecutionHelper.kt:91)
        at org.kevoree.core.impl.deploy.PrimitiveCommandExecutionHelper.execute(PrimitiveCommandExec
utionHelper.kt:44)
        at org.kevoree.core.impl.KevoreeCoreBean.internal_update_model(KevoreeCoreBean.java:408)
        at org.kevoree.core.impl.KevoreeCoreBean$UpdateModelRunnable.run(KevoreeCoreBean.java:166)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoSuchMethodError: org.kevoree.api.Port.send(Ljava/lang/Object;)V
        at gr.atc.heads.Sender.update(Sender.java:46)
        ... 25 more
maxleiko commented 9 years ago

Did you clean your project before running it ?

mvn clean install kev:run instead of just mvn kev:run

kgiannakakisATC commented 9 years ago

I am not sure I've cleaned it. I can't do that now, because I am away from my office. I will do so at the afternoon and let you know.

kgiannakakisATC commented 9 years ago

Cleaning didn't help. The code I am trying is available at:

https://github.com/kgiannakakisATC/training/tree/master/3.Wrapping_ThingML_into_Kevoree/3.3_Contrib/ATC

maxleiko commented 9 years ago

Yes, you need to use Kevoree v5.2.5 not 5.1.4, I have made many fixes after Tutorial 1 and 2.

This changes the API of the send() method.
You will have to call it with at least a null callback:

    @Start
    public void start() {
        Log.info("Sender starts");
        timer.send("", null);
    }
kgiannakakisATC commented 9 years ago

Thanks, that was the problem. However, for everything to work smoothly, I had to use this code:

timer.send("{\"message\" : \"timer_start\", \"delay\" : 5000}", null);

(Manually creating the json message ThingML components expect)

maxleiko commented 9 years ago

Yes, it is the component job, so that's the right way to do it. Well you could improve it by creating a POJO for your message and then use a JSON serializer to serialize it to string before send. But manually is alright in a tutorial I guess.