Adrian,

I can get past the failure in the ResourceInjector, but Spring still 
refuses to start your application context.   Your "factoryMethod" in the 
DummyFactory returns void instead of the factory object.   Thus, Spring 
itself will complain that the bean cannot be null:

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'dummy.factory' defined in class path resource 
[demo/spring/bean-defs.xml]: Initialization of bean failed; nested 
exception is java.lang.IllegalArgumentException: Bean must not be null
Caused by: java.lang.IllegalArgumentException: Bean must not be null


If I make the method return the DummyFactory, all is well.


Dan


On Wednesday 17 October 2007, Adrian C wrote:
> Hi,
>
> I am trying to migrate a XFire project to CXF and seem to have fallen
> quiet early on.
>
> I have alot of spring configuration that used to get loaded up by
> ContextLoaderListener before any of the xfire context were loaded up.
> I loaded up my XFire service contexts using the
> XFireConfigurableServlet. Now that I am trying to migrate, it appears
> I have no way to load up CXF after the all my context have loaded (if
> I try to do this now using the config location param for the servlet
> defintion I get a no bean cxf found exception).
>
> So I am forced to load my CXF services with my main spring
> configuration, but this doesn't work because I have a statically
> initialized bean - my problem seems to be with the
> Jsr250BeanPostProcessor & a bean which is created using a factory
> method at startup.
>
> i.e.
> <bean id="dummy.factory" class="demo.spring.DummyFactory"
> factory-method="createInstance" lazy-init="false">
> ...
>
> This bean causes a NullPointerException (see below), so any
> suggestions as to what to do. I have a attached a source code to
> recreate this problem.
>
> Thanks
>
> 828 [main] ERROR org.springframework.web.context.ContextLoader  -
> Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'dummy.factory ' defined in class path
> resource
> [demo/spring/bean-defs.xml]: Initialization of bean failed; nested
> exception is java.lang.NullPointerException
> Caused by:
> java.lang.NullPointerException
>     at
> org.apache.cxf.common.injection.ResourceInjector.getAnnotatedMethods
> (ResourceInjector.java:333)
>     at
> org.apache.cxf.common.injection.ResourceInjector.getPostConstructMetho
>ds(ResourceInjector.java:323) at
> org.apache.cxf.common.injection.ResourceInjector.invokePostConstruct(R
>esourceInjector.java
>
> :284)
>
>     at
> org.apache.cxf.common.injection.ResourceInjector.construct(ResourceInj
>ector.java:84) at
> org.apache.cxf.bus.spring.Jsr250BeanPostProcessor.postProcessBeforeIni
>tialization(Jsr250BeanPostProcessor.java
>
> :44)
>
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
>actory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapa
>bleBeanFactory.java:301) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
>actory.initializeBean (AbstractAutowireCapableBeanFactory.java:1167)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
>actory.createBean(AbstractAutowireCapableBeanFactory.java:425) at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObj
>ect (AbstractBeanFactory.java:251)
>     at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
>.getSingleton(DefaultSingletonBeanRegistry.java:156) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean
> (AbstractBeanFactory.java:248)
>     at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
>AbstractBeanFactory.java:160) at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.p
>reInstantiateSingletons (DefaultListableBeanFactory.java:287)
>     at
> org.springframework.context.support.AbstractApplicationContext.refresh
>(AbstractApplicationContext.java:352) at
> org.springframework.web.context.ContextLoader.createWebApplicationCont
>ext (ContextLoader.java:244)
>     at
> org.springframework.web.context.ContextLoader.initWebApplicationContex
>t(ContextLoader.java:187) at
> org.springframework.web.context.ContextLoaderListener.contextInitializ
>ed(ContextLoaderListener.java
>
> :49)
>
>     at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext
>.java:3764) at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:42
>16) at org.apache.catalina.core.ContainerBase.addChildInternal
> (ContainerBase.java:760)
>     at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740
>) at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
> at org.apache.catalina.startup.HostConfig.deployDescriptor
> (HostConfig.java:626)
>     at
> org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.ja
>va:553) at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
>     at org.apache.catalina.startup.HostConfig.start
> (HostConfig.java:1138) at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:
>311) at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycle
>Support.java:120) at org.apache.catalina.core.ContainerBase.start
> (ContainerBase.java:1022)
>     at
> org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
> at org.apache.catalina.core.StandardEngine.start
> (StandardEngine.java:443)
>     at
> org.apache.catalina.core.StandardService.start(StandardService.java:44
>8) at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
>     at org.apache.catalina.startup.Catalina.start (Catalina.java:552)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
>ava:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:585)
>     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
>     at org.apache.catalina.startup.Bootstrap.main (Bootstrap.java:433)
>
> http://www.nabble.com/file/p13254519/test.zip test.zip



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
[EMAIL PROTECTED]
http://www.dankulp.com/blog

Reply via email to