You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ty C <ty...@binary42.com> on 2006/02/15 08:52:02 UTC

Launching a subprocess with correct classpath

Shakalaka!

I am upgrading our project from Maven 1.x to 2.0.2. At this point  
only 67 of my 150 tests have test failures/errors due to the  
transition. My main problem is this: I have many tests that launch  
multiple instances of the same server classes. The server uses static  
variables (it is highly inconvenient to do otherwise AFAICS) and thus  
we had written them to be spawned into their own processes, and  
remote-controlled (startup, shutdown, etc) via XML-RPC. This setup  
served us well. To accomplish this, we incorporated the following tools:

org.apache.tools.ant.types.CommandlineJava

java.lang.Process process = Runtime.getRuntime().exec 
(cmd.getCommandline());

org.apache.tools.ant.taskdefs.PumpStreamHandler


Bringing this setup into Maven 2.0.2, when such tests are executed,  
Maven outputs the following:

...
65440 [main] INFO  
com.b42.anyplace.test.AddressBookMultiServerFailTest  - Spawned  
server #4210
65442 [main] INFO com.b42.xmlrpc.DefaultXmlRpcClientLite  -  
waitUntilRunning$
Exception in thread "main" java.lang.NoClassDefFoundError: com/b42/ 
anyplace/test/lib/ServerTask
...

Here, the AddressBookMultiServerFailTest successfully spawned a  
server process using the aforementioned Ant tools and is now waiting  
for the server to enter the running condition before continuing on  
with the tests. However, the dominant class loading system appears to  
have not found com/b42/anyplace/test/lib/ServerTask. A check shows  
that the environment variable values of the spawned processes ( for  
the java.class.path and sun.boot.class.path keys, for example) are  
all primitive and therefore have no concept of either my code or  
Mavens ergo they can't possibly run the test.

How can I surmount this problem? I know that surefire has a "fork"  
mechanism; am I able to reuse this mechanism in one of the tests as  
launched by surefire? Can my test access it's own class path as  
launched by Maven and set that Is it possible to use classworlds to  
load multiple instances of my ServerTask into the same VM without the  
static variables conflicting? Can anyone suggest any solutions?

Thank you very much for your time and energy,
Ty C


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org