Rohit Bajaj
asked on
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 :
Here is my web.xml :
And i am using spring version = <spring.version>4.0.0.RELE ASE</sprin g.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@6093 dd95{/Spri ngMVC-Exam ple,file:/ //private/ var/folder s/yq/z3p_8 xj94fj62fm 65nhmd6f40 000gp/T/je tty-0.0.0. 0-9999-Spr ingMVC-Exa mple.war-_ SpringMVC- Example-an y-75879075 4918573060 1.dir/weba pp/,AVAILA BLE}{/Spri ngMVC-Exam ple.war}
Powered by Jetty:// 9.3.10.v20160621
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
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>
And i am using spring version = <spring.version>4.0.0.RELE
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@6093
Powered by Jetty:// 9.3.10.v20160621
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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-Examp le</finalN ame>
<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.
I found that SpringMVC-Example was used at only one place in project in pom.xml like :
<build>
<finalName>SpringMVC-Examp
<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.
ASKER
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.