I'm sure I'm going about this in completely the wrong way, but can someone point out the error in the code below...
MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer (null).get (0); ObjectName mBean = new ObjectName ("Catalina:type=DataSource,path=/<context>,host=localhost,class=javax.sql.DataSource,name=\"<name>\""); String [] params = {"<username>", "<password>"}; Connection myConnection = (Connection) server.invoke (mBean, "getConnection", params, null); Statement myStatement = myConnection.createStatement (); String myResult = myStatement.executeQuery ("SELECT 1 FROM DUAL;").toString (); myConnection.close (); The problem is occurring when I try to instantiate the Connection object by invoking the getConnection method on my MBean. I receive the following error...
Aug 6, 2012 8:46:03 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception java.lang.IllegalArgumentException: Inconsistent arguments and signature at org.apache.tomcat.util.modeler.ManagedBean.getInvoke(ManagedBean.java:578) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source) What am I doing wrong?