In my Shiro application, I am using the JndiRealmFactory
to define my realms. I Register my realms like this:
Hashtable<String, String> args = new Hashtable<>();
args.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
InitialContext ctx = new InitialContext(args);
ctx.bind("realms/MyRealm", myRealm);
However, Shiro cannot find realms/MyRealm
. I think the reason is, that I Need to define the JndiRealmFactory
's jndiEnvironment, which contains the Context.INITIAL_CONTEXT_FACTORY
property. However, I don't know how to set this property in my shiro.ini
:
realmFactory.jndiEnvironment = ?
I am running my application on TomEE.
My current shiro.ini
looks like this:
realmFactory = org.apache.shiro.realm.jndi.JndiRealmFactory
realmFactory.jndiNames = realms/MyRealm
you are not supposed to bind at runtime anything in the EE context. You can probably define it in tomcat as a resource or resources.xml (tomee specific) then just use a standard lookup to read the value (no special properties passed to InitialContext.