Announcement Announcement Module
Collapse
No announcement yet.
org.springframework.util.ReflectionUtils.makeAcces sible NoSuchMethodException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.util.ReflectionUtils.makeAcces sible NoSuchMethodException

    Simple AOP testcase creates a NoSuchMethodException. Here is the detailed stacktrace.
    Code:
    Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.makeAccessible(Ljava/lang/reflect/Method;)V
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy0.invokeSomeService(Unknown Source)
    	at com.emmes.test.Driver.main(Driver.java:22)
    Following is the snippet of context.xml. Here service class, AOP after return advisor are configured.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    	xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    	<bean id="testAfterAspect" class="com.emmes.aop.DummyAfterReturnAdvisor">
    	</bean>
    	
    	<bean id="testAfterAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    		<property name="advice" ref="testAfterAspect"/>
    		<property name="patterns">
    		    <list>
    				<value>com.emmes.service.ITestAfterReturnAdvisor.invokeSomeService</value>
    			</list>
    		</property>
    	</bean>
     <bean id="testServiceTarget" class="com.emmes.service.impl.TestAfterReturnAdvisorImpl"></bean>
    
    	<bean id="testService" class="org.springframework.aop.framework.ProxyFactoryBean" >
    		<property name="target">
    			<ref local="testServiceTarget"/>
    		</property>
    		<property name="proxyInterfaces" value="com.emmes.service.ITestAfterReturnAdvisor"/>
    		<property name="interceptorNames">
    			<list>
    				<value>testAfterAdvisor</value>
    			</list>
    		</property>
    	</bean>
    </beans>
    The service class is
    Code:
    /**
     * 
     */
    package com.emmes.service.impl;
    
    import com.emmes.service.ITestAfterReturnAdvisor;
    
    /**
     * @author mmutham
     *
     */
    public class TestAfterReturnAdvisorImpl implements ITestAfterReturnAdvisor {
    
    	/* (non-Javadoc)
    	 * @see com.emmes.service.ITestAfterReturnAdvisor#invokeSomeService()
    	 */
    	@Override
    	public void invokeSomeService() {
    		// TODO Auto-generated method stub
    		System.out.println("In invokeSomeService");
    	}
    
    }
    The interface for the service class is shown below.
    Code:
    /**
     * 
     */
    package com.emmes.service;
    
    /**
     * @author mmutham
     *
     */
    public interface ITestAfterReturnAdvisor {
    	
    	public void invokeSomeService();
    }
    The AOP return advisor is shown below.
    Code:
    package com.emmes.aop;
    
    import java.lang.reflect.Method;
    
    import org.springframework.aop.AfterReturningAdvice;
    
    public class DummyAfterReturnAdvisor implements AfterReturningAdvice {
    
    	public void afterReturning(Object arg0, Method arg1, Object[] arg2,
    			Object arg3) throws Throwable {
    		// TODO Auto-generated method stub
    		System.out.println("The afterReturning method of AfterReturningAdvice is getting executed");
    	}
    
    }
    And the following code is the driver class which invokes "invokeSomeService" method.
    Code:
    package com.emmes.test;
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    import com.emmes.service.ITestAfterReturnAdvisor;
    import com.emmes.service.impl.TestAfterReturnAdvisorImpl;
    
    public class Driver {
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		//need the nindscrc-context-localtest.xml to load all the lookupServices and all
    		final Log logger = LogFactory.getLog(Driver.class);
    		ApplicationContext context = new ClassPathXmlApplicationContext
    		(new String[]{"applicationContext.xml"});		
    		logger.info("context is: " + context);
    		logger.info("*****Context is Loaded*****");
    		ITestAfterReturnAdvisor testReturnAdvisorService = (ITestAfterReturnAdvisor)context.getBean("testService");
    		testReturnAdvisorService.invokeSomeService();
    	}
    }
    I am using spring framework 2.5.2 with jdk1.6 Am I missing anything here?
    Last edited by mmutham; Jul 14th, 2008, 12:58 PM. Reason: providing more information

  • #2
    Check your classpath for old jars or incompatible versions.

    Comment


    • #3
      Thanks. It works now.

      Comment


      • #4
        Im having the same exception using Spring-2.5.5 and Struts-2.1.2, but my stackTrace is slightly different:

        Code:
        java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.makeAccessible(Ljava/lang/reflect/Constructor;)V
                at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83)
                at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:62)
                at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:249)
                at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
                at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
                at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
        When I switch the application to Struts-2.0.11.2 (just changing the classpath) it works nicely.

        I also checked for old jars and found nothing...

        Anyone knows how to solve this?

        Comment


        • #5
          I had a similar problem, while trying to deploy spring framework on websphere. The problem occurred due to co-existence of spring-2.0.6.jar and spring-core-2.5.6.jar in my class-path.

          Comment

          Working...
          X