Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
 #!/bin/sh
 # chkconfig: - 85 15
 # description: Tomcat is a servlet container
 PROGRAM=$CATALINA_HOME/bin/catalina.sh
 if [ -f $PROGRAM ]; then
        echo "$1ing" `basename $0`
        su - tomcat -c "$PROGRAM $1"
 fi

...

How do I get direct access to a tomcat Realm?

Credit: This code is from a post by Yoav Shapira http://www.yoavshapira.com in the user list

Sometimes access direclty into othe tomcat realm object is needed to do this the following code can be used. Be aware however by using this your application is relying on tomcat and not a standard.

No Format

Server server = ServerFactory.getServer();
//Note, this assumes the Container is "Catalina"
Service service = server.findService("Catalina");
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(engine.getDefaultHost());
//Note, this assumes your context is "myContext"
Context context = (Context) host.findChild("myContext");
Realm realm = context.getRealm();