Hi You should use ref to refer to another spring bean <property name="codec" ref="myCodec" />
value is for string litterals, numbers and such. On Thu, Mar 5, 2009 at 9:55 AM, Nicolas Bouillon <nico...@bouil.org> wrote: > Hi, > > i've got an error when trying to create my mina endpoint with spring dsl : > > <bean id="myCodec" class="com.example.MyProtocolCodecFactory"> > </bean> > > <bean id="myMinaFactory" > class="org.apache.camel.component.mina.MinaComponent"/> > > <bean id="myMinaEndpoint" > factory-bean="myMinaFactory" > factory-method="createEndpoint"> > <constructor-arg index="0" ref="myMinaConfig"/> > </bean> > > <bean id="myMinaConfig" > class="org.apache.camel.component.mina.MinaConfiguration"> > <property name="protocol" value="tcp" /> > <property name="host" value="localhost" /> > <property name="port" value="7777" /> > <property name="sync" value="true" /> > <property name="codec" value="myCodec" /> > </bean> > > I got the following error : > org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'myMinaEndpoint' defined in class path > resource [spring.xml]: Instantiation of bean failed; nested exception > is org.springframework.beans.factory.BeanDefinitionStoreException: > Factory method [public org.apache.camel.Endpoint > org.apache.camel.component.mina.MinaComponent.createEndpoint(org.apache.camel.component.mina.MinaConfiguration) > throws java.lang.Exception] threw exception; nested exception is > java.lang.NullPointerException > at > org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:444) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:903) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:817) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) > at java.security.AccessController.doPrivileged(Native Method) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) > at > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) > at > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) > at > org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) > at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) > at > org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) > at > org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) > at com.example.main(App.java:15) > Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: > Factory method [public org.apache.camel.Endpoint > org.apache.camel.component.mina.MinaComponent.createEndpoint(org.apache.camel.component.mina.MinaConfiguration) > throws java.lang.Exception] threw exception; nested exception is > java.lang.NullPointerException > at > org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:127) > at > org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:435) > ... 17 more > Caused by: java.lang.NullPointerException > at > org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:152) > at > org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:170) > at > org.apache.camel.impl.DefaultComponent.mandatoryLookup(DefaultComponent.java:315) > at > org.apache.camel.component.mina.MinaComponent.getCodecFactory(MinaComponent.java:360) > at > org.apache.camel.component.mina.MinaComponent.configureCodecFactory(MinaComponent.java:213) > at > org.apache.camel.component.mina.MinaComponent.createSocketEndpoint(MinaComponent.java:175) > at > org.apache.camel.component.mina.MinaComponent.createEndpoint(MinaComponent.java:109) > at > org.apache.camel.component.mina.MinaComponent.createEndpoint(MinaComponent.java:101) > 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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115) > ... 18 more > > if i remove the property "codec", it works. I believe it's because the > "myCodec" bean is not already created. It is reference as a spring > value, not as a bean reference. But i tried to add depends-on but it > doesn't work. > <bean depends-on="myCodec" id="myMinaConfig" ... > > Regards. > NicolaS. > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/