Bug 534219 (RHQ-1036) - Stop using entire classpath as JMX server resource name
Summary: Stop using entire classpath as JMX server resource name
Keywords:
Status: CLOSED NEXTRELEASE
Alias: RHQ-1036
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 1.1.2
Hardware: All
OS: All
high
medium
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact: Jeff Weiss
URL: http://jira.rhq-project.org/browse/RH...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-10-31 15:43 UTC by Charles Crouch
Modified: 2015-02-01 23:24 UTC (History)
2 users (show)

Fixed In Version: 1.2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description Charles Crouch 2008-10-31 15:43:00 UTC
From case 234996

agent.log 718.4 KB 2008-10-30 15:02 CDT:

2008-10-30 12:25:09,926 WARN  [InventoryManager.discovery-1] (org.rhq.plugins.jmx.JMXDiscoveryComponent)- Unable to complete base jmx server discovery - cause (enable DEBUG to see stack trace): java.lang.IllegalArgumentException: Resource name is longer than maximum length (500) [:/opt/jbinstall/access:/opt/db2admin/sqllib/java/db2jcc.jar:/opt/db2admin/sqllib/java/db2jcc_license_cisuz.jar:/opt/db2admin/sqllib/java/db2jcc_license_cu.jar:/usr/oracle/client/current/lib/ojdbc14.jar:/opt/mqm/java/lib/CL3Export.jar:/opt/mqm/java/lib/CL3Nonexport.jar:/opt/mqm/java/lib/dhbcore.jar:/opt/mqm/java/lib/rmm.jar:/opt/mqm/java/lib/connector.jar:/opt/mqm/java/lib/fscontext.jar:/opt/mqm/java/lib/jms.jar:/opt/mqm/java/lib/jndi.jar:/opt/mqm/java/lib/jta.jar:/opt/mqm/java/lib/ldap.jar:/opt/mqm/java/lib/com.ibm.mq.jar:/opt/mqm/java/lib/com.ibm.mqjms.jar:/opt/mqm/java/lib/providerutil.jar:/opt/adabas/connx/connxjdbc.jar:/opt/jbinstall/jboss-4.0.5.GA-B/bin/run.jar:/usr/java/jdk1.5.0_13/lib/tools.jar (3009)]
2008-10-30 12:25:09,928 INFO  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Detected new Server [Resource[id=0, type=JMX Server, key=3002, name=:/opt/jbinstall/access:/opt/db2admin/sqllib/java/db2jcc.jar:/opt/db2admin/sqllib/java/db2jcc_license_cisuz.jar:/opt/db2admin/sqllib/java/db2jcc_license_cu.jar:/usr/oracle/client/current/lib/ojdbc14.jar:/opt/adabas/connx/connxjdbc.jar:/opt/jboss/bin/run.jar:/usr/java/jdk1.5.0_13/lib/tools.jar (3002)]] - adding to local inventory...


Comment 1 Charles Crouch 2008-11-12 19:12:37 UTC
We could make the classpath a trait, but would probably need to make the trait column longer than it is currently

Comment 2 John Mazzitelli 2008-11-19 21:49:45 UTC
            String name = null;
            for (int i = 1; i < process.getCommandLine().length; i++) {
                String arg = process.getCommandLine()[i];

                if (!arg.startsWith("-")) {
                    name = arg;
                    break;
                }
            }

            name += " (" + port + ")";

Tries to take the first argument that doesn't start with -
Which is why: "java -jar helloworld.jar" always produces a name of "helloworld.jar".
If you start your VM like this: "java -cp long-classpath ...and the rest..." this bug will happen.

We need to make auto-detecting the name better.


Comment 3 Charles Crouch 2008-11-19 21:50:30 UTC
see also 237962

Comment 4 John Mazzitelli 2008-11-19 22:05:40 UTC
svn rev 2037

the code falls back to "JMX Server" if it can't find a suitable, short name.  We automatically skip the classpath argument (-cp or -classpath).

Comment 5 John Mazzitelli 2008-11-19 22:06:05 UTC
need to test this

Comment 6 John Mazzitelli 2008-11-19 22:06:53 UTC
this is the code now:

            String name = "JMX Server";
            for (int i = 1; i < process.getCommandLine().length; i++) {
                String arg = process.getCommandLine()[i];

                if (!arg.startsWith("-")) {
                    if (arg.length() < 200) { // don't use it if its really long, that's an ugly resource name
                        name = arg;
                        break;
                    }
                } else if (arg.equals("-cp") || arg.equals("-classpath")) {
                    i++; // skip the next arg, its the classpath, we don't want that as the name
                }
            }

            name += " (" + port + ")";


Comment 7 John Mazzitelli 2008-11-20 19:01:04 UTC
to workaround this problem (if running an older version that does not yet have this fix), set the classpath via an environment variable so you don't have to pass it on the command line:

export CLASSPATH=/really/long:/class/path:/here
java -jar -Dmy-options=here myjar.jar

Comment 8 John Mazzitelli 2008-12-09 22:10:52 UTC
svn ren 2267 in the 1.1.2.CP branch

Comment 9 Jeff Weiss 2008-12-18 16:11:47 UTC
Fixed, 2.1.2GA_CP1 

<jweiss> this was my command: java -Dcom.sun.management.jmxremote.port=1500 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -cp .:/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/s
 erver/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acroread/Reader/Legal/en_US/::/tmp:/usr/local/pgsql/include/server/access/:/usr/lib/acro
 read/Reader/Legal/en_US/: DummyJVM
<ccrouch> jweiss if that actually launches a JVM then it should be a good test
<jweiss> ccrouch: yeah, it did and it was discovered.  mazz now what am i looking for to make sure everything is fixed
 i don't see any traits for the jvm
<ccrouch> jweiss: the name of the resource not being 100's of characters long
<mazz> I think the fact it made it into inventory is a good sign :)
<ccrouch> +1
<jweiss> mazz: is the fix that it used the name of my class "DummyJVM" as the resource name?
<mazz> yes. 
 the name of the resource would have been that long classpath before
 which was obviously not what we wanted :)
<jweiss> ok, so when i restart with --classpath, it's going to stay the same resource right?
<mazz> if your resource name is valid now, then this is verified fixed
 correct

Comment 10 Red Hat Bugzilla 2009-11-10 20:22:28 UTC
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-1036
This bug is related to RHQ-1104



Note You need to log in before you can comment on or make changes to this bug.