PDA

View Full Version : NoSuchMethodError



mikelitton
Oct 7th, 2007, 12:48 PM
Hi,

I've written some very simple AOP code to test springs AOP support. However, I can't get the program to start. I'm using 2.0.6 and the error I'm getting is

====================
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'helloService' defined in class path resource [spring-config.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.isPresent(Ljav a/lang/String;Ljava/lang/ClassLoader;)Z
Caused by: java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.isPresent(Ljav a/lang/String;Ljava/lang/ClassLoader;)Z
at org.springframework.aop.framework.DefaultAopProxyF actory.<clinit>(DefaultAopProxyFactory.java:50)
====================

The application context is configured as follows

====================
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">

<aop:aspectj-autoproxy />

<bean id="helloService" class="micke.test.HelloServiceImpl" />
<bean id="AspectHello" class="micke.test.AspectHello" />

</beans>
====================

And main( String[] args ) is

====================
ApplicationContext context = new ClassPathXmlApplicationContext( "spring-config.xml" );

HelloService service = (HelloService) context.getBean( "helloService" );
service.mike();
====================

I ran into this the same "NoSuchMethodError" trying to configure Spring's transaction manager yesterday. It's still unresolved. This is probably a lib version error or something so I'm guessing that others have been having this problem as well but I can't find much about it on the net.

Thanks.

Mike

karldmoore
Oct 7th, 2007, 01:50 PM
Any chance you've got duplicate JARs or different versions on the classpath? I'd make sure you've only got the one most upto date one and try it again.

mikelitton
Oct 8th, 2007, 01:14 AM
I finally managed to find a second spring.jar file that got automatically included to the classpath.

NoMethodFoundError -> Classpath Trouble

Thanks.

Mike