提交 032788d7 编写于 作者: K kohsuke

improving error detection for Ant 1.6.5


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7253 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5e21e89e
......@@ -13,9 +13,11 @@ import hudson.util.InsufficientPermissionDetected;
import hudson.util.NoHomeDir;
import hudson.util.RingBufferLogHandler;
import hudson.util.NoTempDir;
import hudson.util.IncompatibleAntVersionDetected;
import org.jvnet.localizer.LocaleProvider;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.apache.tools.ant.types.FileSet;
import javax.naming.Context;
import javax.naming.InitialContext;
......@@ -102,6 +104,14 @@ public class WebAppMain implements ServletContextListener {
return;
}
// make sure that we see Ant 1.7
try {
FileSet.class.getMethod("getDirectoryScanner");
} catch (NoSuchMethodException e) {
context.setAttribute(APP,new IncompatibleAntVersionDetected(FileSet.class));
return;
}
// some containers (in particular Tomcat) doesn't abort a launch
// even if the temp directory doesn't exist.
// check that and report an error
......
package hudson.util;
import hudson.remoting.Which;
import java.io.File;
import java.io.IOException;
/**
* Model object used to display the error top page if
* we find out that the container is picking up its own Ant and that's not 1.7.
*
* <p>
* <tt>index.jelly</tt> would display a nice friendly error page.
*
* @author Kohsuke Kawaguchi
*/
public class IncompatibleAntVersionDetected {
private final Class antClass;
public IncompatibleAntVersionDetected(Class antClass) {
this.antClass = antClass;
}
public File getWhereAntIsLoaded() throws IOException {
return Which.jarFile(antClass);
}
}
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout>
<l:header title="Hudson" />
<l:side-panel />
<l:main-panel>
<h1><img src="${imagesURL}/48x48/error.gif" alt="[!]"/><st:nbsp/>${%Error}</h1>
<p>
${%errorMessage(it.whereAntIsLoaded)}
</p>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
errorMessage=\
We detected that your servlet container is loading an older version of Ant by itself, \
thereby preventing Hudson from loading its own newer copy. \
(Ant classes are loaded from {0}) <br> \
Perhaps can you override Ant in your container by copying one from Hudson's <tt>WEB-INF/lib</tt>, \
or can you set up the classloader delegation to child-first so that Hudson sees its own copy first?
......@@ -6,8 +6,6 @@
<h1><img src="${imagesURL}/48x48/error.gif" alt="[!]"/><st:nbsp/>${%Error}</h1>
<p>
${%errorMessage(it.whereServletIsLoaded)}
We detected that your servlet container does not support Servlet 2.4
(servlet API is loaded from ${it.whereServletIsLoaded})
</p>
</l:main-panel>
</l:layout>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册