Results 1 to 2 of 2

Thread: NoSuchBeanDefinitionException when refering from schema bean

  1. #1
    Join Date
    Jan 2010
    Location
    Altan Ord
    Posts
    36

    Default NoSuchBeanDefinitionException when refering from schema bean

    Hi,

    Have a look:

    Code:
    <bean id="someBean" class="com.....SomeBean">
    	<property name="url" value="XXX"/>
    </bean>
    		
    <bean id="anotherBean" class="com... AnotherBean">
    	<property name="url" value="#{ someBean.url }"/>
    </bean>
    
    <jaxws:client id="service" serviceClass="com....Port" address="#{ someBean.url }" />
    anotherBean gets its url without problesm, but when resolving service address it fails with

    Code:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '{ someBean.url }' is defined
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1094)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:276)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1327)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1085)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
    I expected a schema-defined parser to treat attributes' values in the same way as core spring deals with bean properties, but if I understand the trace correctly, the exception is thrown before parser is reached, thus it's something about spring. So the question if there is any way to refer to some bean's property from a schema-defined bean attribute.


    Best regards, Eugene.

  2. #2
    Join Date
    Jan 2010
    Location
    Altan Ord
    Posts
    36

    Default

    Ok, looks like there is no way to get expression there .The AbstractBeanDefinitionParser mapToProperty method contains this:

    Code:
    if (val.startsWith("#")) {
       bean.addPropertyReference(propertyName, val.substring(1));
    } else {
       bean.addPropertyValue(propertyName, val);
    }

    thus # should be followed by just a bean name, not expression. Am I right? I really hope I'm missing something.

    Best regards, Eugene.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •