Gettin NoSuchMethodError while starting a spring web application with jetty runner

HI,
I have a very basic spring web application. I am using the intellij jetty runner.
Here is the exception i am getting :
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/1-SimpleObjectCreation/target/classes:/Users/robinsuri/.m2/repository/org/springframework/spring/2.5.6/spring-2.5.6.jar:/Users/robinsuri/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/2-SimpleObjectCreation/target/classes:/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/2-SimpleDI/target/classes:/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/3-Spring-Autowiring/target/classes:/Users/robinsuri/.m2/repository/org/springframework/spring-core/4.1.1.RELEASE/spring-core-4.1.1.RELEASE.jar:/Users/robinsuri/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-aop/4.1.1.RELEASE/spring-aop-4.1.1.RELEASE.jar:/Users/robinsuri/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-beans/4.1.1.RELEASE/spring-beans-4.1.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-expression/4.1.1.RELEASE/spring-expression-4.1.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar:/Users/robinsuri/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/Users/robinsuri/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/robinsuri/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/Users/robinsuri/.m2/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar:/Users/robinsuri/.m2/repository/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar:/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/4-Spring-MVC/target/classes:/Users/robinsuri/.m2/repository/org/springframework/spring-core/4.0.0.RELEASE/spring-core-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-web/4.0.0.RELEASE/spring-web-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-aop/4.0.0.RELEASE/spring-aop-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-beans/4.0.0.RELEASE/spring-beans-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-jdbc/4.0.0.RELEASE/spring-jdbc-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-tx/4.0.0.RELEASE/spring-tx-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-webmvc/4.0.0.RELEASE/spring-webmvc-4.0.0.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-expression/4.0.0.RELEASE/spring-expression-4.0.0.RELEASE.jar:/Users/robinsuri/Library/Application Support/IdeaIC2016.1/jetty-runner/lib/eclipse-jetty-runner-9.2.5.jar" org.eclipse.jetty.runner.Runner --port 9999 --path /MVC-DI-Tutorial "/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/4-Spring-MVC/src/main/webapp" --classes "/Users/robinsuri/Documents/Mumbai Session/MVC-DI-Tutorial/4-Spring-MVC/target/classes"
log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
	at org.springframework.core.convert.support.GenericConversionService.<clinit>(GenericConversionService.java:81)
	at org.springframework.core.env.AbstractPropertyResolver.<init>(AbstractPropertyResolver.java:41)
	at org.springframework.core.env.PropertySourcesPropertyResolver.<init>(PropertySourcesPropertyResolver.java:41)
	at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:112)
	at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
	at org.springframework.web.context.support.StandardServletEnvironment.<init>(StandardServletEnvironment.java:44)
	at org.springframework.web.servlet.HttpServletBean.createEnvironment(HttpServletBean.java:215)
	at org.springframework.web.servlet.HttpServletBean.getEnvironment(HttpServletBean.java:205)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612)
	at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395)
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871)
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1343)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1336)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.server.Server.start(Server.java:387)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.Server.doStart(Server.java:354)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.runner.Runner.run(Runner.java:509)
	at org.eclipse.jetty.runner.Runner.main(Runner.java:557)

Process finished with exit code 137

Open in new window


Here is my web.xml :
<web-app version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<display-name>Spring MVC Application</display-name>

    <servlet>
		<servlet-name>mvc-dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>mvc-dispatcher</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

Open in new window


And i am using spring version = <spring.version>4.0.0.RELEASE</spring.version>
I tried with the latest versions also the error is same.
what other ways i can run my web application apart from jetty runner probably that may be causing the issue.
Also i tried one way to put the war in webapps directory of jetty and run it using the command :
java -jar start.jar -Djetty.port=9999
But i am getting the following on loading of localhost:9999/ :

Error 404 - Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:
    /SpringMVC-Example ---> o.e.j.w.WebAppContext@6093dd95{/SpringMVC-Example,file:///private/var/folders/yq/z3p_8xj94fj62fm65nhmd6f40000gp/T/jetty-0.0.0.0-9999-SpringMVC-Example.war-_SpringMVC-Example-any-7587907549185730601.dir/webapp/,AVAILABLE}{/SpringMVC-Example.war}
 Powered by Jetty:// 9.3.10.v20160621
Rohit BajajAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
Your first issue appears to be related to library versioning issues. The "getMethod" method that it is looking for was not present in earlier versions of Spring. Now I not saying that you don't have the latest version in use, but it may be that you (or some other dependency) is including an old version of the Spring util module in addition to what you have.

Are you using Maven or can you look through the JAR's that are being included in your project?


As for your second issue, you just need to specific the context in the URL that you are requesting. So something like....    http://localhost:9999/SpringMVC-Example
0
 
Rohit BajajAuthor Commented:
Hi,
Here is the complete project : https://github.com/robinsuri/MVC-DI-Tutorial/tree/master/4-Spring-MVC
 I think something is probably fundamentally wrong.
But need comments from experts to understand it.
In one class there is :
public class UserRepository {
    @Autowired private JdbcTemplate jdbcTemplate;

But nowhere anybean with name etc jdbcTemplate has been defined.
0
 
Rohit BajajAuthor Commented:
As for your second issue, you just need to specific the context in the URL that you are requesting. So something like....    http://localhost:9999/SpringMVC-Example
I found that SpringMVC-Example was used at only one place in project in pom.xml like :
<build>
        <finalName>SpringMVC-Example</finalName>
        <plugins>
            <plugin>

This is under the build section.
Is the context which you write above is the applicationContext which Spring creates ?
How is the url name related to context name that spring creates.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.