[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[Subclipse-users] Using svnAnt from within servlet

From: j impala <maboiteaspam_at_yahoo.de>
Date: 2007-09-18 15:33:34 CEST

Hi,
I am using the <svn> task (svnant-1.1.0-RC2) in an Ant buildfile which is itself called from a servlet. The whole runs under Apache Tomcat 5.5, Windows XP.
Here is the Ant buildfile snippet:

    <!-- path to the svnant libraries. Usually they will be located in ANT_HOME/lib -->
    <path id="svnant.classpath">
        <fileset dir="lib">
            <include name="**/*.jar" />
        </fileset>
    </path>

    <!-- load the svn task -->
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />

    <target name="svn-export">
        <svn username="mologin" password="mypwd">
            <export srcUrl="svn://franquin/VQLDocumentation" destPath="exportDir" />
        </svn>
    </target>

The calling servlet is here:

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;

public class ConverterServlet extends HttpServlet {

    /**
     * Etensively used
     * http://www.onjava.com/pub/a/onjava/2002/07/24/antauto.html to make Ant
     * run from servlet environment
     */
    private static final long serialVersionUID = -6743147743349685336L;

    public void doGet(HttpServletRequest req, HttpServletResponse res)
            throws IOException, BuildException {
        PrintWriter out = res.getWriter();

        Export.main(new String[0]);
        
        String baseDir = getServletContext().getRealPath("/");
        Project project = new Project();
        project.init();
        out.println(new File(baseDir, "convert.xml").getAbsolutePath());
        ProjectHelper.configureProject(project,
                new File(baseDir, "convert.xml"));
        project.addBuildListener(new DefaultLogger());
        project.setBaseDir(new File(baseDir));
        project.addBuildListener(new HtmlReportLogger(res.getWriter()));

        project.addBuildListener(new ServletLogger(this));
        project.executeTarget("build-html");
        out.println("Hello, world!");
        out.close();
    }
}

The HtmlReportLogger and ServletLogger are copied verbatim from http://www.onjava.com/pub/a/onjava/2002/07/24/antauto.html, the source of which is here: http://www.onjava.com/onjava/2002/07/24/examples/AntServlet.zip

When I run this servlet (ie, deploy and call it), I get the following exception trace in my Tomcat "localhost" log file (convert.xml:108 is the line containing <svn> above):
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\VQLDocbookConverter\convert.xml:108: java.lang.NullPointerException
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:115)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at com.voiceinsight.vqldoc.ConverterServlet.doGet(ConverterServlet.java:40)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
    at org.apache.tools.ant.DefaultLogger.printMessage(DefaultLogger.java:321)
    at org.apache.tools.ant.DefaultLogger.messageLogged(DefaultLogger.java:289)
    at org.apache.tools.ant.Project.fireMessageLoggedEvent(Project.java:2171)
    at org.apache.tools.ant.Project.fireMessageLogged(Project.java:2271)
    at org.apache.tools.ant.Project.log(Project.java:449)
    at org.tigris.subversion.svnant.commands.SvnCommand.logError(Unknown Source)
    at org.tigris.subversion.svnant.commands.Feedback.logError(Unknown Source)
    at org.tigris.subversion.svnclientadapter.SVNNotificationHandler.logError(SVNNotificationHandler.java:71)
    at org.tigris.subversion.svnclientadapter.SVNNotificationHandler.logException(SVNNotificationHandler.java:127)
    at org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter.doExport(AbstractJhlClientAdapter.java:677)
    at org.tigris.subversion.svnant.commands.Export.execute(Unknown Source)
    at org.tigris.subversion.svnant.commands.SvnCommand.executeCommand(Unknown Source)
    at org.tigris.subversion.svnant.SvnTask.execute(Unknown Source)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    ... 22 more
--- Nested Exception ---
java.lang.NullPointerException
    at org.apache.tools.ant.DefaultLogger.printMessage(DefaultLogger.java:321)
    at org.apache.tools.ant.DefaultLogger.messageLogged(DefaultLogger.java:289)
    at org.apache.tools.ant.Project.fireMessageLoggedEvent(Project.java:2171)
    at org.apache.tools.ant.Project.fireMessageLogged(Project.java:2271)
    at org.apache.tools.ant.Project.log(Project.java:449)
    at org.tigris.subversion.svnant.commands.SvnCommand.logError(Unknown Source)
    at org.tigris.subversion.svnant.commands.Feedback.logError(Unknown Source)
    at org.tigris.subversion.svnclientadapter.SVNNotificationHandler.logError(SVNNotificationHandler.java:71)
    at org.tigris.subversion.svnclientadapter.SVNNotificationHandler.logException(SVNNotificationHandler.java:127)
    at org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter.doExport(AbstractJhlClientAdapter.java:677)
    at org.tigris.subversion.svnant.commands.Export.execute(Unknown Source)
    at org.tigris.subversion.svnant.commands.SvnCommand.executeCommand(Unknown Source)
    at org.tigris.subversion.svnant.SvnTask.execute(Unknown Source)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at com.voiceinsight.vqldoc.ConverterServlet.doGet(ConverterServlet.java:40)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:619)

Executing the same buildfile target under Eclipse runs fine. I don't understand how to interpret the error message.
Can you explain me what it means, and what could be going wrong when I call <svn> from within my web application ?
I'm happy to give any more details you may need.

Thank you
J

      Wissenswertes zum Thema PC, Zubehör oder Programme. BE A BETTER INTERNET-GURU! www.yahoo.de/clever

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subclipse.tigris.org
For additional commands, e-mail: users-help@subclipse.tigris.org
Received on Tue Sep 18 15:46:56 2007

This is an archived mail posted to the Subclipse Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.