[ grinder-Bugs-3548322 ] Wrong selection of agent JAR in WorkerProcessCommand
SourceForge.net <[email protected]> Wed, 25 Jul 2012 05:38:26 -0700
| Newsgroups | gmane.comp.java.grinder.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #3548322, was opened at 2012-07-25 05:38
Message generated for change (Tracker Item Submitted) made by arnede
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3548322&group_id=18598
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core engine
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Arne (arnede)
Assigned to: Nobody/Anonymous (nobody)
Summary: Wrong selection of agent JAR in WorkerProcessCommand
Initial Comment:
If the directory in which the grinder-dcr-agent.jar exists, another JAR file with the same prefix exists (e.g. the -sources.jar), it is wrongly selected, even in case the correct JAR was available on the original classpath.
In my case, I run Grinder 3.10 directly from the Maven local repository. The Grinder agent tries to use the grinder-dcr-agent sources JAR instead of the normal JAR:
2012-07-25 14:31:33,525 INFO agent: Worker process command line: java '-javaagent:..\..\..\..\..\local-repo\net\sf\grinder\grinder-dcr-agent\3.10\grinder-dcr-agent-3.10-sources.jar' -classpath [LONG CLASSPATH OMMITED]' net.grinder.engine.process.WorkerProcessEntryPoint
Error occurred during initialization of VM
agent library failed to init: instrument
The solution is to change the WorkerProcessCommand.findAgentJarFile method to prefer the classpath entries themselves over other children of the directories mentioned in the classpath.
Suggested fix:
static File findAgentJarFile(String path) {
for (String pathEntry : path.split(File.pathSeparator)) {
final File f = new File(pathEntry);
if (isAgentJarFile(f.getName())) {
return f;
}
}
for (String pathEntry : path.split(File.pathSeparator)) {
final File f = new File(pathEntry).getParentFile();
final File parentFile = f != null ? f : new File(".");
final File[] children = parentFile.listFiles();
if (children != null) {
for (File candidate : children) {
final String name = candidate.getName();
if (name.startsWith(AGENT_JAR_FILENAME_PREFIX) &&
name.endsWith(".jar")) {
return candidate;
}
}
}
}
return null;
}
static boolean isAgentJarFile(String name) {
return name.startsWith(AGENT_JAR_FILENAME_PREFIX) &&
name.endsWith(".jar");
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3548322&group_id=18598
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/