Hi,
I have a web service using JAX-WS 2.1 with CXF 2.0.6. It's an elementary
service with one operation, but it works fine. Now, I want to add Spring
support. I want to get the Spring application's context, by calling this:
*ApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext( ?? ServletContext ??);*

So, I thought I'd make my service implementation class implement the
ServletContextListener interface, implement the contextInitialized() and
contextDestroyed() methods, and voila! I would have a servletContext to pass
into
getWebApplicationContext() above. I could then get the Spring context very
early in my services lifecycle. I registered the listener class in my
web.xml file and it all seems good to me. But, when I deploy my
Maven-created war to Tomcat 6.0.18, I get:

Dec 16, 2008 1:37:40 PM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Error configuring application listener of class
com.mycompany.service.TestWebServicePortImpl
javax.naming.NameNotFoundException: Name
com.mycompany.service.TestWebServicePortImpl is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at
org.apache.catalina.util.DefaultAnnotationProcessor.lookupFieldResource(DefaultAnnotationProcessor.java:208)
    at
org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:138)
    at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3790)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
    at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
    at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
    at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Dec 16, 2008 1:37:40 PM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Dec 16, 2008 1:37:40 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 16, 2008 1:37:40 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()


Incidentally, when I attempted the same thing in Metro (Glassfish/NetBeans),
it worked fine. The service implementation class can indeed implement the
ServletContextListener interface as long as you register your class as a
listener in web.xml.
Can I not do this with CXF?
Any hints please would be greatly appreciated.

Thanks,
Jeff Walker

Reply via email to