Running Graph with java

Hello,
I try to run a graph with a java class, so I take the example of the wiki and try to run graph.


Defaults.init();
Plugins.init("./cloverEtl/plugins/");
TransformationGraph graph = new TransformationGraph("./graph/graph.grf");
if(!graph.init()){
				System.err.println("Graph initialization failed !");

			  }

		if (graph.run() != Result.FINISHED_OK){
				System.out.println("Failed starting all nodes!");
		}

But when it arrive to the line of graph.init() exception is catch I don’t understand the problem.


FATAL [main] - No root Nodes detected! There must be at least one root node defined. (Root node is	node with output ports defined only.)
ERROR [main] - No root node!
org.jetel.exception.GraphConfigurationException: No root node!
	at org.jetel.graph.TransformationGraphAnalyzer.analyzeGraphTopology(TransformationGraphAnalyzer.java:89)
	at org.jetel.graph.TransformationGraph.init(TransformationGraph.java:466)
	at src.Lau.main(Lau.java:106)

Someone could help me ?

Thanks in advance.

Hello,

I am not an expert but it seams that you have a problem into the graph structure.

Have you tried to run the graph example given with clover ?

Regards,

Tchoua

Hello,
constructor TransformationGraph(String) creates new (empty) graph with given name. To read graph from xml file you have to use TransformationGraphXMLReaderWriter class (see javaExamples/testXMLGraph.java in example package).

Thanks to both of you.
It works fine with TansformationGraphXmlReaderWriter.

Juste another question :
Do I have to initialize the plugins, and Default before each Graph ?

Thanks in advance.

You have to initialize engine and plugins before you run a graph, so if you run more graphs from one application it suffices one initialization for all graphs.

Thank you for your answer avackova.

I have one more question, when i run the graph it ask me to use CheckConfig before.
I do something like


ConfigurationStatus statut = new ConfigurationStatus();
graph.checkConfig(statut);

But I’m not convinced it’s the good way to do it.

It is correct way, but it is not necessary to do it if you know your graph is configured properly. If graph configuration is not correct method init will throw ComponentNotReadyException. Method checkConfig was introduced for GUI support purposes.

Thank you for all your answers.