Arduino service wont start through IDE

Hi. I am simply having issue starting the Arduino service in mrl through Intellij on my  x64 intel cpu desktop PC.

My steps that led to the issue are as follows: 

  • I cloned  MRL through intellij using the url 
  • I ran the SwingGui service's main method,
  • I right clicked on the Arduino service in the SwingGui's service list and click start to start the Arduino service.
  • I get the error "createAndStart(arduino, org.myrobotlab.service.Arduino) java.lang.NullPointerException" at the bottom of the SwingGui window and the Arduino service doesnt start. 

I have already switched to the  Java 1.8  JDK in both my environment variables (path and JAVA_HOME) , and I have set the MRL nixie project in the IDE to use the 1.8 JDK. I have checked that running "java -version" in cmd returns 1.8  and that the IDE log shows that I am using 1.8 when I run any main method in the project, so it shouldnt be an issue of java version.  Manticore runs the Arduino service fine using the Jar.  However, trying to run the Arduino service in nixie in my IDE (either by the method above, or directly via Runtime.start("myarduino", "Arduino"); )  does not work and gives me a null pointer exception which is traced back to a failure of the Arduino service to create a Registration, at the point where the service is converted toJson.  I will share my code with you @Kwatters or @Grog, in case you want to inspect  the MRL package I have for cause of the issue. I tried pushing my new branch but git said remote permission was denied to my username.  

Ray.Edgley's picture

Raspberry Pi service

You need it to be running on the Raspberry Pi for this service to work.

Also check your version of Java

kwatters's picture

Share the full exception

Null pointers can come from anywhere. You need to share with us the full exception not the the type of exception. There is usually information about what line number caused the exception... That's very important.

That being said . You should be doing this testing as a unit test.. not just randomly launching some services main method.

Here is an old video that I did. Hopefully it helps.

GroG's picture

Hi Alex. Testing locally on

Hi Alex.
Testing locally on my system using SwingGui's main ... I get worky - I'm a little ahead of the latest Nixie, but I don't see any fixes locally that would be relevant.

You don't need permissions to do a pr - this is how most of my prs to other projects are done (I've done several against Apache Ivy)

The quickest way I suspect to get to the root of this is to see a noWorky

GroG's picture

Verified the latest Nixie

Verified the latest Nixie code works when  I download the jar

build 195 - mrl version 65

Alexinator40's picture

Hi Grog! So, thank for

Hi Grog! So, thank for testing the arduino service via the jar. It appears im only having issues with the ide clone. The jar version that I downloaded  an hour ago   is , however, the IDE clone, which i cloned an hour ago into a new directory,  is I used this url to clone today     Ive had no problem whatsoever getting the jar to run the arduino service (in both the web gui and swing gui) but still cant get the cloned ide version to create the arduino service either by running the swing gui service's main and clicking start on the arduino service in that swing gui list, or by adding "Runtime.start("arduino", "Arduino")"  to the swinggui. Ive also tried opening the arduino service by starting the swinggui service, then clicking on the web gui service and, then trying to start the Arduino service. In any case, any attempt to run the Arduino service via the IDE is not working. I want to post my error log so you can see exactly what is happening, but im not sure if it will format correctly in these comments. Perhaps its just that is the issue. Let me know what you think. 

Alexinator40's picture

  So, what i did was simply

So, what i did was simply add the line "Runtime.start("arduino", "Arduino");"  to the SwingGui service's main and then ran that.  No other code was added/edited/removed from the newly cloned project.  
runtime@r1 /]#
15:19:33.135 [main] INFO  c.myrobotlab.service.SwingGui - tabs size 0
15:19:33.135 [main] INFO  c.myrobotlab.framework.Service - subscribe [runtime/released ---> gui/removeTab]
15:19:33.136 [main] INFO  c.myrobotlab.framework.Service - subscribe [runtime/registered ---> gui/onRegistered]
15:19:33.138 [main] INFO  c.myrobotlab.framework.MethodCache - caching Welcome's 58 methods and 0 declared methods
15:19:33.138 [main] INFO  c.myrobotlab.framework.MethodCache - cached Welcome 58 methods with 58 ordinal signatures in 0 ms
15:19:33.304 [main] INFO  c.myrobotlab.service.SwingGui - buildTabPanels service count 3
15:19:33.314 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - caching SwingGuiGui's 67 methods and 11 declared methods
15:19:33.317 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - cached SwingGuiGui 67 methods with 67 ordinal signatures in 3 ms
15:19:33.433 [main] INFO  class org.myrobotlab.service.Runtime - Runtime.createService arduino
15:19:33.441 [main] INFO  c.myrobotlab.framework.Service - creating remote proxy service for id r1
15:19:33.451 [main] INFO  c.myrobotlab.framework.MethodCache - caching Arduino's 352 methods and 137 declared methods
15:19:33.455 [main] INFO  c.myrobotlab.framework.MethodCache - cached Arduino 352 methods with 319 ordinal signatures in 14 ms
15:19:33.456 [main] INFO  c.myrobotlab.framework.Service - found override resource dir src\main\resources\resource\Arduino
15:19:33.456 [main] INFO - src\main\resources\resource\Arduino\localization\ does not exist
15:19:33.456 [main] INFO  c.myrobotlab.framework.Service - found override resource dir src\main\resources\resource\Arduino
15:19:33.456 [main] INFO - src\main\resources\resource\Arduino\localization\ does not exist
15:19:33.457 [main] INFO  c.myrobotlab.framework.Service - found override resource dir src\main\resources\resource\Arduino
15:19:33.457 [main] INFO  c.myrobotlab.framework.Registration - creating registration for arduino@r1 - org.myrobotlab.service.Arduino
15:19:33.466 [main] ERROR class org.myrobotlab.service.Runtime - createService failed for arduino@null of type org.myrobotlab.service.Arduino
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_251]
at sun.reflect.NativeConstructorAccessorImpl.newInstance( ~[na:1.8.0_251]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( ~[na:1.8.0_251]
at java.lang.reflect.Constructor.newInstance( ~[na:1.8.0_251]
at org.myrobotlab.framework.Instantiator.getThrowableNewInstance( ~[classes/:na]
at org.myrobotlab.service.Runtime.createService( [classes/:na]
at org.myrobotlab.service.Runtime.create( [classes/:na]
at org.myrobotlab.service.Runtime.createAndStart( [classes/:na]
at org.myrobotlab.service.Runtime.start( [classes/:na]
at org.myrobotlab.service.SwingGui.main( [classes/:na]
Caused by: java.lang.NoClassDefFoundError: Lcom/pi4j/io/gpio/GpioPinDigitalMultipurpose;
at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_251]
at java.lang.Class.privateGetDeclaredFields( ~[na:1.8.0_251]
at java.lang.Class.getDeclaredFields( ~[na:1.8.0_251]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at ~[gson-2.8.5.jar:na]
at org.myrobotlab.codec.CodecUtils.toJson( ~[classes/:na]
at org.myrobotlab.framework.Registration.<init>( ~[classes/:na]
at org.myrobotlab.framework.Service.<init>( ~[classes/:na]
at org.myrobotlab.service.abstracts.AbstractMicrocontroller.<init>( ~[classes/:na]
at org.myrobotlab.service.Arduino.<init>( ~[classes/:na]
... 10 common frames omitted
Caused by: java.lang.ClassNotFoundException:
at ~[na:1.8.0_251]
at java.lang.ClassLoader.loadClass( ~[na:1.8.0_251]
at sun.misc.Launcher$AppClassLoader.loadClass( ~[na:1.8.0_251]
at java.lang.ClassLoader.loadClass( ~[na:1.8.0_251]
... 31 common frames omitted
15:19:33.467 [main] ERROR c.myrobotlab.framework.Service - runtime error createAndStart(arduino, Arduino) java.lang.NullPointerException
15:19:33.467 [main] ERROR class org.myrobotlab.service.Runtime - createAndStart(arduino, Arduino) java.lang.NullPointerException
java.lang.NullPointerException: null
at org.myrobotlab.service.Runtime.createAndStart( [classes/:na]
at org.myrobotlab.service.Runtime.start( [classes/:na]
at org.myrobotlab.service.SwingGui.main( [classes/:na]
15:19:33.602 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [gui@r1/publishStatus ---> gui/onStatus]
15:19:33.602 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [gui@r1/publishState ---> gui/onState]
15:19:33.623 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - caching RuntimeGui's 79 methods and 25 declared methods
15:19:33.624 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - cached RuntimeGui 79 methods with 78 ordinal signatures in 1 ms
15:19:33.661 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [runtime@r1/publishStatus ---> gui/onStatus]
15:19:33.661 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [runtime@r1/publishState ---> gui/onState]
15:19:33.775 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - caching SecurityGui's 60 methods and 4 declared methods
15:19:33.776 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.MethodCache - cached SecurityGui 60 methods with 60 ordinal signatures in 1 ms
15:19:33.778 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [security@r1/publishStatus ---> gui/onStatus]
15:19:33.778 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [security@r1/publishState ---> gui/onState]
Alexinator40's picture

Here is a link to pics of the

Here is a link to pics of the issues in my pom

GroG's picture

hmmm ... if their not

hmmm ...
if their not defined they should evaluete to "nothing" which should be fine ..

Apache Maven (the group that defined the pom) handles this without problem...
Is it just a linting problem in Intellij - or is it not building because of it ?

There has got to be a way to set env variables in Intellij

The reason they are there is because our Ci/Cd (Jenkins) passes the vars on each build.

Alexinator40's picture

Yea, there is a way to set

Yea, there is a way to set the environment variables. What variables do i need to set?  

GroG's picture

The ones you pointed out in

The ones you pointed out in the pom.xml file, if that is really an issue...

I'm not too familiar with intellj - otherwise I would be able to help more,

but I'm pretty sure "for whatever reason, your IDE is not correctly processing the pom.xml"
(usually this is maven under the hood)

Alexinator40's picture

Ahoy. So I got the arduino

Ahoy. So I got the arduino service running in the ide, but now im running into another issue that ive slowly tracked down. The Arduino service uses the Serial class , which  implements the JSSC library classes, to make a connection to the serial ports. Unforturnately, although maven has dowloaded the jssc dependency into my .m2 repository, the JSSC directory that the Serial class imports from is not found in my project directory.  Im not sure why this is the case, but my only guess was that perhaps there was supposed to be an additional step for maven to decompile the JSSC jar in the .m2 directory into the MRL project directory. Let me know what you think might be the issue here when you come back online. Thanks. 

kwatters's picture

try eclipse

all of this stuff magically just works fine in eclipse and with command line maven.  I suspect all of your issues are related to how the project was imported into intellij.  have you tried eclipse?  

There's not magic de-compiling..   the ".m2" directory is where maven caches the jar files that it downloads.  intellij will use the same one.

Alexinator40's picture

I'll try it out in Eclipse

I'll try it out in Eclipse and report back ;)