InvocationException on connecting to MBean server from Spring

I am trying to connect to MBean server from my Spring application. Below is the code:

public void connect() throws Exception {

    MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();

    Properties environment = new Properties();

    environment.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
    environment.put("java.naming.provider.url", "rmi://");
    environment.put("jmx.remote.jndi.rebind", "true");


    MBeanServerConnection server = (MBeanServerConnection)bean.getObject();

    System.out.println("test"); // After bean.getObject() - Debug pointer on this line.

The debug pointer is set after bean.getObject() method call.

On debugging above code, I am getting below value for MBeanServerConnection server:

com.sun.jdi.InvocationException occurred invoking method.

Values of Environment and ServiceUrl of MBeanServerConnectionFactoryBean are set correctly then why it's not connecting to MBean Server?


I'm not familiar with that particular utility, but it looks like there is some weird overlap between the JNDI and JMX configurations. Why don't you simplify and just use the JDK's own JMXConnectorFactory ?

JMXConnector connector = JMXConnectorFactory.connect("service:jmx:rmi://");
MBeanServerConnection connection = connector.getMBeanServerConnection();

Technically, if you need to, you can add an environment map into the mix by using:

JMXConnector connector = JMXConnectorFactory.connect("service:jmx:rmi://", environment);

...but it seems to me that the environment you are using is already implied by the default connector and the contents of your JMXServiceURL.

It's get resolved after setting java.rmi.server.ignoreStubClasses system property to true.

System.setProperty("java.rmi.server.ignoreStubClasses", "true");

Need Your Help

My (Java/Swing) MouseListener isn't listening, help me figure out why

java swing actionlistener mouselistener

So I've got a JPanel implementing MouseListener and MouseMotionListener:

Could not load file or assembly 'Telerik.Web.UI' or one of its dependencies. Strong name signature could not be verified webforms telerik

Today, when I opened my project in Visual Studio 2010 with Telerik Ajax 2013 Q2 installed on it, I realized that when running, it gives a server error, with this error info:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.