So I'm trying to create a JDBCRealm for my application instead of using the users from tomcat-users.xml.
Ive changed my server.xml to look like this :
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm.
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> -->
<Realm className="org.apache.catalina.realm.JDBCRealm"
debug="99"
driverName="org.postgresql.Driver"
connctionURL="jdbc:postgresql://localhost:5432/MyDataBase"
connectionName="xxxxxxxx"
ConnectionPassword="xxxxxxxx"
userTable="authUsers" userNameCol="name" userCredCol="password"
userRoleTable="authRole" roleNameCol="role" />
</Realm>
so - UserDatabaseRealm is commented out, and instead I put in my JDBCRealm element.
but for some reason I keep getting a nullPointerException when I start my tomcat, originating in the postgres driver class :
org.apache.catalina.LifecycleException: Failed to start component [Realm[JDBCRealm]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.realm.CombinedRealm.startInternal(CombinedRealm.java:201)
at org.apache.catalina.realm.LockOutRealm.startInternal(LockOutRealm.java:120)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1109)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:691)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Caused by: java.lang.NullPointerException
at org.postgresql.Driver.connect(Driver.java:232)
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:710)
at org.apache.catalina.realm.JDBCRealm.startInternal(JDBCRealm.java:788)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 17 more
I use tomcat 7 with postgres 9.3 and the jar I use for the driver is postgresql-9.3-1100.jdbc4.jar.
any ideas why it won't work? any known bugs with this driver? or is it something in my element?
Thanks!