Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

spring security 3.1 login not working.

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there
I am trying to go through spring in action third edition.
I am trying to implement a basic login and url security. I am not getting any login page. Here is my web.xml



Here is my application context xml name servlet-context.xml



here is my security xml



I have two controller. for admin I have one controller



I dont have any login or index jsp. when I go to http://localhost:8080/App/admin it gives me 400 page not found error
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see you filter mapping in your web.xml

Besides telling that you want to use the SecuriltyDelegatingFilterProxy, you also have to map it to URLs in the web.xml file Usually to all the URLs like you did with the DispatcherServlet in the servlet-mapping.

Mark
 
rewati raman
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply.

I changed my web.xml.



but now I am getting this error.


TTP Status 500 -

type Exception report

message

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

exception

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:251)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs.
 
rewati raman
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled some stuff and changed my web.xml to this

now wehen I try to go to http://localhost:8080/App/admin url changes to http://localhost:8080/App/spring_security_login and I get this error

HTTP Status 400 -

type Status report

message

description The request sent by the client was syntactically incorrect ().

Apache Tomcat/6.0.33

 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You duplicated

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/shuruat-servlet.xml,
/WEB-INF/my-security.xml
</param-value>
</context-param>

in your web.xml

The DispatcherServlet is loading the same config files. So now you have two copies of all those beans.

The DispatcherServlet should load the xml that contains web only components, spring beans.

The ContextLoaderListener should only load the xml that contains the middle tier spring beans.

You will get two ApplicationContexts, one a parent, one a child. and that is what you want.

You last error is that the URL request isn't formed correctly, or that you don't have a URL mapping to your Controller for that URL.

I recommend reading the Spring MVC sections in the Spring documentation to help explain it more.

Thanks

Mark
 
rewati raman
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think thats the issue, but still I changed it because that how it should be.

my new web.xml is

 
rewati raman
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its still not working what am i doing wrong. I read hundreds of blogs and forum but its still not working. I have posted my all configuration here. and all changes one by one. What am I doing wrong???
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your security context xml file, where are you defining the login page?
 
rewati raman
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want default login page that spring 3 generates for you. For that I dont need to specify login page right???
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, fine.. Yes, then you don't need to define login page in security context file.. In web.xml, you are mapping /admin1/* to spring security filter, so when you request for /admin, this filter is not applied..
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic