Hello!
I have configured spring JMX with SAP WAS. SAP WAS requires to pass user auth information to InitialContext like:
In order to lookup server I use JndiObjectFactoryBean and JndiTemplate.Code:properties.put(Context.SECURITY_PRINCIPAL, this.username); properties.put(Context.SECURITY_CREDENTIALS, this.password); new InitialContext(properties);
The user's auth information is passed as environment property of JndiTemplate.
But I get
I have extends JndiTemplateCode:java.security.AccessControlException: access denied (javax.management.MBeanPermission javax.management.modelmbean.RequiredModelMBean#-[:
Code:public class CustomJndiTemplate extends JndiTemplate { private static Log logger = LogFactory.getLog(CustomJndiTemplate.class); protected Context createInitialContext() throws NamingException { return super.createInitialContext(); } public Object lookup(final String string) throws NamingException { Object objMBeanServer = createInitialContext().lookup(string); return objMBeanServer; } }
It works!
Then I change the code:
It doesn't work! The same exception.Code:public class CustomJndiTemplate extends JndiTemplate { private static Log logger = LogFactory.getLog(CustomJndiTemplate.class); protected Context createInitialContext() throws NamingException { logger.debug("@@@@@@@ Environement=" + getEnvironment()); return new InitialContext(getEnvironment()); } public Object lookup(final String string) throws NamingException { logger.debug("@@@@@@@ Lookup=" + getEnvironment()); return execute(new JndiCallback() { public Object doInContext(Context ctx) throws NamingException { logger.debug("@@@@@@@ Lookup2=" + ctx.getEnvironment()); return ctx.lookup(string); } }); } }
My Log content:
Code:jmx.CustomJndiTemplate - @@@@@@@ Lookup={java.naming.security.principal=Administrator, java.naming.security.credentials=abcd1234} jmx.CustomJndiTemplate - @@@@@@@ Environement={java.naming.security.principal=Administrator, java.naming.security.credentials=abcd1234} jmx.CustomJndiTemplate$1 - @@@@@@@ Lookup2={java.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl, java.naming.security.principal=Administrator, server=true, java.naming.security.credentials=abcd1234} jndi.JndiLocatorSupport - Located object with JNDI name [jmx]
I suppose the problem is with inner class but I have no idea why it dosn't work.
Could you explain why it doesn't work?


Reply With Quote
