Results 1 to 3 of 3

Thread: facing problrm with bean property name

  1. #1

    Question facing problem with bean property name

    given code is the sample code to demonstrate the problem that i'm facing in my real application

    when i run this code it throws an exception : org.springframework.beans.factory.BeanCreationExce ption
    : Error creating bean with name 'ITestInterface' defined in file [E:\myhibernet\src\spring-config\ITest-Interface-Bean.xml]: Cannot resolve reference to bean 'testImplementation' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'testImplementation' defined in file [E:\myhibernet\src\spring-config\Test-Implementation-Bean.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException : Invalid property 'iPrimeNo' of bean class [com.TestImplementation]: No property 'iPrimeNo' found


    Code:
    file: TestImplementation.java
    
    package com;
    
    interface ITestInterface {
    
    	public void setIPrimeNo(Integer iPrimeNo) throws SufalamException;		
    }
    
    
    
    public class TestImplementation implements ITestInterface{
    	private Integer iPrimeNo;
    	public void setIPrimeNo(Integer iPrimeNo) throws SufalamException{
    		this.iPrimeNo = iPrimeNo;
    	}
    	public Integer getIPrimeNo() throws SufalamException{
    		return iPrimeNo;
    	}
    }
    
    
    file: ITest-Interface-Bean.xml
    
    <?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="ITestInterface" class="org.springframework.aop.framework.ProxyFactoryBean" autowire="byName">
    	<property name="proxyInterfaces">
    		<value>com.ITestInterface</value>
    	</property>
    
    	<property name="target">
    		<ref bean="testImplementation"/>
    	</property>
    </bean>
    
    </beans>
    
    
    
    
    file: Test-Implementation-Bean.xml
    
    <?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="testImplementation" class="com.TestImplementation" >
    	<property name="iPrimeNo">
    		<value>10</value>
    	</property>
    </bean>
    
    </beans>



    when i change the property to name="IPrimeNo" in Test-Implementation-Bean.xml file the error gets solved.
    but it is illegal as my property name is iPrimeNo.

    I've observed this problem occurs with the property names starts with "i".

    Can Anyone help me what's the problem is ??
    Thanks In Advance.
    Attached Files Attached Files
    Last edited by shaileshpatel; Apr 1st, 2009 at 02:38 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    When posting code please use [ code][/code ] tags.

    when i change the property to name="IPrimeNo" in Test-Implementation-Bean.xml file the error gets solved.
    but it is illegal as my property name is iPrimeNo.
    It isn't illegal. I suggest you read the java beans specification. You ran into one of the exceptions to the naming convention. When a property name starts with 2 uppercase characters the naming convention states that it remains that way instead of lowercasing the first character.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    thanks for your valuable reply Marten,
    I'll take better care of coding conventions.
    Good bi.

Posting Permissions

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