I've been working on this more - and it now appears to me to have more to do
with some change to application-event handling in Spring between 2.5.6 and 3.0.
The code that fails in CXFServlet under Spring 3.0 is at line 125:
resourceManager.addResourceResolver(new
ServletContextResourceResolver(servletConfig.getServletContext()));
specifically 'servletConfig' is null when the sample code is run under Spring
3.0 and is valid when run with 2.5.6. I have discovered that the problem is
with the implementation of 'onApplicationEvent' in CXFServlet.
I added some tracing to this code. Under Spring 2.5.6 - I saw no evidence that
this method was ever called at all. When running under Spring 3.0 this method
was called multiple times - the first call happening BEFORE servletConfig was
actually available, and subsequently two more times, resulting in unnecessary
context updates that resulted in this information log entry:
INFO: Servlet transport factory already registered
It seems that at minimum, the execution of 'updateContext' should only happen
if the ServletConfig is non-null. It also appears that the use of the
'inRefresh' flag is insufficient to guard against rapid fire repeat events as
seem to be raised in Spring 3.0.
Hope this helps and I apologize for not having all the information when I
posted the first time.
B.J.
On Jan 15, 2010, at 10:40 AM, William Blackburn wrote:
> I have been using CXF 2.2.3 with Spring 2.5.6 and an embedded Jetty instance
> successfully for several months. After the release of Spring 3.0, I have
> tried migrating to the new Spring version. Now the CXF Servlet is failing
> with a nullpointerexception on the 'updateContext' method:
>
> Caused by: java.lang.NullPointerException
> at
> org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
> at
> org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:182)
> at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
> at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
> at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
> at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
>
> The line that is failing is:
>
> resourceManager.addResourceResolver(new
> ServletContextResourceResolver(servletConfig.getServletContext()));
>
> Since Spring doesn't seem to even be involved in this line, I can't see why
> the move from 2.5.6 to 3.0 would even have caused this, but its the only
> change I made before it started failing.
>
> Has anyone else seen this? I tried using CXF 2.2.5 and had the same result,
> so I am wondering if CXF's current GA release is even compatible with Spring
> 3?
>
> Thanks for any help at all.
>
> BJ