You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by depsypher <vo...@gmail.com> on 2010/11/28 21:15:34 UTC

shiro-spring giving me 404s

I tried to integrate shiro into my spring app as described in the
documentation, but so far I haven't been able to get any requests to do
anything but 404.  The logs on startup seem to indicate everything
initialized fine but nothing appears in the logs when I hit one of the pages
in the app.

I initially thought it might be my UrlRewriteFilter interfering, but I took
that out and I get the same behavior.  If I take out the shiro filter the
404s go away and the app works ok. I can post all my configs, but first
wanted to check if there's any known issues.

I also tried building the shiro spring example and it 404s for me as well. 
I did mvn package and deployed the war to apache-tomcat-6.0.26.  Bringing it
up in a browser causes a redirect to:
http://localhost:8080/samples-spring-1.1.0/s/login
which is a 404 page that complains "HTTP Status 404 - Servlet sample is not
available"

On a related note, are there source jars (or a way for the build to create
them easily) so I can link it in eclipse and step debug through the running
code?

Thanks,
Ray

-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5782432.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
Glad to help! :)

Cheers,

Les

Re: shiro-spring giving me 404s

Posted by depsypher <vo...@gmail.com>.
Aha!  Thanks for your patience with me.  Doing the clean mvn install helped. 
I had skipped straight to building just the sample before.  I got it working
with both jetty and tomcat now (although in tomcat I had to download
standard.jar and include it alongside the jstl-x.x.x.jar for tomcat to
render the jsp without 500 error-ing with
"org.apache.jasper.JasperException: The absolute uri:
http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or
the jar files deployed with this application").

Thanks for walking me through getting it up and running :)
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5822199.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
This is what works for me:

cd shiro-trunk
mvn clean install
cd samples/spring
mvn jetty:run-exploded

Then visit http://localhost:8080/shiro-samples-spring

Note the port (8080, not 9080 as it once was) and the context path is
/shiro-samples-spring

I also tried 'mvn jetty:run-war' and that worked as well.

If trying to deploy the .war in tomcat, you might want to blast
Tomcat's work directory - maybe there is something stale causing a
conflict.

HTH!

Les

Re: shiro-spring giving me 404s

Posted by depsypher <vo...@gmail.com>.
Thanks for looking into this.  I checked out trunk and tried it again, but no
luck so far.  Using jetty gave me a 500 error so I tried packaging as a
regular war again and deployed to tomcat.  That still results in 404 for me. 
I'll grab the source jars later and hook up the debugger and see what I can
find.  Here is the logs from tomcat (also, fyi, I was using chrome before,
but I just tried it with firefox with same results):


2010-12-09 20:33:53,413 TRACE
[org.apache.shiro.web.servlet.OncePerRequestFilter] - Filter 'shiroFilter'
not yet executed.  Executing now. 
2010-12-09 20:33:53,429 TRACE [org.apache.shiro.mgt.DefaultSecurityManager]
- Context already contains a SecurityManager instance.  Returning. 
2010-12-09 20:33:53,432 DEBUG
[org.apache.shiro.session.mgt.AbstractValidatingSessionManager] - No
sessionValidationScheduler set.  Attempting to create default instance. 
2010-12-09 20:33:53,433 TRACE
[org.apache.shiro.session.mgt.AbstractValidatingSessionManager] - Created
default SessionValidationScheduler instance of type
[org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler]. 
2010-12-09 20:33:53,433 INFO
[org.apache.shiro.session.mgt.AbstractValidatingSessionManager] - Enabling
session validation scheduler... 
2010-12-09 20:33:53,434 TRACE
[org.apache.shiro.session.mgt.AbstractValidatingSessionManager] - Attempting
to retrieve session with key
org.apache.shiro.web.session.mgt.WebSessionKey@70036428 
2010-12-09 20:33:53,435 DEBUG [org.apache.shiro.web.servlet.SimpleCookie] -
Found string value [5ed8d2b5-7165-43a8-9072-c55dcf834b2b] from Cookie
[JSESSIONID] 
2010-12-09 20:33:53,437 DEBUG [org.apache.shiro.mgt.DefaultSecurityManager]
- Resolved SubjectContext context session is invalid.  Ignoring and creating
an anonymous (session-less) Subject instance. 
org.apache.shiro.session.UnknownSessionException: There is no session with
id [5ed8d2b5-7165-43a8-9072-c55dcf834b2b]
	at
org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170)
	at
org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236)
	at
org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222)
	at
org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118)
	at
org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:105)
	at
org.apache.shiro.session.mgt.AbstractNativeSessionManager.getSession(AbstractNativeSessionManager.java:97)
	at
org.apache.shiro.mgt.SessionsSecurityManager.getSession(SessionsSecurityManager.java:125)
	at
org.apache.shiro.mgt.DefaultSecurityManager.resolveContextSession(DefaultSecurityManager.java:394)
	at
org.apache.shiro.mgt.DefaultSecurityManager.resolveSession(DefaultSecurityManager.java:380)
	at
org.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:329)
	at org.apache.shiro.subject.Subject$Builder.buildSubject(Subject.java:829)
	at
org.apache.shiro.web.subject.WebSubject$Builder.buildWebSubject(WebSubject.java:148)
	at
org.apache.shiro.web.servlet.AbstractShiroFilter.createSubject(AbstractShiroFilter.java:202)
	at
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:269)
	at
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
	at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
	at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	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:852)
	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)
2010-12-09 20:33:53,438 TRACE [org.apache.shiro.mgt.DefaultSecurityManager]
- No identity (PrincipalCollection) found in the context.  Looking for a
remembered identity. 
2010-12-09 20:33:53,439 TRACE [org.apache.shiro.web.servlet.SimpleCookie] -
No value found in request Cookies under cookie name [rememberMe] 
2010-12-09 20:33:53,439 TRACE [org.apache.shiro.mgt.DefaultSecurityManager]
- No remembered identity found.  Returning original context. 
2010-12-09 20:33:53,445 TRACE
[org.apache.shiro.subject.support.DelegatingSubject] - attempting to get
session; create = false; session is null = true; session has id = false 
2010-12-09 20:33:53,446 TRACE
[org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver] - Matched
path pattern [/**] for requestURI [/].  Utilizing corresponding filter
chain... 
2010-12-09 20:33:53,447 TRACE
[org.apache.shiro.web.servlet.AbstractShiroFilter] - Resolved a configured
FilterChain for the current request. 
2010-12-09 20:33:53,447 TRACE
[org.apache.shiro.web.servlet.ProxiedFilterChain] - Invoking wrapped filter
at index [0] 
2010-12-09 20:33:53,447 TRACE
[org.apache.shiro.web.servlet.OncePerRequestFilter] - Filter 'authc' not yet
executed.  Executing now. 
2010-12-09 20:33:53,447 TRACE
[org.apache.shiro.web.filter.PathMatchingFilter] - Attempting to match
pattern [/s/login] with current requestURI [/]... 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.web.filter.PathMatchingFilter] - Attempting to match
pattern [/**] with current requestURI [/]... 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.web.filter.PathMatchingFilter] - Current requestURI
matches pattern [/**].  Performing onPreHandle check... 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.web.filter.PathMatchingFilter] - Attempting to match
pattern [/s/login] with current requestURI [/]... 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.web.filter.authc.FormAuthenticationFilter] - Attempting to
access a path which requires authentication.  Forwarding to the
Authentication url [/s/login] 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.subject.support.DelegatingSubject] - attempting to get
session; create = true; session is null = true; session has id = false 
2010-12-09 20:33:53,448 TRACE
[org.apache.shiro.subject.support.DelegatingSubject] - Starting session for
host 0:0:0:0:0:0:0:1%0 
2010-12-09 20:33:53,451 TRACE
[org.apache.shiro.session.mgt.DefaultSessionManager] - Creating session for
host 0:0:0:0:0:0:0:1%0 
2010-12-09 20:33:53,451 DEBUG
[org.apache.shiro.session.mgt.DefaultSessionManager] - Creating new EIS
record for new session instance
[org.apache.shiro.session.mgt.SimpleSession,id=null] 
2010-12-09 20:33:53,452 TRACE [org.apache.shiro.web.servlet.SimpleCookie] -
calculated path: /samples-spring-1.1.0 
2010-12-09 20:33:53,452 DEBUG [org.apache.shiro.web.servlet.SimpleCookie] -
Added HttpServletResponse Cookie
[JSESSIONID=9a2de9a6-30e8-4169-97be-1a041613015a;
Path=/samples-spring-1.1.0; HttpOnly] 
2010-12-09 20:33:53,452 TRACE
[org.apache.shiro.web.session.mgt.DefaultWebSessionManager] - Set session ID
cookie for session with id 9a2de9a6-30e8-4169-97be-1a041613015a 
2010-12-09 20:33:53,456 TRACE
[org.apache.shiro.session.mgt.AbstractValidatingSessionManager] - Attempting
to retrieve session with key
org.apache.shiro.web.session.mgt.WebSessionKey@53e64a3b 
2010-12-09 20:33:53,457 TRACE
[org.apache.shiro.subject.support.DelegatingSubject] - attempting to get
session; create = false; session is null = false; session has id = true 
2010-12-09 20:33:53,457 TRACE
[org.apache.shiro.subject.support.DelegatingSubject] - attempting to get
session; create = false; session is null = false; session has id = true 
2010-12-09 20:33:53,462 TRACE [org.apache.shiro.web.servlet.AdviceFilter] -
Invoked preHandle method.  Continuing chain?: [false] 
2010-12-09 20:33:53,462 TRACE [org.apache.shiro.web.servlet.AdviceFilter] -
Successfully invoked postHandle method 
2010-12-09 20:33:53,462 TRACE [org.apache.shiro.web.servlet.AdviceFilter] -
Successfully invoked afterCompletion method. 

-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5821978.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
The shiro spring sample application now works successfully.  The code
changes have been committed to the trunk (the codebase for this sample
app was rather old and hadn't been updated in quite a while).

After updating from svn and doing a build, go into the samples/spring
directory and run:

mvn jetty:run-exploded

Then visit http://localhost:8080/shiro-samples-spring

and you'll be able to log in/log out again.  No 404s.

I think the 404's you might have been seeing depends on the browser
you're using and any requests it makes for /favicon.ico..  I think
Chrome for example will show you the 404 error (shiro tries to
redirect Chrome to the login page if it sees this error, and Chrome
may be reporting that as a 404).  Other browsers may do something
similar.  One easy fix was to add a /favicon.ico = anon to the filter
chain definitions.  (The updated sample app does this just in case).

Note however that there is still a problem with launching the WebStart
application after you've logged in, but at least you should see that
you're not getting any more 404s.

HTH!

Les

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
Oh, I forgot - Shiro publishes source jars with its releases to the
Maven repo. (we publish the binary .jar, the javadoc .jar and the
source .jar).  An 'mvn dependency:sources' call will download them
from Maven Central.

Regards,

Les

On Sun, Nov 28, 2010 at 12:15 PM, depsypher <vo...@gmail.com> wrote:
> On a related note, are there source jars (or a way for the build to create
> them easily) so I can link it in eclipse and step debug through the running
> code?
>
> Thanks,
> Ray

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
Hi Ray,

Sorry - I got side tracked last week working on our product.  I should
be able to try this out today in a little bit.

Best,

Les

On Thu, Dec 9, 2010 at 12:11 PM, depsypher <vo...@gmail.com> wrote:
>
> Just wondering if you've had a chance to see what the problem is with the
> shiro spring sample app.
>
> I'm trying to add authentication into a spring app I have as a fun side
> project.  I have facebook authentication working with oauth and am trying to
> tie that into an auth framework.  I was trying to stay away from acegi or
> creating my own, but I'm also not sure how much trouble it is to get shiro
> working on spring... any signs of life on this would encourage me to stick
> with shiro.
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5820479.html
> Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by depsypher <vo...@gmail.com>.
Just wondering if you've had a chance to see what the problem is with the
shiro spring sample app.

I'm trying to add authentication into a spring app I have as a fun side
project.  I have facebook authentication working with oauth and am trying to
tie that into an auth framework.  I was trying to stay away from acegi or
creating my own, but I'm also not sure how much trouble it is to get shiro
working on spring... any signs of life on this would encourage me to stick
with shiro.
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5820479.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by depsypher <vo...@gmail.com>.
Yup, I'm the one who submitted SHIRO-219.  It's not the cause of these 404s
(in my app or in the sample).  I got a different error from it in my app and
fixed it, and I just checked the source for the spring sample and it has the
correct classname.  Still stuck on this unfortunately.
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5787033.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: shiro-spring giving me 404s

Posted by Les Hazlewood <lh...@apache.org>.
Hi Ray,

Let me try the spring sample app and see what happens.  There is one
issue that was raised in the last few days that might be related to
your problem:  https://issues.apache.org/jira/browse/SHIRO-219

I'm not sure if this is causing you troubles, but it's worth looking
into.  When I find out more from trying the sample app myself, I'll
update this thread.

Cheers,

-- 
Les Hazlewood
Founder, Katasoft, Inc.
Application Security Products & Professional Apache Shiro Support and Training:
http://www.katasoft.com


On Sun, Nov 28, 2010 at 12:15 PM, depsypher <vo...@gmail.com> wrote:
>
> I tried to integrate shiro into my spring app as described in the
> documentation, but so far I haven't been able to get any requests to do
> anything but 404.  The logs on startup seem to indicate everything
> initialized fine but nothing appears in the logs when I hit one of the pages
> in the app.
>
> I initially thought it might be my UrlRewriteFilter interfering, but I took
> that out and I get the same behavior.  If I take out the shiro filter the
> 404s go away and the app works ok. I can post all my configs, but first
> wanted to check if there's any known issues.
>
> I also tried building the shiro spring example and it 404s for me as well.
> I did mvn package and deployed the war to apache-tomcat-6.0.26.  Bringing it
> up in a browser causes a redirect to:
> http://localhost:8080/samples-spring-1.1.0/s/login
> which is a 404 page that complains "HTTP Status 404 - Servlet sample is not
> available"
>
> On a related note, are there source jars (or a way for the build to create
> them easily) so I can link it in eclipse and step debug through the running
> code?
>
> Thanks,
> Ray
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/shiro-spring-giving-me-404s-tp5782432p5782432.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>