Re: MinaConfiguration codec property

2009-03-05 Thread Claus Ibsen
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= /
                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 
 

Re: MinaConfiguration codec property

2009-03-05 Thread Nicolas Bouillon
I've already tried that. But the codec property IS a string property,
and then i got the following error :

Caused by: org.springframework.beans.TypeMismatchException: Failed to
convert property value of type [com.example.MyProtocolCodecFactory] to
required type [java.lang.String] for property 'codec'; nested
exception is java.lang.IllegalArgumentException: Cannot convert value
of type [com.example.MyProtocolCodecFactory] to required type
[java.lang.String] for property 'codec': no matching editors or
conversion strategy found
at 
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 29 more


On Thu, Mar 5, 2009 at 10:04, Claus Ibsen claus.ib...@gmail.com wrote:
 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= /
                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 
 

Re: MinaConfiguration codec property

2009-03-05 Thread Nicolas Bouillon
Should I create my Endpoints such they are attached to my CamelContext ?

On Thu, Mar 5, 2009 at 10:21, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 Sorry yeah its a string as this was how its done in Camel 1.x

 We could change it to a real ProtocolCodecFactory object instead of
 String and then it should work

 For uri you should use the # notation to lookup the codec.

 Btw the NPE you get is because you create it like that using Spring
 style and the endpoint does not have the CamelContext associated.
 And thus it can not got hold of the registry to lookup the codec.

 I will fix it.



 On Thu, Mar 5, 2009 at 10:11 AM, Nicolas Bouillon nico...@bouil.org wrote:
 I've already tried that. But the codec property IS a string property,
 and then i got the following error :

 Caused by: org.springframework.beans.TypeMismatchException: Failed to
 convert property value of type [com.example.MyProtocolCodecFactory] to
 required type [java.lang.String] for property 'codec'; nested
 exception is java.lang.IllegalArgumentException: Cannot convert value
 of type [com.example.MyProtocolCodecFactory] to required type
 [java.lang.String] for property 'codec': no matching editors or
 conversion strategy found
        at 
 org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
        at 
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
        at 
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
        at 
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at 
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        ... 29 more


 On Thu, Mar 5, 2009 at 10:04, Claus Ibsen claus.ib...@gmail.com wrote:
 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= /
                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 
 

Re: MinaConfiguration codec property

2009-03-05 Thread Willem Jiang
Hi

Since the myMinaEndpoint is created by the myMinaFactory which has not
the reference from the application context which can be referred by the
camelContext .
So the myMinaEndpoint can't get find the instance of myCodec.

My suggestion is adding a constructor-arg of the camel context under the
bean id=myMinaFactory ...
to let the myMinaFactory hold the reference of camelContext.

Willem


Nicolas Bouillon 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= /
   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 
 

Re: MinaConfiguration codec property

2009-03-05 Thread Claus Ibsen
On Thu, Mar 5, 2009 at 10:31 AM, Willem Jiang willem.ji...@gmail.com wrote:
 Hi

 Since the myMinaEndpoint is created by the myMinaFactory which has not
 the reference from the application context which can be referred by the
 camelContext .
 So the myMinaEndpoint can't get find the instance of myCodec.

 My suggestion is adding a constructor-arg of the camel context under the
 bean id=myMinaFactory ...
 to let the myMinaFactory hold the reference of camelContext.
Yes I am adding it right now

bean id=myMinaEndpoint
  factory-bean=myMinaFactory
  factory-method=createEndpoint
constructor-arg index=0 ref=myCamel/
constructor-arg index=1 ref=myMinaConfig/
/bean



 Willem


 Nicolas Bouillon 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= /
               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 
 

Re: MinaConfiguration codec property

2009-03-05 Thread Nicolas Bouillon
Thanks ! This way it works.

bean id=myCodec class=com.example.MyProtocolCodecFactory
/bean

bean id=myMinaFactory 
class=org.apache.camel.component.mina.MinaComponent
constructor-arg index=0 ref=camel /
/bean


bean id=myMinaEndpoint
  factory-bean=myMinaFactory
  factory-method=createEndpoint
constructor-arg index=0 ref=myMinaConfig/
/bean

bean depends-on=eppCodec id=myMinaConfig
class=org.apache.camel.component.mina.MinaConfiguration
property name=protocol value=tcp /
property name=host value=loclahost /
property name=port value= /
property name=sync value=true /
property name=codec value=myCodec /
/bean

On Thu, Mar 5, 2009 at 10:31, Willem Jiang willem.ji...@gmail.com wrote:
 Hi

 Since the myMinaEndpoint is created by the myMinaFactory which has not
 the reference from the application context which can be referred by the
 camelContext .
 So the myMinaEndpoint can't get find the instance of myCodec.

 My suggestion is adding a constructor-arg of the camel context under the
 bean id=myMinaFactory ...
 to let the myMinaFactory hold the reference of camelContext.

 Willem


 Nicolas Bouillon 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= /
               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