ops4j / org.ops4j.pax.web

OSGi R7 Http Service, Whiteboard and Web Applications (OSGi CMPN Release chapters 102, 140 and 128) implementation using Jetty 9, Tomcat 9 or Undertow 2.
https://ops4j1.jira.com/wiki/display/paxweb/Pax+Web
Other
144 stars 183 forks source link

[8.0.x] Cannot invoke "org.ops4j.pax.web.service.spi.model.OsgiContextModel.setDisplayName(String)" because "ocm" is null #1975

Closed MrEasy closed 1 week ago

MrEasy commented 4 weeks ago

Hi, with change: KARAF-7774 Fix display-name for WABs a display name is set. In our case, we have it sporadically that this fails with a NullPointerExc. because allocatedOsgiContextModel is null here already: BundleWebApplication.java#L712 and then fails with NullPointerExc here when setting displayName: BundleWebApplication.java#L1302 Unclear what leads to it being null sporadically, but maybe adding a null-check would be appropriate anyhow?

ERROR    org.ops4j.pax.web.extender.war.internal.model.BundleWebApplication  wab-extender-1-thread-2     [org.ops4j.pax.web.pax-web-extender-war:8.0.27]                     Problem processing Web Application "/api" for bundle com.seeburger.api.rest-service/1.60.0: Cannot invoke "org.ops4j.pax.web.service.spi.model.OsgiContextModel.setDisplayName(String)" because "ocm" is null
java.lang.NullPointerException: Cannot invoke "org.ops4j.pax.web.service.spi.model.OsgiContextModel.setDisplayName(String)" because "ocm" is null
    at org.ops4j.pax.web.extender.war.internal.model.BundleWebApplication.buildModel(BundleWebApplication.java:1300) ~[?:?]
    at org.ops4j.pax.web.extender.war.internal.model.BundleWebApplication.deploy(BundleWebApplication.java:719) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
    at java.lang.Thread.run(Thread.java:1583) [?:?]

internal ref#188580

grgrzybek commented 4 weeks ago

3e714eff46fff4e980c44114b6b403a1a5e13138 can't be the cause of NPE (ocm was used before this change), but I'll check this issue after holidays (Aug 30th). thanks for reporting!

grgrzybek commented 1 week ago

This is a timing issue when HttpService is quickly registered and unregistered. I'll add some protection code.