aspose file tools*
The moose likes Spring and the fly likes spring security 3.1 login not working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring security 3.1 login not working." Watch "spring security 3.1 login not working." New topic
Author

spring security 3.1 login not working.

rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
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

Joined: May 22, 2010
Posts: 62
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
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

Joined: May 22, 2010
Posts: 62
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

Joined: May 22, 2010
Posts: 62
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???
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

In your security context xml file, where are you defining the login page?


Regards, Prasad
SCJP 5 (93%)
rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
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

Joined: Apr 25, 2010
Posts: 507

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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring security 3.1 login not working.
 
Similar Threads
Spring MVC: Getting resource not available for one Request Mapping while its working for the others.
Spring MVC question
Problem running app under Tomcat v7
Problem finding index page under WEB-INF / Spring MVC
[Spring Security] No bean named 'springSecurityFilterChain' is defined