Hi,

How you run this code?

This error generally means you don't have correct credential in the 
SecurityContext. Did you login in as Admin role?
That's said, don't use the local process way to access the MBeanServer,  or for 
the upcoming Karaf 3.0.2 you can  edit
etc/jmx.acl.whitelist.cfg
to 
add
java.lang.OperatingSystem=bypass
which will totally bypass the RBAC check for the given ObjectName.
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



On 2014-6-26, at 下午1:57, XiLai Dai wrote:

> Hi,
>  
> With these codes running in the karaf 3.0.1:
>  
> import java.lang.management.ManagementFactory;
> import javax.management.MBeanServer;
> import javax.management.ObjectName;
> ……
> MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
> ObjectName name = ObjectName.getInstance("java.lang:type=OperatingSystem");
> AttributeList list = mbs.getAttributes(name, new String[] { "SystemCpuLoad" 
> });
>  
> And also created a ACL configuration file etc/ 
> jmx.acl.java.lang.OperatingSystem.cfg  (one line for enable access to all 
> attributes)
>  
> * = admin
>  
>  
> But still got the SecurityException:
> karaf@root()> Exception in thread "Thread-49" java.lang.SecurityException: 
> Insufficient roles/credentials for operation
>         at 
> org.apache.karaf.management.KarafMBeanServerGuard.handleInvoke(KarafMBeanServerGuard.java:228)
>         at 
> org.apache.karaf.management.KarafMBeanServerGuard.handleGetAttribute(KarafMBeanServerGuard.java:192)
>         at 
> org.apache.karaf.management.KarafMBeanServerGuard.handleGetAttributes(KarafMBeanServerGuard.java:197)
>         at 
> org.apache.karaf.management.KarafMBeanServerGuard.invoke(KarafMBeanServerGuard.java:65)
>         at 
> org.apache.karaf.management.boot.KarafMBeanServerBuilder$MBeanInvocationHandler.invoke(KarafMBeanServerBuilde
> r.java:63)
>  
> Any ideas?
>  
> Regards.
> Xilai Dai

Reply via email to