JDBCRealms in Tomcat 4

Hi,

just to make things sure in the beginning, my problem is not to get JDBCRealms to work ;) My Problem is to get several of them up and running - if it is possible.

Im using Tomcat 4 with mod_webapp through Apache. Everything works fine. But i need several JDBCRealms for different servlets. The only place where i could get the JDBCRealm to work is in the Tomcat-Apache <service>-Entry in the server.xml.

Though, there is just on Tomcat-Apache-Service, but several servlets. So i guess there must be a way to define the JDBCRealm Servlet-specific out of this Service-Entry. In former times - running Tomcat 3 - i put the JDBCRealm into the web.xml in the webapp-dir of the regarding servlet. Though - Tomcat 4 ignores any Realm i put there.

So, where can i define a Servlet-Specific Realm how ?

regards,

Cedric

[870 byte] By [Cedric_] at [2007-9-19]
# 1

Cedric, do you mean web application if you say servlet? While i don't know a way to configure a realm for a single servlet, you can configure a realm for a single web application (aka context). Just put your realm element into the context element for the web application (see Tomcat 4 Server Configuration Reference, Context, Nested Components for more details, http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html ). I've done that for my web application and it works fine.

HTH, Markus

Howlingmad at 2007-7-5 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2

> Cedric, do you mean web application if you say

> servlet? While i don't know a way to configure a realm

Yes.

> http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html ).

Ok, thanks, that's it. There are days where you better leave the Server alone ;) My problems depend on the Fact that i don't have any Context defined ;)

*cu

Cedric

Cedric_ at 2007-7-5 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 3
> My problems depend on the Fact that i don't have any Context defined ;)Just for the files: it is ok to have no context element for your web application if you have no special needs.Markus
Howlingmad at 2007-7-5 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 4

I have tried to setup a realm and in server.xml of Tomcat 4, I wrote:

...

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"

driverName="COM.ibm.db2.jdbc.app.DB2Driver"

connectionURL="jdbc:db2:CRISAN"

connectionName="crisan"

connectionPassword="parola"

userTable="users" userNameCol="user_name"

userCredCol="user_pass"

userRoleTable="users_roles" roleNameCol="role_name" />

...

to configure the Realm.

Every table is corectly created in db2 but when i try to start Tomcat, I get the following error:

"Starting service Tomcat-Standalone

Apache Tomcat/4.0.3

Catalina.start: LifecycleException: Exception opening database connection: java.sql.SQLException: java.lang.UnsatisfiedLinkError: no db2jdbc in java.library.path

LifecycleException: Exception opening database connection: java.sql.SQLException: java.lang.UnsatisfiedLinkError: no db2jdbc in java.library.path

java.lang.Throwable()

java.lang.Exception()

org.apache.catalina.LifecycleException(java.lang.String, java.lang.Throwable)

void org.apache.catalina.realm.JDBCRealm.start()

void org.apache.catalina.core.ContainerBase.start()

void org.apache.catalina.core.StandardEngine.start()

void org.apache.catalina.core.StandardService.start()

void org.apache.catalina.core.StandardServer.start()

void org.apache.catalina.startup.Catalina.start()

void org.apache.catalina.startup.Catalina.execute()

void org.apache.catalina.startup.Catalina.process(java.lang.String [])

java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object [])

void org.apache.catalina.startup.Bootstrap.main(java.lang.String [])

java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object [])

void com.silbergrau.tomcat.TomcatRunner.start(java.lang.String [], java.lang.String)

void com.silbergrau.tomcat.TomcatRunner.main(java.lang.String [])

java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object [])"

If you have the answer to mine, I would appreciate your help or any suggestion.

A million thankx in advance,

Sincerly,

Marius C.

crisanmarius at 2007-7-5 > top of java,Enterprise & Remote Computing,Web Tier APIs...