java - Spring junit NoSuchMethodException -
getting below error junit test case. can please suggest should clear error. using maven build tool spring 4.3.2 , junit 4.12.
org.springframework.test.context.support.abstracttestcontextbootstrapper getdefaulttestexecutionlistenerclassnames info: loaded default testexecutionlistener class names location [meta-inf/spring.factories]: [org.springframework.test.context.web.servlettestexecutionlistener, org.springframework.test.context.support.dirtiescontextbeforemodestestexecutionlistener, org.springframework.test.context.support.dependencyinjectiontestexecutionlistener, org.springframework.test.context.support.dirtiescontexttestexecutionlistener, org.springframework.test.context.transaction.transactionaltestexecutionlistener, org.springframework.test.context.jdbc.sqlscriptstestexecutionlistener] 07-sep-2016 18:19:17 org.springframework.test.context.support.abstracttestcontextbootstrapper gettestexecutionlisteners info: using testexecutionlisteners: [org.springframework.test.context.web.servlettestexecutionlistener@691f36, org.springframework.test.context.support.dirtiescontextbeforemodestestexecutionlistener@18020cc, org.springframework.test.context.support.dependencyinjectiontestexecutionlistener@e94e92, org.springframework.test.context.support.dirtiescontexttestexecutionlistener@12558d6, org.springframework.test.context.transaction.transactionaltestexecutionlistener@eb7859, org.springframework.test.context.jdbc.sqlscriptstestexecutionlistener@12a54f9] 07-sep-2016 18:19:18 org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions info: loading xml bean definitions class path resource [testcontext.xml] 07-sep-2016 18:19:18 org.springframework.context.support.abstractapplicationcontext preparerefresh info: refreshing org.springframework.context.support.genericapplicationcontext@df8f5e: startup date [wed sep 07 18:19:18 ist 2016]; root of context hierarchy 07-sep-2016 18:19:18 org.springframework.core.io.support.propertiesloadersupport loadproperties info: loading properties file class path resource [ldap_dev.properties] slf4j: failed load class "org.slf4j.impl.staticloggerbinder". slf4j: defaulting no-operation (nop) logger implementation slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. 07-sep-2016 18:19:18 org.springframework.test.context.testcontextmanager preparetestinstance severe: caught exception while allowing testexecutionlistener [org.springframework.test.context.support.dependencyinjectiontestexecutionlistener@e94e92] prepare test instance [com.bt.dnp.ldap.util.ldapsynctest@9505f] java.lang.nosuchmethoderror: org.springframework.aop.scope.scopedproxyutils.isscopedtarget(ljava/lang/string;)z @ org.springframework.context.event.eventlistenermethodprocessor.aftersingletonsinstantiated(eventlistenermethodprocessor.java:79) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:796) @
my java class : using java 1.8.
import java.io.unsupportedencodingexception; import javax.naming.namingexception; import org.junit.after; import org.junit.before; import org.junit.test; import org.junit.runner.runwith; import org.springframework.beans.factory.annotation.autowired; import org.springframework.ldap.core.ldaptemplate; import org.springframework.test.context.contextconfiguration; import org.springframework.test.context.junit4.springjunit4classrunner; @runwith(springjunit4classrunner.class) @contextconfiguration("classpath:testcontext.xml") public class ldapsynctest { private ldapsync ldapsync = null; @autowired private ldaptemplate ldaptemplate; @before public void init() { ldapsync = new ldapsync(); ldapsync.setldaptemplate(ldaptemplate); } @test public void testpasswordsync() throws unsupportedencodingexception, namingexception { ldapsync.dopwdupdate("rajak1@bt.com", "uid", "btcom", "tcs@12345"); } }
try adding pom:
<dependency> <groupid>org.springframework</groupid> <artifactid>spring-aop</artifactid> <version>4.3.2.release</version> </dependency>
your error shows spring-context
trying call spring-aop
's scopedproxyutils.isscopedtarget(string beanname)
.
that method present in 4.3.2 (since 2.5), can means spring-aop's runtime dependency wrong.
before adding dependency above, may go in console , type type mvn dependency:tree -dincludes=org.springframework:spring-aop
, you'll find wrong version coming from.
Comments
Post a Comment