Announcement Announcement Module
Collapse
No announcement yet.
Newbie problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Can you post your Appendix and First classes?

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

    Comment


    • #3
      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 ...

      Comment

      Working...
      X