Announcement Announcement Module
Collapse
No announcement yet.
stuck with org.springframework.beans.factory.BeanCreationExce ption Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • stuck with org.springframework.beans.factory.BeanCreationExce ption

    Hi,

    Following is my configuration file :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>

    <bean id="cacheFactory" class="com.tangosol.net.DefaultConfigurableCacheFa ctory">
    <constructor-arg value="cache-config-client.xml" />
    </bean>


    <bean id="invocationService" factory-bean="cacheFactory" factory-method="ensureService">
    <constructor-arg type="java.lang.String" value="remoteInvocationService"/>
    </bean>

    </beans>

    and the code snippet creating beans from this file is :

    context = new ClassPathXmlApplicationContext(
    new String[] {"beans-bootstrap.xml"});

    but this is not working and throwing the exception mentioned in the subject line.
    Following is the error stack trace :

    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'invocationService' defined in class path resource [beans-coherence.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionSt oreException: Factory method [public com.tangosol.net.Service com.tangosol.net.DefaultConfigurableCacheFactory.e nsureService(java.lang.String)] threw exception; nested exception is com.tangosol.net.messaging.ConnectionException
    Related cause: org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'invocationService' defined in class path resource [beans-coherence.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.tangosol.run.xml.XmlElement]: Ambiguous factory method argument types - did you specify the correct bean references as factory method arguments?
    at org.springframework.beans.factory.support.Construc torResolver.instantiateUsingFactoryMethod(Construc torResolver.java:396)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateUsingFactory Method(AbstractAutowireCapableBeanFactory.java:936 )
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:851)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:514)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:485)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:455)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:169)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:170)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:413)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:735)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:369)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:122)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:76)
    at com.rbsfm.gss.cache.loader.BootStrap.main(BootStra p.java:22)
    Caused by: org.springframework.beans.factory.BeanDefinitionSt oreException: Factory method [public com.tangosol.net.Service com.tangosol.net.DefaultConfigurableCacheFactory.e nsureService(java.lang.String)] threw exception; nested exception is com.tangosol.net.messaging.ConnectionException
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:127)
    at org.springframework.beans.factory.support.Construc torResolver.instantiateUsingFactoryMethod(Construc torResolver.java:387)
    ... 16 more

    Can anyone suggest what is the problem with the configuration? Does the problem lies with spring container or the bean is not geting created because of com.tangosol.net.messaging.ConnectionException

    I am using spring-core-2.5.0 and my java version is Java 1.5.0_14

  • #2
    @Manish,

    You have a nested exception "com.tangosol.net.messaging.ConnectionExceptio n", but you have not posted the message of this exception e.g. "could not establish a Socket connection to one of the remote addresses specified in the...".

    But to answer your question: "Does the problem lie with spring container?", the problem is not Spring Container, but the way you configure your cache bean. It seems that the Coherence Service, that you are trying to "ensure", is not running, and Coherence throws you a "nice" ConnectionException.

    /Anatoly

    Comment


    • #3
      Thanks Anatoly,

      I figured the problem out. The problem was indeed with ensureService. When I resolved that the above mentioned issue disappeared. Earlier I was concentrating on Spring's bean creation aspect and ignoring the connectionException.

      Thanks for your reply.

      Manish

      Comment

      Working...
      X