This discussion is archived
4 Replies Latest reply: Sep 7, 2012 12:32 AM by Luis RSS

Servlet throwing 'NoAccessRuntimeException' trying access JMX bean

user603048 Newbie
Currently Being Moderated
I have a servlet where in I access weblogic MBeans. I am getting 'subject: principal does not have access to perform admin actions'. Some attributes I am able to access fine but while trying to access 'DataSource' I believe it is throwing the exception.

Code:
ctx = new InitialContext();
MBeanServer mBeanCon = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");

ObjectName runtimeService =
new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");

serverConfiguration = (ObjectName) mBeanCon.getAttribute(runtimeService, "ServerConfiguration");

ObjectName cluster = (ObjectName) mBeanCon.getAttribute(serverConfiguration, "Cluster");

All the above lines are executed fine. It fails at the following line:
ObjectName dataSourceForJobScheduler = (ObjectName) mBeanCon.getAttribute(cluster, "DataSourceForJobScheduler");
ObjectName jdbcDataSourceForJobScheduler =
(ObjectName) mBeanCon.getAttribute(dataSourceForJobScheduler, "JDBCResource");
ObjectName jdbcDataSourceForJobSchedulerParmas =
(ObjectName) mBeanCon.getAttribute(jdbcDataSourceForJobScheduler, "JDBCDataSourceParams");
String[] jndiNames =
(String[]) mBeanCon.getAttribute(jdbcDataSourceForJobSchedulerParmas, "JNDINames");

How can I get around this probelm?

Thank you,
  • 1. Re: Servlet throwing 'NoAccessRuntimeException' trying access JMX bean
    739896 Guru
    Currently Being Moderated
    HI,
    This error indicates that: The user does not have access to the resource who is trying to access the resource. Please check your credentials. Or You need to use JMX Policy editor to give access to that particular user to access the required resources.

    If you just want to access "JDBCResource" and "JDBCDataSourceParams" and their attributes then you can refer to the following link: http://middlewaremagic.com/weblogic/?p=606 Along with all the JDBC Configuration and Runtime Informations.


    Please crrect your code line *"ctx=new InitialContext()"* like below


    = = = = = = = = = =
    try{
    Hashtable h = new Hashtable();
    h.put(Context.SECURITY_PRINCIPAL, "weblogic");
    h.put(Context.SECURITY_CREDENTIALS, "weblogic");
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
    <font color=red>ctx=new InitialContext(h);</font> ----------------------------> Pass the Context Information Here
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }


    .
    .
    Thanks
    Jay SenSharma
    http://middlewaremagic.com/weblogic (Middleware Magic Is here)
  • 2. Re: Servlet throwing 'NoAccessRuntimeException' trying access JMX bean
    user603048 Newbie
    Currently Being Moderated
    My problem is how do I get the admin user name and password.

    Is there any way that I can change my servlet's security so that it has admin privileges to access these properties?

    or can the Servlet be deployed with Admin privileges to access these properties?

    Thank you,
  • 3. Re: Servlet throwing 'NoAccessRuntimeException' trying access JMX bean
    739896 Guru
    Currently Being Moderated
    Hi,
    If you are just a developer and Not An Admin ....then Please contact your Administrator to give you privilages.
    Without his permission if you will try to do this then it will be kind of HACKING.


    .
    .
    Thanks
    Jay SenSharma
  • 4. Re: Servlet throwing 'NoAccessRuntimeException' trying access JMX bean
    Luis Newbie
    Currently Being Moderated
    Hello Jay,

    Thank you very much, it is working for me!

    I needed to get the SSOSigningCert of an Identity provider partner:
    encodedCertificate = idPPartner.getSSOSigningCert().getEncoded();
    And I was executing this from a javax.servlet.ServletContextListener. When I deployed the application everything was ok, but when I restarted the managed server I was getting the exception.

    Thanks again and best regards,

    Luis

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points