NullPointerException in QuickStart Sample

Hi there,

I want to try JSecurity for the first time. I think I'm doing sth wrong... I want to try the QuickStart in my Eclipse so I added the jsecurity.jar and the QuickStart.java. No errors there. Then I try to start the main()-Method an this ist the Output:


23.09.2008 10:51:07 org.jsecurity.session.mgt.AbstractValidatingSessionManager enableSessionValidation
INFO: Enabling session validation scheduler...
23.09.2008 10:51:08 Quickstart main
INFO: Retrieved the correct value! [aValue]
23.09.2008 10:51:08 org.jsecurity.mgt.RealmSecurityManager ensureRealms
INFO: No Realms configured. Defaulting to failsafe PropertiesRealm.
23.09.2008 10:51:08 org.jsecurity.realm.AuthorizingRealm initAuthorizationCache
INFO: No cache or cacheManager properties have been set. Authorization caching is disabled.
23.09.2008 10:51:08 org.jsecurity.realm.AuthorizingRealm initAuthorizationCache
INFO: No cache or cacheManager properties have been set. Authorization caching is disabled.
23.09.2008 10:51:08 org.jsecurity.authc.AbstractAuthenticator authenticate
WARNUNG: Authentication failed for token submission [org.jsecurity.authc.UsernamePasswordToken - lonestarr, rememberMe=true]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).
java.lang.NullPointerException
at org.jsecurity.realm.SimpleAccountRealm.doGetAuthenticationInfo(SimpleAccountRealm.java:139)
at org.jsecurity.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:168)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:186)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:276)
at org.jsecurity.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:141)
at org.jsecurity.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:171)
at org.jsecurity.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:312)
at org.jsecurity.subject.DelegatingSubject.login(DelegatingSubject.java:237)
at Quickstart.main(Quickstart.java:72)
23.09.2008 10:51:08 Quickstart main
INFO: User [null] logged in successfully.
23.09.2008 10:51:08 Quickstart main
INFO: Hello, mere mortal.
23.09.2008 10:51:08 Quickstart main
INFO: Sorry, lightsaber rings are for schwartz masters only.
23.09.2008 10:51:08 Quickstart main
INFO: Sorry, you aren't allowed to drive the 'eagle5' winnebago!

So currentUser.login(token) throws a NullPointerException

What am I doning wrong? Is there a need to put a jsecurity-users.properties somewhere because of Defaulting to failsafe PropertiesRealm?

Greetings,
Sebastian

Solved it by my self. It's

Solved it by my self.

It's obvious to add jsecurity.jar and commons-logging.jar to your classpath.

What I didn't know: you need backport-util-concurrent.jar, ehcahce.jar and xercesImpl.jar, too.

How I figerued that out: I just looked into the build.xml. Everything you need to run the QuickStart-Sample is written there ;)


<include name="ehcache.jar"/>
<!-- needed by ehcache, not jsecurity: -->
<include name="backport-util-concurrent.jar"/>
<include name="commons-logging.jar"/>
<!-- Not normally needed, but mac os x JDK needs it for some reason: -->
<include name="xercesImpl.jar"/>

What's ehcache I asked my self... well "Ehcache is a widely used java distributed cache for general purpose caching, Java EE and light-weight containers." (http://ehcache.sourceforge.net/). Don't need to know more for now.

Keep up the good work and I hope we can get a glimps at the promised Reference-Guide very soon ;)

Regards,
Sebastian

Re: Solved it by my self.

Hi Sebastian,

Sorry for the confusion. I expect most people to run the quickstart from the command line, as the quickstart document recommends. Since I don't have the time to write setup guides for each IDE (I use IntelliJ IDEA myself), I use ant for the examples since pretty much everyone has that ;)

Regards,

Les