I have a servlet that performs an ANT build, I've attached a org.apache.tools.ant.listener.Log4jListener as you can see below and at the end of the build the org.apache.tools.ant.listener.Log4jListener is not released, the only way I've found around this is to restart Tomcat. If I don't restart Tomcat the next time I try to run the build the org.apache.tools.ant.listener.Log4JListener doesn't log anything.
The Log4JListener is setup to log the build of the project which I then have a log4j.xml setup to listen for the output and an appender of org.apache.log4j.jdbc.JDBCAppender that sends the logging to a database table.
Is there any other solution?
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
try {
Log4jListener l4j = new Log4jListener();
p.addBuildListener(l4j);
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget("war");
p.fireBuildFinished(null);
p.removeBuildListener(l4j);
} catch (BuildException e) {
p.fireBuildFinished(e);
}