Quantcast
Channel: Adobe Community : Popular Discussions - CQ5 (read only)
Viewing all articles
Browse latest Browse all 12476

Connect to JMX tools from java

$
0
0

Hello everyone, hope you’re all having a wonderful day,

 

I’m currently trying to connect to the JMX console’s LDAP functionality through a custom login module. I’m currently trying to use the code located on this web page:

 

http://dev.day.com/content/kb/home/Crx/CrxFAQ/how-to-synchronize-user-with-ldap.html

 

The problem I am running into is this:

 

I run the code, and I am greeted with a null pointer error originating from the line: MBeanServerConnection server = (MBeanServerConnection) JMXConnectorFactory.connect(new JMXServiceURL(serverUrl), attributes).getMBeanServerConnection();

 

What I would like to know is this:

What are the possible causes? I believe that the problem stems from the fact that I cannot connect to the JMX console for some unknown reason, but I could be wrong. I’ve had LDAP working for a while now, so I know that I am able to successfully connect to the server.

 

Additionally: How do I close my connection to the LDAP server after I have finished? I’ve pasted the code below so you guys can try and figure what the problem is. Thanks!

 

            public static void syncUserToCrx(String userName){

                        String userid = "admin";

                        String password = "admin";

                        String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9000/jmxrmi";

                        String OBJECT_NAME = "com.adobe.granite.ldap:host=(host),port=389,type=Tools";

                        String[] buffer = new String[] { userid, password };

                        Hashtable<String, String[]> attributes = new Hashtable<String, String[]>();

                        attributes.put("jmx.remote.credentials", (String[]) buffer);       

                        MBeanServerConnection server;

                        ObjectName name;

                        try {

                                    server = (MBeanServerConnection) JMXConnectorFactory.connect(new JMXServiceURL(serverUrl), attributes).getMBeanServerConnection();

                                    name = new ObjectName(OBJECT_NAME);

                                    LDAPUserMBean ldap = (LDAPUserMBean) MBeanServerInvocationHandler.newProxyInstance(server, name, LDAPUserMBean.class,false);

                                    ldap.syncUser(userName);

                                   //This is my trying to close the connection

                                    server.unregisterMBean(name);

                        } catch (MalformedObjectNameException e) {

 

                                    LOG.error("Line 79: "+e.getMessage());

                                    e.printStackTrace();

                        } catch (NullPointerException e) {

 

                                    LOG.error("Line 83: "+e.getMessage());

                                    e.printStackTrace();

                        }

                        catch (MalformedURLException e) {

                                    LOG.error("Line 88: "+e.getMessage());

                                    e.printStackTrace();

                        } catch (IOException e) {

                                    LOG.error("Line 90: "+e.getMessage());

                                    e.printStackTrace();

                        } catch (InstanceNotFoundException e) {

                                    LOG.error("Line 94: "+e.getMessage());

                                    e.printStackTrace();

                        } catch (MBeanRegistrationException e) {

                                    LOG.error("Line 97: "+e.getMessage());

                                    e.printStackTrace();

                        }

 

 

            }


Viewing all articles
Browse latest Browse all 12476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>