need to configure an old JDBCRealm for tomcat webapp with oracle database

1.5k Views Asked by At

I am trying to resurrect some old java webapps but lost my old glassfish config files in which my JDBCRealm was defined. Now I am trying to deploy the old war's to Tomcat 7 and need to recreate the JDBCRealm to authenticate users. It's been so long since I worked on this stuff I can't remember how to do it, I looked a the official doc but it lacks a connectionURL for oracle. I think my database is set up as before with the users and roles table.

Can I even reuse the old war that ran on glassfish 3 on Tomcat 7? It contains a sun-web.xml file. Is that just for glassfish?

I am using form auth method - here is s snippet of my web.xml:

 <login-config>
<auth-method>FORM</auth-method>
<realm-name>jdbc/myapp/realm</realm-name>
<form-login-config>
  <form-login-page>/loginPage.jsp</form-login-page>
  <form-error-page>/loginError.jsp</form-error-page>
</form-login-config>

Here is my realm snippet from server.xml file:

  <Realm className="org.apache.catalina.realm.LockOutRealm">

    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
      resourceName="UserDatabase"/>

  </Realm>


  <Realm className="org.apache.catalina.realm.JDBCRealm" 
driverName="oracle.jdbc.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:XE"
   userTable="users"userNameCol="username" 
userCredCol="wpassword"userRoleTable="roles"roleNameCol="rolename"/>

Does my connectionURL look right? What else might be wrong? Right now when I try to login it never accepts my password. I always get my login error page (not a full app crash ).

Latest realm version:

<Realm className="org.apache.catalina.realm.JDBCRealm"
       driverName="oracle.jdbc.OracleDriver"
       connectionURL="jdbc:oracle:thin:@localhost:1521:XE"
       connectionName="uname"
       connectionPassword="pword_33"
       userTable="USERS"
       userNameCol="USERNAME"
       userCredCol="WPASSWORD"
       userRoleTable="ROLES"
       roleNameCol="ROLENAME" />
1

There are 1 best solutions below

5
On

The connection URL looks ok, assuming the database sid is XE. You seem to be missing the connectionName and connectionPassword attributes. Any attribute listed in bold in the docs is required.