Giter Site home page Giter Site logo

spring-mvc-showcase's Introduction

spring-mvc-showcase is no longer actively maintained by VMware, Inc.

Spring MVC Showcase

Demonstrates the capabilities of the Spring MVC web framework through small, simple examples. After reviewing this showcase, you should have a good understanding of what Spring MVC can do and get a feel for how easy it is to use. Includes project code along with a supporting slideshow and screen cast.

In this showcase you'll see the following in action:

  • The simplest possible @Controller
  • Mapping Requests
  • Obtaining Request Data
  • Generating Responses
  • Message Converters
  • Rendering Views
  • Type Conversion
  • Validation
  • Forms
  • File Upload
  • Exception Handling

To get the code:

Clone the repository:

$ git clone git://github.com/SpringSource/spring-mvc-showcase.git

If this is your first time using Github, review https://help.github.com to learn the basics.

To run the application:

From the command line with Maven:

$ cd spring-mvc-showcase
$ mvn jetty:run 

Access the deployed web application at: http://localhost:8080/spring-mvc-showcase/

Note:

This showcase originated from a blog post and was adapted into a SpringOne presentation called Mastering MVC 3.

A screen cast showing the showcase in action is available in QuickTime format.

spring-mvc-showcase's People

Contributors

adrianpillinger avatar djbrieck avatar huguangju avatar mnorbury avatar pledbrook avatar rstoyanchev avatar rwinch avatar sbiyyala avatar sdeleuze avatar spring-operator avatar trevormarshall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-mvc-showcase's Issues

Add test for "forward:..."

There is a test for a controller that uses "redirect:..." views but none for "forward:..." (and it seems to be non-obvious how to get the mock request dispatcher to dispatch back to the main servlet).

Can't build application

Hello,

i tried to build the application on command-line.
But it doesn't work, her is my log.

noname:spring-mvc-showcase christianhenle$ mvn tomcat7:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-mvc-showcase 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.0:run (default-cli) @ spring-mvc-showcase >>>
[INFO]
[INFO] --- aspectj-maven-plugin:1.2:compile (default) @ spring-mvc-showcase ---
[ERROR] The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] HttpServletRequest cannot be resolved to a type
[ERROR] The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
[ERROR] The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] HttpServletRequest cannot be resolved to a type
[ERROR] The type org.joda.time.base.BaseLocal cannot be resolved. It is indirectly referenced from required .class files
[ERROR] The import org.hibernate.validator.constraints.NotEmpty cannot be resolved
[ERROR] NotEmpty cannot be resolved to a type
[ERROR] The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files
[ERROR] The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] The import javax.servlet.http.HttpServletResponse cannot be resolved
[ERROR] The import javax.servlet.http.HttpSession cannot be resolved
[ERROR] HttpServletRequest cannot be resolved to a type
[ERROR] HttpServletResponse cannot be resolved to a type
[ERROR] HttpSession cannot be resolved to a type
[ERROR] The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] HttpServletRequest cannot be resolved to a type
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.003s
[INFO] Finished at: Thu Dec 19 22:25:08 CET 2013
[INFO] Final Memory: 11M/147M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (default) on project spring-mvc-showcase: Compiler errors :
[ERROR] error at import javax.servlet.http.HttpServletRequest;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java:3:0::0 The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] error at public @responsebody String byPathPattern(HttpServletRequest request) {
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java:21:0::0 HttpServletRequest cannot be resolved to a type
[ERROR] error at result.setResult(new ModelAndView("views/html", "javaBean", new JavaBean("bar", "apple")));
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java:66:0::0 The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
[ERROR] error at import javax.servlet.http.HttpServletRequest;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java:3:0::0 The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] error at public @responsebody String byPathPattern(HttpServletRequest request) {
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java:21:0::0 HttpServletRequest cannot be resolved to a type
[ERROR] error at (no source information available)
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/redirect/RedirectController.java:1:0::0 The type org.joda.time.base.BaseLocal cannot be resolved. It is indirectly referenced from required .class files
[ERROR] error at import org.hibernate.validator.constraints.NotEmpty;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/form/FormBean.java:10:0::0 The import org.hibernate.validator.constraints.NotEmpty cannot be resolved
[ERROR] error at @notempty
[ERROR] ^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/form/FormBean.java:19:0::0 NotEmpty cannot be resolved to a type
[ERROR] error at (no source information available)
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:1:0::0 The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files
[ERROR] error at import javax.servlet.http.HttpServletRequest;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:11:0::0 The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] error at import javax.servlet.http.HttpServletResponse;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:12:0::0 The import javax.servlet.http.HttpServletResponse cannot be resolved
[ERROR] error at import javax.servlet.http.HttpSession;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:13:0::0 The import javax.servlet.http.HttpSession cannot be resolved
[ERROR] error at public @responsebody String standardRequestArgs(HttpServletRequest request, Principal user, Locale locale) {
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:27:0::0 HttpServletRequest cannot be resolved to a type
[ERROR] error at public @responsebody String response(HttpServletResponse response) {
[ERROR] ^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:48:0::0 HttpServletResponse cannot be resolved to a type
[ERROR] error at public @responsebody String session(HttpSession session) {
[ERROR] ^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java:65:0::0 HttpSession cannot be resolved to a type
[ERROR] error at import javax.servlet.http.HttpServletRequest;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java:3:0::0 The import javax.servlet.http.HttpServletRequest cannot be resolved
[ERROR] error at void beforeInvokingHandlerMethod(HttpServletRequest request) {
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] /Users/christianhenle/git/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java:15:0::0 HttpServletRequest cannot be resolved to a type
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

JPA addition

Are you considering to work on a database and use a JPA provider for this project?

Bug in ConvertControllerTests when executed in the UK during autumn/winter

The tests setup a static variable called TIMEZONE. In the UK this is not the same all year round, during spring/summer it is BST, during autumn/winter it is GMT.

The dates being tested are all BST, but now that I am executing the test after the clocks have gone back an hour (i.e. into GMT) they are failing.

e.g.

date(org.springframework.samples.mvc.convert.ConvertControllerTests) Time elapsed: 0.094 sec <<< FAILURE!
java.lang.AssertionError: Response content
Expected: "Converted date Sun Jul 04 00:00:00 GMT 2010"
got: "Converted date Sun Jul 04 00:00:00 BST 2010"

I am happy to fix, just not the time right at this moment, so am logging for now. If anyone gets to this before I do, feel free to fix it :-)

HTTP Status 500 - Servlet.init() for servlet appServlet threw exception

type Exception report

message Servlet.init() for servlet appServlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.samples.mvc.data.custom.CustomArgumentResolver]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:605)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause

java.lang.IllegalArgumentException: Cannot find class [org.springframework.samples.mvc.data.custom.CustomArgumentResolver]
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:287)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.wrapLegacyResolvers(AnnotationDrivenBeanDefinitionParser.java:504)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.getArgumentResolvers(AnnotationDrivenBeanDefinitionParser.java:493)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:215)
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1411)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:168)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:138)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:605)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause

java.lang.ClassNotFoundException: org.springframework.samples.mvc.data.custom.CustomArgumentResolver
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.wrapLegacyResolvers(AnnotationDrivenBeanDefinitionParser.java:504)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.getArgumentResolvers(AnnotationDrivenBeanDefinitionParser.java:493)
org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:215)
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1411)
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:168)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:138)
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:605)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.28 logs.

Error on pom.xml

Using Eclipe plugin Maven Integration for Eclipse 1.5.0:

On line 271:
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>

Error:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (execution: default, phase: process-sources)

I have solved it adding an <id> and <phase> tags to the <execution> block.

STS project files missing

Just got started using STS and I couldn't help but notice that the project files are missing; could I be missing something? I cloned the repository but cannot seem to find the project files.

Bootify!

This is the 2nd most popular repo in GitHub spring-projects, but it's still using Xml for everything and no spring boot! Pull request to follow (time permitting).

Joda Time library should be updated from 1.6.2 to current version (2.3)

Hello spring-projects,

let me first thank you for the great set of examples provided by this project. For someone (like me) who is relatively new to Spring MVC this is of great help.

I would like to report the following:
with the currently shipped version of the Joda Time library (1.6.2) the spring-mvc-showcase throws an error when trying to use the "Redirecting" examples (org.springframework.samples.mvc.redirect, that rely on org.joda.time.LocalDate;).

Error:
cannot resolve org.joda.time.format.DateTimeFormatter.parseLocalDate

This is due to the Joda Time library (1.6.2) does not contain the parseLocalDate method, which is available only from version 2.0 of the Joda Time libraries.
See details that confirm this:
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormatter.html#parseLocalDate(java.lang.String)

If the dependecy in pom.xml could be updated that would be great.

Tested with Eclipse Kepler, Tomcat 7.047, Java 1.7.0 (build 1.7.0-b147)

Kamil

Request Data -> Matrix Variable. Return wrong value.

Im new to Spring MVC, thanks to this repository, I learn a lot. I currently face a issue is the return value of Request Data-> Matrix Variable. according to the code:

@RequestMapping(value="{path}/simple", method=RequestMethod.GET)
public @ResponseBody String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) {
    logger.debug("path is" + path + "foo is " + foo);
    return "Obtained matrix variable 'foo=" + foo + "' from path segment '" + path + "'";
}

it should return that string, but the string shown on the html is "hello world!". I can find where the hello world comes from. Could anyone help?

Besides, withMatrixVariablesMultiple got a 404 error.

Steven

Can't load properties when starting use tomcat7 + eclipse (4.2)

Untitled

When checked "Serve modules without publishing" can't start project, but uncheck is ok. why?

I need load a properties file, then add config in root-context.xml.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- Root Context: defines shared resources visible to all other web components -->
        <context:property-placeholder ignore-unresolvable="true"
            location="classpath*:/application.properties" />
</beans>

Full error log:

Jan 01, 2013 1:24:43 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/henryyan/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Jan 01, 2013 1:24:43 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:spring-mvc-showcase' did not find a matching property.
Jan 01, 2013 1:24:43 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context/Loader} Setting property 'useSystemClassLoaderAsParent' to 'false' did not find a matching property.
Jan 01, 2013 1:24:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 01, 2013 1:24:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 01, 2013 1:24:44 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 758 ms
Jan 01, 2013 1:24:44 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 01, 2013 1:24:44 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
Jan 01, 2013 1:24:45 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 01, 2013 1:24:45 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
01:24:45 [localhost-startStop-1] ContextLoader - Root WebApplicationContext: initialization started
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Initializing new StandardServletEnvironment
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [servletConfigInitParams] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [servletContextInitParams] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [jndiProperties] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
01:24:46 [localhost-startStop-1] XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 01 01:24:46 CST 2013]; root of context hierarchy
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Replacing [servletContextInitParams] PropertySource with [servletContextInitParams]
01:24:46 [localhost-startStop-1] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
01:24:46 [localhost-startStop-1] XmlWebApplicationContext - Bean factory for Root WebApplicationContext: org.springframework.beans.factory.support.DefaultListableBeanFactory@29e3889a: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0]; root of factory hierarchy
01:24:46 [localhost-startStop-1] PropertyPlaceholderConfigurer - Loading properties file from URL [file:/Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties]
01:24:46 [localhost-startStop-1] DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29e3889a: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0]; root of factory hierarchy
01:24:46 [localhost-startStop-1] ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:125)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
... 16 more
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:125)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
... 16 more

Jan 01, 2013 1:24:46 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 01, 2013 1:24:46 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [134] milliseconds.
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/spring-mvc-showcase] startup failed due to previous errors
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/docs
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/examples
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@3b15947b')
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/host-manager
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/manager
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/ROOT
Jan 01, 2013 1:24:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 01, 2013 1:24:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2598 ms

org.springframework.samples.mvc.form.FormController.processSubmit has invalid ajaxRequest argument.

The argument is not documented in @RequestMapper javadoc -> http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html.

Also, ajaxRequest is not a request parameter, but a model attribute set by ajaxAttribute method in the same file.

I think, the test for ajax in processSubmit shoud be rewritten like this:

final Boolean isAjaxRequest = (Boolean) model.asMap( ).get( "ajaxRequest" );

if ( isAjaxRequest != null && isAjaxRequest.booleanValue( ) ) {
...

And ajaxRequest should be retired from the method signature. Currently it always evaluates to false.

Does not run on JDK8

Just cloned and ran mvn tomcat7:run

Navigating to localhost:8080/spring-mvc-showcase/ gives me below stack trace.

After doing a little searching, looks like this is a problem with either the Tomcat 7 version or Glassfish jstl-impl version.

HTTP Status 500 - Unable to compile class for JSP:

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1229)
    org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.

Apache Tomcat/7.0.30

Can't Resolve Symbol asyncDispatch

@commit 18da3dc created a dependency error for

@test.java.o.s.samples.mvc.async.*

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch

HTTP Status 403 - Expected CSRF token not found. Has your session expired?

My problem was different with "HTTP Status 403 - Expected CSRF token not found #29" at "#29".

When I send post request to access the URL with Java CloseableHttpClient, I get the result as fllowing.

<html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - Expected CSRF token not found. Has your session expired?</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Expected CSRF token not found. Has your session expired?</u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.47</h3></body></html>

The main codes as fllowing:

String url  = "http://127.0.0.1:9123/spring-mvc-showcase/data/body";

//配置请求参数
		RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(2000).setConnectTimeout(2000).setSocketTimeout(2000).build();
		//创建自定义的httpClient实例
		CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
		//创建httpPost
		HttpPost post = new HttpPost(url);

CloseableHttpResponse response = httpClient.execute(post);
			HttpEntity respEntity = response.getEntity();

But, when I sent get request, it can work rightly.

Why this error?
What shoud I do to solve this?

HTTP Status 500 - Servlet.init() for servlet dispatcher threw exception

15:09:59.863 [http-apr-8080-exec-6] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:676) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:545) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499) [spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172) [spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) [servlet-api.jar:3.0.FR]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269) [catalina.jar:7.0.84]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:869) [catalina.jar:7.0.84]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135) [catalina.jar:7.0.84]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) [catalina.jar:7.0.84]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) [catalina.jar:7.0.84]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.84]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.84]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) [catalina.jar:7.0.84]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.84]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) [catalina.jar:7.0.84]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) [tomcat-coyote.jar:7.0.84]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.84]
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555) [tomcat-coyote.jar:7.0.84]
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544) [tomcat-coyote.jar:7.0.84]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_202]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.84]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:392) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:364) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.mvcValidator() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getConfigurableWebBindingInitializer(WebMvcConfigurationSupport.java:605) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerAdapter(WebMvcConfigurationSupport.java:566) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.CGLIB$requestMappingHandlerAdapter$26() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044$$FastClassBySpringCGLIB$$1538d5a4.invoke() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.requestMappingHandlerAdapter() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 34 more
Caused by: java.lang.NoClassDefFoundError: javax/el/ELManager
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:88) ~[hibernate-validator-6.0.7.Final.jar:6.0.7.Final]
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.(ResourceBundleMessageInterpolator.java:47) ~[hibernate-validator-6.0.7.Final.jar:6.0.7.Final]
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolator(ConfigurationImpl.java:461) ~[hibernate-validator-6.0.7.Final.jar:6.0.7.Final]
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:272) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.java:40) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:392) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:364) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.mvcValidator() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getConfigurableWebBindingInitializer(WebMvcConfigurationSupport.java:605) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerAdapter(WebMvcConfigurationSupport.java:566) ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.CGLIB$requestMappingHandlerAdapter$26() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044$$FastClassBySpringCGLIB$$1538d5a4.invoke() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9082e044.requestMappingHandlerAdapter() ~[spring-webmvc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 34 more

Project has been tested on tomcat -8.5.24

Hi,
There were some issue around ClassNotFoundException . So I have fixed the dependency which make it working now.

	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>2.9.3</version> <!-- this is the latest -->
	</dependency>
	<dependency>
		<groupId>javax.validation</groupId>
		<artifactId>validation-api</artifactId>
		<version>2.0.1.Final</version> <!-- latest-->			
	</dependency>
	
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>6.0.7.Final</version> <!-- latest -->
	</dependency>

It would be great if somebody upgrade the maven pom file.

Regards,
Alan Meiho

html injection

in /spring-mvc-showcase/src/main/webapp/WEB-INF/views/form.jsp
u forget to write a c:out tag in <div id="message" class="success">${message}</div>
so if u input a name like "Test<script>alert('abc')</script>", and click submit button, you will see what i mean

Already downloaded it but still not working

I have imported it already in my IDE(Spring tool suite) however I cannot seem to run it. I've installed it as a General Project, how would I run it on the server? also where are the view files?

Async Requests Tab

Hello,

I am getting the following error when try to access the async requests tab:

java.lang.UnsupportedOperationException: No async support in a pre-Servlet 3.0 runtime

i was just wondering if anyone else encountered such a problem.

Many thanks for your time.

Pishty

[ERROR] COMPILATION ERROR

I tried mvn jetty:run but could not as it gave me the following error trace:

howcase (master) $ mvn jetty:run
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.springframework.samples:spring-mvc-showcase:war:1.0.0-BUILD-SNAPSHOT
[WARNING] 'dependencies.dependency.version' for org.apache.logging.log4j:log4j-core:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 48, column 13
[WARNING] 'dependencies.dependency.version' for org.apache.logging.log4j:log4j-slf4j-impl:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 53, column 13
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 183, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------< org.springframework.samples:spring-mvc-showcase >-----------
[INFO] Building spring-mvc-showcase 1.0.0-BUILD-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:9.4.8.v20171121:run (default-cli) > test-compile @ spring-mvc-showcase >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spring-mvc-showcase ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-mvc-showcase ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 40 source files to /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/target/classes
[INFO] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/form/FormBean.java: Some input files use or override a deprecated API.
[INFO] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/form/FormBean.java: Recompile with -Xlint:deprecation for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/messageconverters/JavaBean.java:[4,33] package javax.xml.bind.annotation does not exist
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/messageconverters/JavaBean.java:[6,2] cannot find symbol
  symbol: class XmlRootElement
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/JavaBean.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/JavaBean.java:[5,2] cannot find symbol
  symbol: class XmlRootElement
[INFO] 4 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.383 s
[INFO] Finished at: 2019-03-31T09:31:00+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project spring-mvc-showcase: Compilation failure: Compilation failure: 
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/messageconverters/JavaBean.java:[4,33] package javax.xml.bind.annotation does not exist
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/messageconverters/JavaBean.java:[6,2] cannot find symbol
[ERROR]   symbol: class XmlRootElement
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/JavaBean.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /media/nobu/Ubuntu Backup/Comp Sci/Web/Java/spring-mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/JavaBean.java:[5,2] cannot find symbol
[ERROR]   symbol: class XmlRootElement
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

installation

Hello, java noobie here. I was just wondering if i can have more detail on how to install this, do i just run tomcat and copy the code into it, or do i need to run maven install to produce a war file of some sort. I guess am just asking for a bit more detail to get this application up and running.

Timezone configuration makes tests fail

When I want to build the project with maven, it returns the following:

Failed tests: formattedCollection(org.springframework.samples.mvc.convert.ConvertControllerTests): Response content expected:<Converted formatted collection [Sun Jul 04 00:00:00 MESZ 2010, Mon Jul 04 00:00:00 MESZ 2011]> but was:<Converted formatted collection [Sun Jul 04 00:00:00 CEST 2010, Mon Jul 04 00:00:00 CEST 2011]> beanFormattedCollection(org.springframework.samples.mvc.convert.ConvertControllerTests): Response content expected:<Converted JavaBean formattedList=[Sun Jul 04 00:00:00 MESZ 2010, Mon Jul 04 00:00:00 MESZ 2011]> but was:<Converted JavaBean formattedList=[Sun Jul 04 00:00:00 CEST 2010, Mon Jul 04 00:00:00 CEST 2011]> date(org.springframework.samples.mvc.convert.ConvertControllerTests): Response content expected:<Converted date Sun Jul 04 00:00:00 MESZ 2010> but was:<Converted date Sun Jul 04 00:00:00 CEST 2010> beanDate(org.springframework.samples.mvc.convert.ConvertControllerTests): Response content expected:<Converted JavaBean date=Sun Jul 04 00:00:00 MESZ 2010> but was:<Converted JavaBean date=Sun Jul 04 00:00:00 CEST 2010> submitSuccess(org.springframework.samples.mvc.form.FormControllerTests): Flash attribute expected:<Form submitted successfully. Bound properties name='Joe', age=56, birthDate=Tue Dec 16 00:00:00 MESZ 1941, phone='(347) 888-1234', currency=123.33, percent=0.89, inquiry=comment, inquiryDetails='what is?', subscribeNewsletter=false, additionalInfo={java=true, mvc=true}> but was:<Form submitted successfully. Bound properties name='Joe', age=56, birthDate=Tue Dec 16 00:00:00 CEST 1941, phone='(347) 888-1234', currency=123.33, percent=0.89, inquiry=comment, inquiryDetails='what is?', subscribeNewsletter=false, additionalInfo={java=true, mvc=true}> submitSuccessAjax(org.springframework.samples.mvc.form.FormControllerTests): Model attribute 'message' expected:<Form submitted successfully. Bound properties name='Joe', age=56, birthDate=Tue Dec 16 00:00:00 MESZ 1941, phone='(347) 888-1234', currency=123.33, percent=0.89, inquiry=comment, inquiryDetails='what is?', subscribeNewsletter=false, additionalInfo={java=true, mvc=true}> but was:<Form submitted successfully. Bound properties name='Joe', age=56, birthDate=Tue Dec 16 00:00:00 CEST 1941, phone='(347) 888-1234', currency=123.33, percent=0.89, inquiry=comment, inquiryDetails='what is?', subscribeNewsletter=false, additionalInfo={java=true, mvc=true}>

How can I fix this?

Slideshow 404s

The slideshow .pdf seems to be missing - is "this directory" meant to be the root of the project?

Null pointer exception while server startup

Hi Team,
I am using spring mvc for my application and tomcat 8.0 version. during server startup i am getting the below error.This is happening for the first api call.After that it is working fine.
Can you please guide me in resolving this?

java.lang.NullPointerException
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)

Unable to run spring-mvc-showcase in STS 3.8.1

STS 3.8.1 uses Pivotal Server v3.1

I performed a simple "run on server" .....

Logs have this exception:
10:25:44 [localhost-startStop-1] DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.samples.mvc.data.custom.CustomArgumentResolver]

I have modified the pom.xml to use Java 8. Is that the reason? If yes, how do I get it to work with Java 8?
Regards,

Can not import to sts

when check out all the source code and then use sts import the folder as tutorial mentioned, but i can not work out.

ClassCastException when running mvn tomcat:run

When running the showcase as follows-

mvn tomcat:run

I get a ClassCastException:-

[INFO] Creating Tomcat server configuration at /home/mnorbury/tmp/spring-mvc-showcase/target/tomcat
Nov 9, 2012 8:10:05 AM org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
Nov 9, 2012 8:10:05 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
Nov 9, 2012 8:10:05 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet appServlet as unavailable
Nov 9, 2012 8:10:05 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /spring-mvc-showcase threw load() exception
java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Nov 9, 2012 8:10:05 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Nov 9, 2012 8:10:06 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080

HTTP Status 500 - Servlet.init() for servlet appServlet threw exception

Hi can you please suggest me? I am using spring mvc with Spring Tool Suite first time

HTTP Status 500 - Servlet.init() for servlet appServlet threw exception

type Exception report

message Servlet.init() for servlet appServlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)

root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)

root cause
java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41)
javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:184)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)

root cause
java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41)
javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:184)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.23 logs.

LinkageError: loader constraint violation

I'm running the maven app like described in the README file with mvn tomcat:run. My environment is Mac OS X 10.6.8 with Java 1.6.0_26. When accessing the application through the browser at address http://localhost:8080/spring-mvc-showcase it get the following exception:

INFO: Starting Coyote HTTP/1.1 on http-8080
DEBUG: org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'appServlet' processing GET request for [/spring-mvc-showcase/]
DEBUG: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /
DEBUG: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/]
DEBUG: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/] to HandlerExecutionChain with handler [org.springframework.web.servlet.mvc.ParameterizableViewController@5994a1e9] and 1 interceptor
DEBUG: org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/spring-mvc-showcase/] is: -1
DEBUG: org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'home'; URL [/WEB-INF/views/home.jsp]] in DispatcherServlet with name 'appServlet'
DEBUG: org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/home.jsp] in InternalResourceView 'home'
11.07.2011 21:11:11 org.apache.catalina.core.ApplicationDispatcher invoke
SCHWERWIEGEND: Servlet.service() for servlet jsp threw exception
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/WEB_002dINF/views/home_jsp, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
at org.apache.jsp.WEB_002dINF.views.home_jsp._jspInit(home_jsp.java:25)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1120)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:890)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.mvc.extensions.flash.FlashMapFilter.doFilterInternal(FlashMapFilter.java:33)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:680)

I guess it has something to do with the javax.el library?

Some ConvertControllerTests and FormControllerTests fail when run in a different timezone

Some of the recently added tests for Spring 3.2 are failing because they are expecting dates to be formatted with a specific time zone which may not be the case:

this.mockMvc.perform(get("/convert/date/2010-07-04"))
                .andExpect(content().string("Converted date Sun Jul 04 00:00:00 EST 2010"));

For example, running the tests on a machine set to UK time (BST) results in:

java.lang.AssertionError: Response content
Expected: "Converted date Sun Jul 04 00:00:00 EST 2010"
     got: "Converted date Sun Jul 04 00:00:00 BST 2010"

Not able to unit test validations using MockMVC

Hi,

I am starting out on using MockMVC and I dont understand why my validations (javax and hibernate) do not execute when I run my unit test. Here is the summary :

  1. I have a mvc controller annotated with @RestController. This controller has a method to delete resource.
    uri to delete resource is : /myresources/{resourceId} (I have given context relative url)
    this method accepts the Path Parameter in resourceId parameter annotated with @PathParam,
    Also this parameter is annotated with two other annotations for validating the path parameter.
    i) @pattern which is a javax.validation annotation which specifies following pattern : regexp=[0-9]{1,12} to accept only 1 to 12 digits as input
    ii) it has @notblank validation which is org.hibernate validation to check if its not empty
I am building standalone MockMVC setup and using perform method to call the url with path parameter value set to abcd : /myresources/abcd instead of valid intege.  At this point no validation is carried out and it throws NumberFormatException in my method. 

So
Should it not preempt the call by carrying out validation so that it doesn't reach my method?
If yes why its not working. If no is this possible in any way because I want to write unit test for each of the validations.

I found similar link on stackoverflow and giving that here for reference :

http://stackoverflow.com/questions/27106298/mock-mvc-javax-validation-test

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.