Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getResourceLoader()Lorg/springframework/core/io/ResourceLoader

I am working on a Spring application on Tomcat7, JDK1.7, Maven and other components. Recently, I made a major change to the application, requiring switching over to Spring 3. After the change, I'm seeing the below exception on deploying to dev server. The application runs flawlessly on my local system though.

javax.servlet.ServletException: Servlet.init() for servlet amadeusAce threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
root cause

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/amadeusAce-servlet.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getResourceLoader()Lorg/springframework/core/io/ResourceLoader;
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:375)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
    org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:298)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:311)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:258)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:229)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.java:160)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
root cause

java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getResourceLoader()Lorg/springframework/core/io/ResourceLoader;
    org.springframework.context.annotation.ComponentScanBeanDefinitionParser.configureScanner(ComponentScanBeanDefinitionParser.java:100)
    org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:83)
    org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
    org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1114)
    org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1104)
    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
    org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:298)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:311)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:258)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:229)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.java:160)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)

I don't think there's any issue with the said xml amadeusAce-servlet.xml as well because there there is no change in the file since last deployment.

POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ace.amadeus</groupId>
    <artifactId>AmadeusSpring</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>
    <name>Simple CXF project using spring configuration</name>
    <repositories>
        <repository>
            <id>JBoss repository</id>
            <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
        </repository>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net2</id>
            <name>Java.net</name>
            <url>https://oss.sonatype.org/content/repositories/java.net2</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>0.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-ibatis</artifactId>
            <version>2.0.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.0.5.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springmodules</groupId>
            <artifactId>spring-modules-validation</artifactId>
            <version>0.8a</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>2.0.7</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>20030825.183949</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ibatis</groupId>
            <artifactId>ibatis-sqlmap</artifactId>
            <version>2.3.4.726</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>uk.com.robust-it</groupId>
            <artifactId>cloning</artifactId>
            <version>1.8.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>sax</groupId>
            <artifactId>sax</artifactId>
            <version>2.0.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Anything you can see from the above resources?? I'd absolutely love to hear from you. Thank you.

EDIT:
As suggested in the below post, I found out the classpath from where dependencies are resolved. Results below:

file:/D:/ace-amadeus-ws/AmadeusSpring/target/classes/
file:/C:/Users/pc/.m2/repository/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/httpcomponents/httpcore/4.2.2/httpcore-4.2.2.jar
file:/C:/Users/pc/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
file:/C:/Users/pc/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
file:/C:/Users/pc/.m2/repository/javax/ws/rs/jsr311-api/0.2/jsr311-api-0.2.jar
file:/C:/Users/pc/.m2/repository/com/sun/jersey/jersey-server/1.8/jersey-server-1.8.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxws/2.1.3/cxf-rt-frontend-jaxws-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-jaxws_2.1_spec/1.0/geronimo-jaxws_2.1_spec-1.0.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.2/geronimo-activation_1.1_spec-1.0.2.jar
file:/C:/Users/pc/.m2/repository/asm/asm/2.2.3/asm-2.2.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-api/2.1.3/cxf-api-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-common-utilities/2.1.3/cxf-common-utilities-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar
file:/C:/Users/pc/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar
file:/C:/Users/pc/.m2/repository/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/ws/commons/schema/XmlSchema/1.4.2/XmlSchema-1.4.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/geronimo-annotation_1.0_spec-1.1.1.jar
file:/C:/Users/pc/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6.jar
file:/C:/Users/pc/.m2/repository/org/apache/neethi/neethi/2.0.4/neethi-2.0.4.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-common-schemas/2.1.3/cxf-common-schemas-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-core/2.1.3/cxf-rt-core-2.1.3.jar
file:/C:/Users/pc/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.7/jaxb-impl-2.1.7.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.3/geronimo-javamail_1.4_spec-1.3.jar
file:/C:/Users/pc/.m2/repository/com/sun/xml/fastinfoset/FastInfoset/1.2.2/FastInfoset-1.2.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-bindings-soap/2.1.3/cxf-rt-bindings-soap-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-tools-common/2.1.3/cxf-tools-common-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
file:/C:/Users/pc/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.1.7/jaxb-xjc-2.1.7.jar
file:/C:/Users/pc/.m2/repository/org/apache/geronimo/specs/geronimo-ws-metadata_2.0_spec/1.1.2/geronimo-ws-metadata_2.0_spec-1.1.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-databinding-jaxb/2.1.3/cxf-rt-databinding-jaxb-2.1.3.jar
file:/C:/Users/pc/.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.1.3/cxf-rt-bindings-xml-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-frontend-simple/2.1.3/cxf-rt-frontend-simple-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-ws-addr/2.1.3/cxf-rt-ws-addr-2.1.3.jar
file:/C:/Users/pc/.m2/repository/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar
file:/C:/Users/pc/.m2/repository/com/sun/xml/messaging/saaj/saaj-impl/1.3.2/saaj-impl-1.3.2.jar
file:/C:/Users/pc/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.1.3/cxf-rt-transports-http-2.1.3.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-web/3.0.5.RELEASE/spring-web-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-context/3.0.5.RELEASE/spring-context-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-webmvc/3.0.5.RELEASE/spring-webmvc-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-context-support/3.0.5.RELEASE/spring-context-support-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-expression/3.0.5.RELEASE/spring-expression-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-ibatis/2.0.8/spring-ibatis-2.0.8.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-dao/2.0.8/spring-dao-2.0.8.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-jdbc/2.0.8/spring-jdbc-2.0.8.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-aop/3.0.5.RELEASE/spring-aop-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring-aspects/3.0.5.RELEASE/spring-aspects-3.0.5.RELEASE.jar
file:/C:/Users/pc/.m2/repository/org/springmodules/spring-modules-validation/0.8a/spring-modules-validation-0.8a.jar
file:/C:/Users/pc/.m2/repository/commons-lang/commons-lang/2.2/commons-lang-2.2.jar
file:/C:/Users/pc/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
file:/C:/Users/pc/.m2/repository/commons-validator/commons-validator/1.3.0/commons-validator-1.3.0.jar
file:/C:/Users/pc/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
file:/C:/Users/pc/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
file:/C:/Users/pc/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
file:/C:/Users/pc/.m2/repository/commons-digester/commons-digester/1.7/commons-digester-1.7.jar
file:/C:/Users/pc/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
file:/C:/Users/pc/.m2/repository/org/springframework/spring/2.0.3/spring-2.0.3.jar
file:/C:/Users/pc/.m2/repository/rhino/js/1.6R2/js-1.6R2.jar
file:/C:/Users/pc/.m2/repository/org/apache/tiles/tiles-jsp/2.0.7/tiles-jsp-2.0.7.jar
file:/C:/Users/pc/.m2/repository/org/apache/tiles/tiles-core/2.0.7/tiles-core-2.0.7.jar
file:/C:/Users/pc/.m2/repository/org/apache/tiles/tiles-api/2.0.7/tiles-api-2.0.7.jar
file:/C:/Users/pc/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
file:/C:/Users/pc/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar
file:/C:/Users/pc/.m2/repository/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar
file:/C:/Users/pc/.m2/repository/taglibs/standard/1.1.2/standard-1.1.2.jar
file:/C:/Users/pc/.m2/repository/commons-dbcp/commons-dbcp/20030825.184428/commons-dbcp-20030825.184428.jar
file:/C:/Users/pc/.m2/repository/commons-pool/commons-pool/20030825.183949/commons-pool-20030825.183949.jar
file:/C:/Users/pc/.m2/repository/org/apache/ibatis/ibatis-sqlmap/2.3.4.726/ibatis-sqlmap-2.3.4.726.jar
file:/C:/Users/pc/.m2/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar
file:/C:/Users/pc/.m2/repository/uk/com/robust-it/cloning/1.8.2/cloning-1.8.2.jar
file:/C:/Users/pc/.m2/repository/org/objenesis/objenesis/1.2/objenesis-1.2.jar
file:/C:/Users/pc/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
file:/C:/Users/pc/.m2/repository/sax/sax/2.0.1/sax-2.0.1.jar
like image 536
James Avatar asked Nov 30 '12 10:11

James


1 Answers

java.lang.NoSuchMethodError occur if there is some issue with the jar loaded. I think that on the system that you are trying to run this code on, has CLASSPATH set to some path which is loading the older version of the jar. Use the following code to find out the paths from where the ClassLoader is resolving the dependencies

public static void main(String[] args) {
            URLClassLoader classLoader = (URLClassLoader)Main.class.getClassLoader();
            System.out.println(Arrays.toString(classLoader.getURLs()));
    }

Put this method in Main class and execute it in the system that is giving this error. It will show you all the paths from where the dependencies have been resolved. Find out if any of the paths have older version of the jar.

Hope this helps your cause.

like image 147
Narendra Pathai Avatar answered Sep 19 '22 06:09

Narendra Pathai