Registering war when EventAdmin service available causes NullPointerException

Description

When running in Karaf and deploying a war I am seeing the following exception:

2013-05-03 11:47:27,109 | DEBUG | pool-8-thread-1 | ServletEventDispatcher | .internal.ServletEventDispatcher 130 | Sending web event ServletEvent [replay=false, type=1, bundle=com.mycompany.myproject.mywar_1.0.0.20130502-jenkins-302 [206], timestamp=1367596047109, alias=null, servletName=MyWarServlet, urlParameter=[Ljava.lang.String;@146aac84, servlet=null, servletClass=class com.mycompany.myproject.mywar.MyWarServlet], httpContext=WebAppHttpContext{com.mycompany.myproject.mywar - 206}] for bundle com.mycompany.myproject.mywar
2013-05-03 11:47:27,114 | WARN | pool-8-thread-1 | ServletEventDispatcher | .internal.ServletEventDispatcher 190 | Listener caused an exception, will be ignored
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)[:1.7.0_17]
at java.util.concurrent.FutureTask.get(FutureTask.java:111)[:1.7.0_17]
at java.util.concurrent.AbstractExecutorService.doInvokeAny(AbstractExecutorService.java:193)[:1.7.0_17]
at java.util.concurrent.AbstractExecutorService.invokeAny(AbstractExecutorService.java:225)[:1.7.0_17]
at org.ops4j.pax.web.service.internal.ServletEventDispatcher.callListener(ServletEventDispatcher.java:175)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.ServletEventDispatcher.callListeners(ServletEventDispatcher.java:164)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.ServletEventDispatcher.servletEvent(ServletEventDispatcher.java:134)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.servletEvent(HttpServiceStarted.java:184)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:192)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:378)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:413)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.visit(RegisterWebAppVisitorWC.java:215)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:664)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:201)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:262)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:136)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf.jar:2.3.1]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)[karaf.jar:2.3.1]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf.jar:2.3.1]
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)[karaf.jar:2.3.1]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317)[karaf.jar:2.3.1]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)[karaf.jar:2.3.1]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:102)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:202)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.WebObserver$1.start(WebObserver.java:174)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$1.run(AbstractExtender.java:261)[81:org.ops4j.pax.web.pax-web-extender-war:3.0.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_17]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_17]
at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_17]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_17]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_17]
at java.lang.Thread.run(Thread.java:722)[:1.7.0_17]
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:542)[:1.7.0_17]
at org.ops4j.pax.web.service.internal.EventAdminHandler.servletEvent(EventAdminHandler.java:92)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.ServletEventDispatcher$3.call(ServletEventDispatcher.java:179)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at org.ops4j.pax.web.service.internal.ServletEventDispatcher$3.call(ServletEventDispatcher.java:176)[77:org.ops4j.pax.web.pax-web-runtime:3.0.0]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_17]
at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_17]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_17]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_17]
at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_17]
... 8 more

I tracked it down to here in EventAdminHandler.servletEvent:

public void servletEvent(ServletEvent servletEvent) {
.
.
properties.put("servlet.servlet",servletEvent.getServlet()); <<
.
.
}

This makes sense as the original ServletEvent did not provide a servlet. What is the right solution here? Is the problem that the original event did not provide a Servlet...or should a check for a null servlet be added to servletEvent?

Environment

Karaf 2.3.1 running with Pax Web 3.0.0

Status

Assignee

Achim Nierbeck

Reporter

G

Labels

None

Components

Fix versions

Affects versions

Priority

Minor
Configure