mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 90 forks source link

Null pointer exception when adding a new user #426

Closed jkandasa closed 6 years ago

jkandasa commented 6 years ago

Source: https://forum.mycontroller.org/topic/223/null-pointer-exception-when-adding-a-new-user

Reported by: Daniele and Tag. 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
cimba007 commented 6 years ago

From my experience this only happens if not all fields are filled (e.g. the email is omitted).

OPI-0 commented 6 years ago

agree, only seen when not all fields are filled