ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay <sjsel...@gmail.com>
Subject Ant build script executing <sql> task using java code
Date Tue, 03 Nov 2009 00:15:43 GMT
Hi,

When I tried to execute a sql task during server start up using a java code, it 
completely freezes the app server disabling the users making any further 
request.

Here is the sample code i have (this is a standalone java code in which nothing 
gets printed after the call to execute the specified task in ant).

<code>

import org.apache.tools.ant.*;

import java.io.*;
import java.util.*;


public class AntRunnerTest
{
     
		 private Project project;

		 public void executeTask(String taskName){
			 try{
				 project = new Project();
				
				 
				 DefaultLogger consoleLogger = new 
DefaultLogger();
				 consoleLogger.setErrorPrintStream(System.err);
				 consoleLogger.setOutputPrintStream(System.out);
				 
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
				 project.addBuildListener(consoleLogger);
				 
				 project.fireBuildStarted();
				 project.init();
				 project.setBasedir(new String("."));
				 ProjectHelper helper = 
ProjectHelper.getProjectHelper();
				 project.addReference("ant.projectHelper", 
helper);
				 helper.parse(project, new File("build-
copy.xml"));
				 project.executeTarget(taskName);
				 project.fireBuildFinished(null);
			 }catch(Exception ex){
			    System.out.println("Exception..."+ex.getMessage());
				project.fireBuildFinished(ex);
			 }
		 }
   public static void main(String args[]){
	  try{
	      AntRunnerTest newInst = new AntRunnerTest();
		  System.out.println("Before");
		  newInst.executeTask("sql");
		  System.out.println("After");

	  }catch(Exception e){System.out.println(""+e);}
   }

}
</code>
and the ant build script

<code>
<project name="document monitor" basedir=".">
	<property file ="${basedir}/build.properties"/>
	<target name="sql">		
			<sql
				driver="${db.mysql.driver}"
				url="${db.mysql.url}"
				userid="${db.mysql.dtsmonitor.username}"
				password="${db.mysql.dtsmonitor.password}"
				onerror="continue"
				print="true"
			>			
			<transaction> <![CDATA[ select now() ]]> </transaction>
			</sql>	
	</target>
</project>

</code>




The debug string "After" never gets printed in the console.

-Jay


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message