Results 1 to 3 of 3

Thread: Newbie problem

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Posts
    2

    Default Newbie problem

    I've installed the Spring IDE plugin for eclipse. I'm trying a mickey mouse project to get the hang of it. My Java classes compile OK, but the validator complains about my spring.xml config file:

    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<bean class="eg.Appendix" id="app">
    	    <property name="word"><value>World</value></property>
    	</bean>
    	<bean class="eg.First" id="first">
    	    <property name="append"><ref bean="app" /></property>
    	</bean>
    </beans>
    The error is "No setter for property 'word' defined in class 'eg.First'".

    I'm baffled, because 'word' is a property of eg.Appendix, not eg.First. Despite the validation error, the application executes as expected - output as follows:

    19-Sep-2004 10:50:55 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from (no description)
    19-Sep-2004 10:50:55 org.springframework.beans.factory.support.Abstract BeanFactory getBean
    INFO: Creating shared instance of singleton bean 'first'
    19-Sep-2004 10:50:56 org.springframework.beans.factory.support.Abstract BeanFactory getBean
    INFO: Creating shared instance of singleton bean 'app'
    Hello World

    Possibly because of the validation error, I can't get a graphical view of the config - I just get a blank sheet in the Config File viewer.

    Any help gratefully received !

    Tom.

  2. #2

    Default

    Can you post your Appendix and First classes?

    Also, what line in spring.xml is the validation error marked on?

  3. #3
    Join Date
    Sep 2004
    Posts
    2

    Default

    OK, for the sake of completeness, here's HelloWorld:

    Code:
    public class HelloWorld &#123;
    
    	public HelloWorld&#40;&#41; &#123;
    		super&#40;&#41;;
    		InputStream is = getClass&#40;&#41;.getResourceAsStream&#40;"spring.xml"&#41;;
    		XmlBeanFactory bf = new XmlBeanFactory&#40;is&#41;;
    		Printy p = &#40;Printy&#41; bf.getBean&#40;"first"&#41;;
    		p.print&#40;&#41;;
    	&#125;
    
    	public static void main&#40;String&#91;&#93; args&#41; &#123;
    		HelloWorld h = new HelloWorld&#40;&#41;;
    	&#125;
    &#125;

    Now here's First:

    Code:
    package eg;
    
    public class First implements Printy &#123;
    	private Append append;
    
    	public void setAppend&#40;Append append&#41; &#123;
    		this.append = append;
    	&#125;
    
    	public void print&#40;&#41; &#123;
    		System.out.println&#40;append.append&#40;"Hello"&#41;&#41;;
    	&#125;
    &#125;
    And here's Appendix:

    Code:
    package eg;
    public class Appendix implements Append &#123;
    
    	private String word;
    	
    	public void setWord&#40;String word&#41; &#123;
    		this.word = word;
    	&#125;
    	public String append&#40;String a&#41; &#123;
    		return a+" "+word;
    	&#125;
    &#125;
    And here's Append interface FWIW:

    Code:
    package eg;
    public interface Append &#123;
    	String append&#40;String a&#41;;
    &#125;
    The error is flagged in this line:

    Code:
    <property name="word"><value>World</value></property>
    Nothing too weird there, I think ...

Similar Threads

  1. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  2. Spring newbie problem
    By 3dot14 in forum Web
    Replies: 0
    Last Post: Mar 2nd, 2005, 10:55 AM
  3. Replies: 2
    Last Post: Jan 5th, 2005, 04:14 PM
  4. Replies: 1
    Last Post: Dec 20th, 2004, 04:43 AM
  5. Newbie problem - NotWritablePropertyException
    By hay7777 in forum Container
    Replies: 2
    Last Post: Aug 31st, 2004, 05:01 PM

Posting Permissions

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