2

In a batch file I want to use jmxterm to access jboss mbeans. Therefore I need to include jboss-eap-6.1\bin\client\jboss-client.jar to the classpath.

So I need to call jmxterm that way to get it to work:

java -cp .;%JBOSSDIR%/bin/client/jboss-client.jar;jmxterm-1.0-alpha-4-uber.jar org.codehaus.classworlds.uberjar.boot.Bootstrapper --url service:jmx:remoting-jmx://localhost:9999

The problem: I need to pass an argument to the MBean method I want to call. So I only see the option to pass the script inline but don't know how to do that.

I found that it should work by piping the jmxterm command to the jmxterm call. Adapted to my case (using -cp instead of -jar) it doesn't work:

echo "bean run " | java -cp .;%JBOSSDIR%/bin/client/jboss-client.jar;jmxterm-1.0-alpha-4-uber.jar org.codehaus.classworlds.uberjar.boot.Bootstrapper --url service:jmx:remoting-jmx://localhost:9999 -n

I get the following output:

Feb 04, 2015 3:26:00 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.7.GA-redhat-1
Feb 04, 2015 3:26:00 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.7.GA-redhat-1
Feb 04, 2015 3:26:00 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.16.GA-redhat-1
Welcome to JMX terminal. Type "help" for available commands.
#IllegalArgumentException: Command "bean isn't valid, run help to see available commands

Passing the script as file works but I need to pass the script inline to pass parameters to the mbean method calls.

Any ideas?

syr
  • 836
  • 1
  • 12
  • 28

1 Answers1

2

I'm not sure if this is what you mean with pass the script as file, but you can give all the execution information as a file in the call:

java -cp .;%JBOSSDIR%/bin/client/jboss-client.jar;jmxterm-1.0-alpha-4-uber.jar 
org.codehaus.classworlds.uberjar.boot.Bootstrapper -v silent -n < commands.txt

And then having a commands.txt as this:

open -u service:jmx:remoting-jmx://localhost:9999
run -b com.your.package:type=BeanName methodName parameter1
close
Daniel Rodríguez
  • 548
  • 1
  • 10
  • 30