1

iam trying to follow the documentation of the mbeans for weblogic and create a web application to access an already created custom beans running in another application deployed in the server . iam using this code

 InitialContext ctx = new InitialContext(); MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime"); String serverName = System.getProperty("weblogic.Name"); ObjectName on =new ObjectName("com.myCompanyName:Name=MyCutomBean,Type=MyCutomBean"); boolean boolresult=(Boolean)server.invoke(on, "myMethod", new Object[]{"a","b","c"} ,new String[]{"java.lang.String","java.lang.String","java.lang.String"}); //throw exception out.print(result); out.print(boolresult); 

when i try to access our custom beans i got this exception :

Access not allowed for subject: principals=[], on ResourceType: Name Action: execute, Target: myMethod

what could be the problem ?

1 Answer 1

2

i finally find a solution to avoid this exception u need to authenticate your Context using the following :

Hashtable props = new Hashtable(); props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(Context.SECURITY_PRINCIPAL, "<userName>"); props.put(Context.SECURITY_CREDENTIALS, "<password>"); Context ctx = new InitialContext(props); MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime"); 

Hope this will help someone

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.