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:[EMAIL PROTECTED]
Fax: +49-711-722 1835





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to