"Unable to find operation run(java.lang.Runnable)" when using a ThreadPool from an MBean

Solution Verified - Updated -

Issue

When I try to have my MBean use an injected thread pool, I get the following exception:

java.lang.IllegalArgumentException: Unable to find operation run(java.lang.Runnable)
  at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:231)
  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
  at $Proxy117.run(Unknown Source)
  at MyTpExample.run



<?xml version="1.0" encoding="UTF-8"?>
<server>
    <mbean code="org.jboss.util.threadpool.BasicThreadPool" name="example:service=ThreadPool">
        <attribute name="Name">My Thread Pool</attribute>
        <attribute name="KeepAliveTime">60000</attribute>
        <attribute name="MaximumPoolSize">10</attribute>
        <attribute name="MaximumQueueSize">100</attribute>
        <attribute name="BlockingMode">wait</attribute>
    </mbean>

    <mbean code="MyTpExample" name="example:service=MyService">
        <depends optional-attribute-name="ThreadPool" proxy-type="attribute">example:service=ThreadPool</depends>
    </mbean>
</server>



public class MyTpExample implements MyTpExampleMBean {
    private ThreadPool threadPool;

    public void setThreadPool(ThreadPool pool) {
        this.threadPool = pool;

        threadPool.run(new MyTask());
    }


    public static class MyTask implements Runnable {
        public void run() {
            System.out.println("running task");
        }

    }
}

Environment

  • JBoss Enterprise Application Platform (EAP) 4.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.