-
Jun 9th, 2007, 01:11 PM
#1
BeanCreationException - Caused by: java.lang.NoClassDefFoundError
Hi,
I am new to Spring and am working through the example in Spring in Action but having problems getting it to work. This morning I had issues loading the xml file into the bean factory, now I get an error saying the class I want to instantiate doesn't exist.
Can anyone advise what I might be doing wrong?
Many thanks,
David
Heres the relevant code:
GreetingService greetingService = (GreetingService) factory.getBean("greetingService");
RUNTIME ERROR:
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'greetingService' defined in file [C:\dev\workshop\SpringInAction\hello.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError
Caused by: java.lang.NoClassDefFoundError
at msjava.base.internal.adapters.UtilityAd....[let me know if you need more]...........
My configuration file looks like:
<?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="greetingService" class="com.springinaction.chapter01.hello.Greeting ServiceImpl">
<constructor-arg>
<value>Hello</value>
</constructor-arg>
</bean>
</beans>
And classes/interfaces look like:
package com.springinaction.chapter01.hello;
public interface GreetingService
{
public void sayGreeting();
}
package com.springinaction.chapter01.hello;
public class GreetingServiceImpl implements GreetingService
{
private String greeting;
public GreetingServiceImpl(){}
public GreetingServiceImpl(String greeting) {
this.greeting = greeting;
}
public void setGreeting(String greeting) {
this.greeting = greeting;
}
public void sayGreeting() {
System.out.println(this.greeting);
}
}
-
Jun 9th, 2007, 04:20 PM
#2
I think it's as simple as the exception message says, the class named in the exception can't be found on the classpath. Also, wrapping code in [code] [ /code] tags makes it soooo much more readable!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules