Skip to content

Greglangford.co.uk

Just another tech blog

Recent Posts

  • Kubernetes Cluster Autoscaler On Hetzner Cloud
  • Docker Compose Unable To Connect To Port
  • PowerDNS-Admin Reset Lost Password
  • STM8 8-bit Timer Configuration TIM4
  • Cross Compile Ruby for the Orange Pi Zero

Categories

  • Cloud
  • Cycling
  • Electronics
  • Linux
  • Networking
  • Programming
  • Ruby on Rails
  • Spring MVC
  • System Administration
  • Uncategorised
  • Virtualization

Category: Spring MVC

How To Fix Spring Security j_spring_security_check 404 Error

Recently I have been teaching myself Spring MVC using the book “Spring MVC: Beginners Guide” by G, Amuthan. The book does not focus on the version of Spring that I am using so maybe there are some changes in the more recent version of Spring.

Chapter 4 has an example to add a custom login form using the spring security framework. The example secures a specific page in our case /products/add/

However after implementing the example I would continuously get a 404 error from Tomcat after submitting the login form. The 404 error was for the path /j_spring_security_check. After some research I finally found the answer on Stackoverflow http://stackoverflow.com/questions/24321169/no-mapping-found-for-http-request-with-uri-pms-j-spring-security-check-in-dis

The missing part of the puzzle was in the security-context.xml file. It appears you must specifically define the login-processing-url within the form-login element.

<security:form-login login-page="/login" default-target-url="/products/add" authentication-failure-url="/loginfailed" login-processing-url="/j_spring_security_check" />
Posted on 16th July 201514th August 2016Categories Programming, Spring MVCTags form login, java, spring mvc, spring security2 Comments on How To Fix Spring Security j_spring_security_check 404 Error
Proudly powered by WordPress