Null pointer exception when adding a new user



  • Hi,
    I successfully set up MyController on a Raspberry Pi 3 B, connected to MySensors network through MQTT gateway.

    I'm trying to add a news user for MQTT, just to avoid using admin user in MQTT gateway configuration.

    Every time I try to add a new user, I get a null pointer exception.
    The complete error log is:

    2017-11-07 11:57:17,468 ERROR [Acme.Utils.ThreadPool(5)-PooledThread: Acme.Serve.Serve$ServeConnection@1fd0f5d] [org.mycontroller.standalone.api.jaxrs.exception.mappers.ApplicationExceptionMapper:42] ApplicationException,
    org.jboss.resteasy.spi.ApplicationException: java.lang.NullPointerException: userId
    	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:152)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
    	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
    	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
    	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
    	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    	at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40)
    	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2328)
    	at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2282)
    	at Acme.Serve.Serve$ServeConnection.run(Serve.java:2054)
    	at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.NullPointerException: userId
    	at org.mycontroller.standalone.api.jaxrs.model.AllowedResources.<init>(AllowedResources.java:33)
    	at org.mycontroller.standalone.api.jaxrs.model.AllowedResources$AllowedResourcesBuilder.build(AllowedResources.java:34)
    	at org.mycontroller.standalone.db.tables.User.getAllowedResources(User.java:86)
    	at org.mycontroller.standalone.db.tables.User.toString(User.java:47)
    	at java.lang.String.valueOf(String.java:2994)
    	at java.lang.StringBuilder.append(StringBuilder.java:131)
    	at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:137)
    	at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:458)
    	at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:328)
    	at org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl.create(BaseAbstractDaoImpl.java:244)
    	at org.mycontroller.standalone.api.jaxrs.model.UserJson.createOrUpdateUser(UserJson.java:74)
    	at org.mycontroller.standalone.api.jaxrs.SecurityHandler.addUser(SecurityHandler.java:184)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:497)
    	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
    	... 15 common frames omitted```

  • ADMIN

    @daniele What version of MyController are you using? I remember I fixed this issue already, could you please confirm it with SNAPSHOT version?

    If you face this issue on SNAPSHOT version, could you please open an issue?



  • I'm using version 1.0.0.Final from https://www.mycontroller.org/#/downloads
    It's my first time with MyController, and I'm not really an expert... so please be patient!
    Should I move to snapshot version? Is it stable enough for "not so expert" user like me?
    What's the easier way to upgrade?

    Thanks a lot
    Daniele


  • ADMIN

    @daniele steps to upgrade from one version to another version https://forum.mycontroller.org/topic/206/upgrade-to-new-version

    It's my first time with MyController, and I'm not really an expert... so please be patient!

    Welcome to MyControler 🙂
    No worries. I will setup locally and verify this. Thank you!


  • MOD

    @daniele

    Hi Daniele, welcome!!

    I use the snapshot version for a couple of weeks now, it works like a charm and is very stable......👍



  • I moved to version 1.1.0 snapshot, but I still have the same issue with user creation.


  • MOD

    @daniele

    What if you install the snapshot in a new directory with a clean database...
    do you still have the issue?

    It might be that you import a "broken" database.....



  • I built it from scratch, not from a backup of the previous version


  • MOD

    @daniele

    Was able to reproduce your problem!

    2017-11-17 21:03:39,766 ERROR [Acme.Utils.ThreadPool(0)-PooledThread: Acme.Serve.Serve$ServeConnection@4dc1b0] [org.mycontroller.standalone.api.jaxrs.exception.mappers.ApplicationExceptionMapper:42] ApplicationException,
    org.jboss.resteasy.spi.ApplicationException: java.lang.NullPointerException: userId
    	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:152)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
    	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
    	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
    	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
    	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
    	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    	at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40)
    	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2328)
    	at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2282)
    	at Acme.Serve.Serve$ServeConnection.run(Serve.java:2054)
    	at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.NullPointerException: userId
    	at org.mycontroller.standalone.api.jaxrs.model.AllowedResources.<init>(AllowedResources.java:33)
    	at org.mycontroller.standalone.api.jaxrs.model.AllowedResources$AllowedResourcesBuilder.build(AllowedResources.java:34)
    	at org.mycontroller.standalone.db.tables.User.getAllowedResources(User.java:86)
    	at org.mycontroller.standalone.db.tables.User.toString(User.java:47)
    	at java.lang.String.valueOf(String.java:2994)
    	at java.lang.StringBuilder.append(StringBuilder.java:131)
    	at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:137)
    	at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:458)
    	at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:328)
    	at org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl.create(BaseAbstractDaoImpl.java:244)
    	at org.mycontroller.standalone.api.jaxrs.model.UserJson.createOrUpdateUser(UserJson.java:74)
    	at org.mycontroller.standalone.api.jaxrs.SecurityHandler.addUser(SecurityHandler.java:184)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
    	... 15 common frames omitted
    

    Do you fill in all fields when creating the user?
    for the email addres just add a@b.com if there is no email available

    This error only shows if not all fields are filled.... (at least on my system, using the same version you use..)

    seems you can use spaces in the username


  • ADMIN


  • MOD

    @jkandasa
    👍 Thank you!


 

Suggested Topics

7
Online

334
Users

318
Topics

1.9k
Posts