Solved

Gettin NoSuchMethodError while starting a spring web application with jetty runner

Posted on 2016-07-24
3
61 Views
Last Modified: 2016-08-11
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
0
Comment
Question by:Rohit Bajaj
  • 2
3 Comments
 

Author Comment

by:Rohit Bajaj
ID: 41726552
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
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 41726876
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
 

Author Comment

by:Rohit Bajaj
ID: 41728265
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert BufferedReader to File 1 75
hasOne  challenge 59 124
groupSum6 challenge 6 76
mapBully challenge 6 113
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now