History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RHQ-1036
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: John Mazzitelli
Reporter: Charles Crouch
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
RHQ Project

Stop using entire classpath as JMX server resource name

Created: 31/Oct/08 10:43 AM   Updated: 18/Dec/08 10:11 AM
Component/s: Plugins
Affects Version/s: 1.1.2
Fix Version/s: 1.2

Time Tracking:
Not Specified

Issue Links:
Relation
 

Resolution Date: 19/Nov/08 04:06 PM
Date of First Response: 19/Nov/08 03:49 PM
Tester: Jeff Weiss
VCS Revision: 2,037


 Description  « Hide
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...


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Crouch - 12/Nov/08 01:12 PM
We could make the classpath a trait, but would probably need to make the trait column longer than it is currently

John Mazzitelli - 19/Nov/08 03:49 PM
            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.

Charles Crouch - 19/Nov/08 03:50 PM
see also 237962

John Mazzitelli - 19/Nov/08 04:05 PM
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).

John Mazzitelli - 19/Nov/08 04:06 PM
need to test this

John Mazzitelli - 19/Nov/08 04:06 PM
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 + ")";

John Mazzitelli - 20/Nov/08 01:01 PM
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

John Mazzitelli - 09/Dec/08 04:10 PM - edited
svn ren 2267 in the 1.1.2.CP branch

Jeff Weiss - 18/Dec/08 10:11 AM
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