In a Clover.ETL web project,
I put clover files into web\WEB-INF\clover directionary, it likes like this:
web
…±–WEB-INF
…±–clover( *.grf)
…±–connection (*.cfg)
…±–metadata (*.fmt)
My test code like this:
String s = {request.getSession().getServletContext().getRealPath(“/WEB-INF/clover/graphOrganLevel.grf”)};
runGraph.main(s);
When I run this code in tomcat, It will throw a FileNotFoundException exception :
Graph definition file: E:\workspace\PMS\DEV\5.code\etl\web\WEB-INF\clover\graphOrganLevel.grf
java.io.FileNotFoundException: web\WEB-INF\clover\connection\pms.cfg
!!! Fatal error during graph initialization !!!
I can run this graph without any error in eclipse, but when in tomcat it will error .
Who can tell me what can I do to settle this relative path problem?
I have settled this problem, I share my experience to all clover.etl develop friends:
1. in action class , we can get project path:
String projectpath = request.getSession().getServletContext().getRealPath(“/”);
2.define parameter in graphOrganLevel.grf
3.invoice graph
param = “-P:projectpath=”+projectpath;
fileName = projectpath+“WEB-INF/clover/graphOrganLevel.grf”;
String s = {param, fileName};
runGraph.main(s);
ok , now it can run without error.
I find the why the tomcat will stop :
I comment “System.exit(0);” in runGraph class, then the problem disappear.
The source code like this:
public static void main(String args) {
…
if (finishedOK) {
// everything O.K.
System.out.println(“Execution of graph finished !”);
//laq add comment: after I comment “System.exit(0)” the tomcat will not stop.
//System.exit(0);
} else {
// something FAILED !!
System.err.println(“Failed starting graph !”);
//laq add comment: I think this line also neet to be commented.
//System.exit(-1);
}
…
}