[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.hyades] Launching a process as a Hyades plugin

Hi,

I am trying to launch a process (an agent to be) through the Hyades plugin
structure (similar to the RemoteLogParserLoader mechanism).
When trying to launch, I get the following entries in the Hyades log file:

<SERVER_MSG time="2004:8:18:15:25:58" severity="INFORMATION"
text="Attempting to launch process : SimpleApp   in location
D:\DOCUME~1\cfhlap0\LOCALS~1\Temp" file="..\RAServer\launcher.c"
line="315"/>
<SERVER_MSG time="2004:8:18:15:25:58" severity="INFORMATION" text="Process
launched: PID=956" file="..\RAServer\launcher.c" line="334"/>
<SERVER_MSG time="2004:8:18:15:25:58" severity="WARNING" text="Application
exited, Closing console" file="..\RAServer\launcher.c" line="712"/>
<SERVER_MSG time="2004:8:18:15:25:58" severity="WARNING" text="Application
exited, Closing console" file="..\RAServer\launcher.c" line="787"/>
<SERVER_MSG time="2004:8:18:15:25:58" severity="INFORMATION" text="Process
956 does not exist so scrub it" file="..\RAServer\RACommS.c" line="2126"/>
<SERVER_MSG time="2004:8:18:15:25:58" severity="INFORMATION" text="Process
956 exited" file="..\RAServer\util.c" line="64"/>
<SERVER_MSG time="2004:8:18:15:26:33" severity="DEBUG" text="Exiting
processing thread for client on socket 1104"
file="..\RAServer\messagePump.c" line="703"/>


It seems like the process died without a reason.


Source code for the client (which launches SimpleApp):

/*
 * Created on Aug 17, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.compuware.hyades.dpj;

/**
 * @author cfhlap0
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.net.UnknownHostException;

import org.eclipse.hyades.internal.execution.local.control.NodeFactory;
import org.eclipse.hyades.internal.execution.local.control.Node;
import org.eclipse.hyades.internal.execution.local.control.ProcessFactory;
import org.eclipse.hyades.internal.execution.local.control.Process;
import org.eclipse.hyades.internal.execution.local.control.ProcessListener;
import org.eclipse.hyades.internal.execution.local.control.Agent;
import org.eclipse.hyades.internal.execution.local.control.Connection;
import
org.eclipse.hyades.internal.execution.local.control.NoSuchApplicationException;

public class DPJClient 
{
	Agent agent = null;
	Process process = null;
	Node node = null;
	Connection conn = null;
	boolean agentLaunched = false;
	boolean monitoringEnded = false;
	
	public void run()
	{
		try
		{
			node = NodeFactory.createNode("evie-xp");
		}
		catch (UnknownHostException uhe)
		{
			System.exit(1);
		}
		catch (Throwable t)
		{
			t.printStackTrace(System.out);
		}

		if (node == null)
		{
			System.out.println("Can't connect, see ya !");
			System.exit(1);
		}
		
		
		try
		{
			conn = node.connect(10002);
		}
		catch (Exception acue)
		{
			acue.printStackTrace(System.out);
			System.exit(1);
		}

		process = ProcessFactory.createProcess(node, "SimpleApp");
		process.addProcessListener(new ProcessListener(){
			public void processLaunched(Process theProc)
			{
				System.out.println("SimpleApp launched!");
				agentLaunched = true;
			}
			public void processExited(Process theProc)
			{
				System.out.println("SimpleApp shut down!");
			}
			
		});
		
		try
		{
			process.launch();
		}
		catch (NoSuchApplicationException nsape)
		{
			nsape.printStackTrace(System.out);
		}
		catch (Exception e)
		{
			e.printStackTrace(System.out);
		}
		
		
		while (!agentLaunched)
		{
			try
			{
				Thread.sleep(100);				
			}
			catch (InterruptedException ie)
			{		
			}
		}
		
		while (!monitoringEnded)
		{
			try
			{
				Thread.sleep(200);
			}
			catch (InterruptedException ie)
			{				
			}
		}
		try
		{
			agent.stopMonitoring();
			agent.detach();			
			process.kill((long)1000);
		}
		catch (Exception e)
		{
			e.printStackTrace(System.out);
		}
		
	
	}

	public static void main(String[] args) 
	{
		DPJClient dpjClient = new DPJClient();
		dpjClient.run();
	}
}

The console window for the client shows the message "SimpleApp launched".

SimpleApp:

/*
 * Created on Aug 18, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.compuware.hyades.simple;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author cfhlap0
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SimpleApp {
	public void go()
	{
		File file = null;
		FileWriter fw = null;
		
		file = new File("e:/temp/out.txt");
		while (true)
		{
			try
			{
				fw = new FileWriter(file, true);				
				long time = System.currentTimeMillis();
				String out = Long.toString(time);
				fw.write(out + "\n\r");
				fw.close();
			}
			catch (IOException ioe)
			{
				ioe.printStackTrace(System.out);
			}
			try
			{
				Thread.sleep(1000);
			}
			catch (InterruptedException ie)
			{
				
			}
		}
		
		
	}

	public static void main(String[] args) {
		SimpleApp sApp = new SimpleApp();
		sApp.go();
	}
}

this app works fine by itself

I installed the SimpleApp under the Hyades RAC server plugins directory,
with a lib and config folder. Lib folder contains the jar, Config folder
contains following pluginconfig.xml:

<?xml version="1.0" encoding="UTF-8"?>
<PluginConfiguration>
	<Application configuration="default" executable="SimpleApp"
location="%SYS_TEMP_DIR%" path="%JAVA_PATH%">
		<Variable name="SA_CONFIG_PATH" position="replace"
value="%RASERVER_HOME%\plugins\com.compuware.hyades.simple\config"/>
		<Variable name="CLASSPATH" position="prepend"
value="%RASERVER_HOME%\plugins\com.compuware.hyades.simple\lib\simple.jar"/>
		<Parameter position="prepend"
value="com.compuware.hyades.simple.SimpleApp"/>
		<Parameter position="prepend" value="-Djava.version=1.4"/>
		<Parameter position="append"
value="&quot;config_path=%DPJ_CONFIG_PATH%&quot;"/>
	</Application>
	<Option name="com.compuware.hyades.dpj" type="version" value="3.0.0"/>
</PluginConfiguration>



Couple of questions:
1. am I doing something wrong here?
2. how can I get more details as to why the launching of the app fails

Thanks,
Luc