Java Null Pointer Exception, browsing; Error 500 [Solved]

Hi Guys,

since a week or two, I have isses browsing to openhab. Today I set out to upgrade OH2, to see if something changed. It didn’t. I then updated java, but still NE :frowning:

So I guess it has to be something that has happened in my setup. Strange thing, is that it works just fine when accessing the sitemap directly (http://xenon:8080/basicui/app?sitemap=beckasinen).

Whenever I try without the sitemap, I get null pointer exceptions in jetty, such as;

2017-01-28 17:53:20.150 [WARN ] [eclipse.jetty.servlet.ServletHandler] - /basicui/app
java.lang.IllegalArgumentException: Subscription a45edb8c-8876-4e85-8c3e-497ecd990853 does not exist!
        at org.eclipse.smarthome.io.rest.sitemap.SitemapSubscriptionService.setPageId(SitemapSubscriptionService.java:172)[115:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201701192225]
        at org.eclipse.smarthome.ui.basic.internal.servlet.WebAppServlet.service(WebAppServlet.java:147)[188:org.eclipse.smarthome.ui.basic:0.9.0.201701192225]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[77:org.eclipse.jetty.security:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.Server.handle(Server.java:499)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[70:org.eclipse.jetty.io:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[81:org.eclipse.jetty.util:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[81:org.eclipse.jetty.util:9.2.19.v20160908]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]

and,

2017-01-28 17:54:01.417 [WARN ] [eclipse.jetty.servlet.ServletHandler] - /start/index
java.lang.NullPointerException
        at java.lang.String.replace(String.java:2240)[:1.8.0_112]
        at org.openhab.ui.dashboard.internal.DashboardServlet.serveDashboard(DashboardServlet.java:74)[168:org.openhab.ui.dashboard:2.0.0.201612272212]
        at org.openhab.ui.dashboard.internal.DashboardServlet.doGet(DashboardServlet.java:63)[168:org.openhab.ui.dashboard:2.0.0.201612272212]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)[19:javax.servlet-api:3.1.0]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)[19:javax.servlet-api:3.1.0]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[77:org.eclipse.jetty.security:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[79:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[170:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.Server.handle(Server.java:499)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[78:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[70:org.eclipse.jetty.io:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[81:org.eclipse.jetty.util:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[81:org.eclipse.jetty.util:9.2.19.v20160908]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]

Any suggestions how to proceed most welcome… :slight_smile:

Does your sitemap match the name of you’re sitemap file? The second word in your for must match the name of the file.

I’ve seen that first NPE a couple times before. It seems to occur sometimes when I restart OH2 with my browser window open running BasicUI. But, I’ve never been able to find a way to reproduce it consistently.

@Rich, if I run the full line with my sitemap, I get no NE. But if I try without any argument (to get to the UI selection base page), I 100% get the NE.

OK, so sometimes the solution is easier than I am expecting; I removed cache, tmp files, and a lock file in the userdata folder, and after starting up oh again it works. Some garbage must have found its way into one of those files.

1 Like

Can you detail the cache and tmp file locations that you removed?

Thanks
Andrew

After quitting oh, I removed everything in userdata/tmp, userdata/cache and a lockfile in userdata/ ( I think it was named “lock” or “lockfile”).

Thanks - ive just done the same and now the interface isnt even loading a web page at all!!!

tmp and cache folders have been recreated on reboot

Thats strange. What happens if you enter your sitemap in the url directly?

page cannot be found - was getting what you had above before removing the temp stuff - might be in for a reinstall methinks

Is there any hints in the oh log? Does everything apart from the web interface work?

think its broken big time - I cleared log and rebooted and its not populating anything in there. running service stop openhab2 says service not recognised but a manual start.sh says a service already running

root@raspberrypi:/usr/share/openhab2# sudo ./start.sh
Launching the openHAB runtime…
karaf: There is a Root instance already running with name main and pid 3131

and PID seems to be random?

So, I don’t know how your installation - I run my oh on my gentoo system, starting it manually, entering into karaf directly. But maybe it faster to reinstall, keeping your conf.

yeah think so - was on a snapshot ans wanted to go stable anyway so maybe this is a good way of doing it
Thanks for your help

OK so after a reinstall and experiencing the same thing - I created a new blank sitemap and got no error.

Long story short I had this in my sitemap:
Switch item=“test_switch”

which should have been
Switch item=test_switch

once I changed it all sitemap items came back
pity its not easier to troubleshoot these syntax errors

If you used Eclipse SmartHome Designer (get 0.80 version), you would see the error:

1 Like

OK have only cut the sitemaps by hand - perhaps its time to use the designer - thanks for the suggestion