tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zsolt Koppany" <zkoppanyl...@intland.com>
Subject How to start a Realm from a servlet or a filter
Date Fri, 09 Apr 2004 08:49:20 GMT
Hi,

because of technical reasons I want to start a Realm class during run-time,
thus I cannot just configure Realm via "<Realm...". When I try to start
MemoryRealm I get a null pointer exception, because the container of Realm
is not set. The application does work (because I catch the exception) but I
would like to start Realm correctly.

What is wrong in my example?

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

Object realm_instance = envCtx.lookup("realm/RealmFactory");
log.info("Realm class: " + realm_instance.getClass().getName());
Realm rlm = (Realm)realm_instance;
if (rlm instanceof Lifecycle)
{
try
{
	// rlm.setContainer(...);		Is that the problem????
	((Lifecycle) rlm).start();
}
catch (Exception e)
{
	log.error("LifecycleException (start): " + e.getMessage(), e);
}


Here is my web-application configuration file:


<Context path="/cb" docBase="cb" debug="0" reloadable="true">
    <Resources className="org.apache.naming.resources.FileDirContext"
allowLinking="false" />

    <Resource name="realm/RealmFactory" auth="Container"
type="org.apache.catalina.realm.MemoryRealm"/>
    <ResourceParams name="realm/RealmFactory">
        <parameter>
            <name>factory</name>
            <value>org.apache.naming.factory.BeanFactory</value>
        </parameter>
        <parameter>
            <name>debug</name>
            <value>99</value>
        </parameter>
        <parameter>
            <name>pathname</name>
            <value>conf/tomcat-users.xml</value>
        </parameter>
    </ResourceParams>

 </Context>



Zsolt Koppany
Phone: +49-711-722 1874
--
Intland Software GmbH, Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart, Germany
Phone: +49-711-722 1873, e-mail:zsolt.koppany@intland.com
Fax: +49-711-722 1835





---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message