Re: troubles using JAASRealm with SecurityFilter
Matthew Hixson <[email protected]> Wed, 30 Jul 2008 14:04:52 -0700
| Newsgroups | gmane.comp.java.securityfilter.user |
|---|---|
| Message-ID | <[email protected]> |
On Jul 30, 2008, at 1:10 PM, Christopher Schultz wrote: > Matthew, > > Matthew Hixson wrote: >> I have a webapp running in Tomcat 6.0.16 [...] > >> I have added the servlet and servlet-mapping to my web.xml and >> moved all of the security related stuff from web.xml into >> securityfilter-config.xml. Here's a trimmed down version of that >> file. > > Your sf.xml looks good. > >> <realm >> className="org.securityfilter.realm.catalina.CatalinaRealmAdapter" /> >> <realm className="org.apache.catalina.realm.JAASRealm"> >> <realm-param name="appName" value="MyCustomLoginModule"/> >> <realm-param name="userClassNames" >> value="com.company.authentication.User"/> >> <realm-param name="roleClassNames" >> value="com.company.authentication.Role"/> >> </realm> >> Right when I start up Tomcat I get the following exception. >> Anyone know what I'm doing wrong or know of a workaround? > > [snip] > >> java.lang.NullPointerException >> at org.apache.catalina.realm.RealmBase.init(RealmBase.java:1370) >> at org.apache.catalina.realm.RealmBase.start(RealmBase.java:1034) >> at org.apache.catalina.realm.JAASRealm.start(JAASRealm.java:549) > > The first time I used sf, I found the same problem: you have to put > catalina.jar into your webapp's lib directory in order to make the > Realm classes available to your application, but then RealmBase (and > other classes) come from your webapp's ClassLoader instead of > Tomcat's ClassLoader. > > Since your JAASRealm is not being properly configured by Tomcat > (because sf instantiates it for you), you get a RealmBase object > with no associated Container, which causes the NPE. > > In my case, I just wrote my own DataSourceRealm from scratch and > threw out Tomcat's implementation altogether. With JAASRealm, I > suppose that could be kind of a pain in the neck. > > Did you put catalina.jar into your webapp's WEB-INF/lib directory? > IF so, try removing it and seeing if that works. I haven't worked > with Tomcat 6.x, yet, but I think they unified the container lib > directories and so loading JAASRealm from the container's > ClassLoader might make a difference. > > If you get a ClassNotFoundException when you do that, let me know > where catalina.jar lives in the Tomcat distribution. > > Sorry.. .I don't have a ton of knowledge about the way Tomcat Realms > plug into sf. I'll have to look into that some more. Thanks for the reply, Chris. I did see some other users recommending to copy catalina.jar into the webapp's WEB-INF/lib. When I do that I still get the same "SEVERE: Parent not available yet: null:type=Engine" message at startup. Without catalina.jar in my WEB-INF/lib I can view any of the non- protected pages. There's nothing wrong until I try to login. With catalina.jar in my WEB-INF/lib I can't view any of the site. Going to the front page (which does not require you to login) gives me a Tomcat HTTP Status 500 error page with: java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor org.apache.jsp.index_jsp._jspInit(index_jsp.java:23) org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52) org .apache .jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java: 159) org .apache .jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java: 337) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java: 188) Any ideas? Thanks. -M@ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/