PDA

View Full Version : Newbie problem


tomhay
Sep 19th, 2004, 06:52 AM
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:


<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://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.

Loren Rosen
Sep 20th, 2004, 02:22 PM
Can you post your Appendix and First classes?

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

tomhay
Sep 21st, 2004, 04:22 PM
OK, for the sake of completeness, here's HelloWorld:

public class HelloWorld {

public HelloWorld() {
super();
InputStream is = getClass().getResourceAsStream("spring.xml");
XmlBeanFactory bf = new XmlBeanFactory(is);
Printy p = (Printy) bf.getBean("first");
p.print();
}

public static void main(String[] args) {
HelloWorld h = new HelloWorld();
}
}


Now here's First:

package eg;

public class First implements Printy {
private Append append;

public void setAppend(Append append) {
this.append = append;
}

public void print() {
System.out.println(append.append("Hello"));
}
}

And here's Appendix:

package eg;
public class Appendix implements Append {

private String word;

public void setWord(String word) {
this.word = word;
}
public String append(String a) {
return a+" "+word;
}
}

And here's Append interface FWIW:

package eg;
public interface Append {
String append(String a);
}

The error is flagged in this line:

<property name="word"><value>World</value></property>

Nothing too weird there, I think ...