%@ page import="java.io.InputStream,
java.io.IOException,
javax.xml.parsers.SAXParser,
javax.xml.parsers.SAXParserFactory"
session="false" %>
<%
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
"+category+": could not find class "+classname
+" from file "+jarFile
+"
"+errorText
+url
+"
");
return 1;
} else {
String location = getLocation(out, clazz);
if(location == null) {
out.write("Found "+ description + " (" + classname + ")
");
}
else {
out.write("Found "+ description + " (" + classname + ") at " + location + "
");
}
return 0;
}
} catch(NoClassDefFoundError ncdfe) {
String url="";
if(homePage!=null) {
url="
See "+homePage+"";
}
out.write("
"+category+": could not find a dependency"
+" of class "+classname
+" from file "+jarFile
+"
"+errorText
+url
+"
The root cause was: "+ncdfe.getMessage()
+"
This can happen e.g. if "+classname+" is in"
+" the 'common' classpath, but a dependency like "
+" activation.jar is only in the webapp classpath."
+"
"); return 1; } } /** * get the location of a class * @param out * @param clazz * @return the jar file or path where a class was found */ String getLocation(JspWriter out, Class clazz) { try { java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation(); String location = url.toString(); if(location.startsWith("jar")) { url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL(); location = url.toString(); } if(location.startsWith("file")) { java.io.File file = new java.io.File(url.getFile()); return file.getAbsolutePath(); } else { return url.toString(); } } catch (Throwable t){ } return "an unknown location"; } /** * a class we need if a class is missing * @param out stream to print stuff * @param classname class to look for * @param jarFile where this class comes from * @param errorText extra error text * @param homePage where to d/l the library * @throws IOException when needed * @return the number of missing libraries (0 or 1) */ int needClass(JspWriter out, String classname, String jarFile, String description, String errorText, String homePage) throws IOException { return probeClass(out, "Error", classname, jarFile, description, errorText, homePage); } /** * print warning message if a class is missing * @param out stream to print stuff * @param classname class to look for * @param jarFile where this class comes from * @param errorText extra error text * @param homePage where to d/l the library * @throws IOException when needed * @return the number of missing libraries (0 or 1) */ int wantClass(JspWriter out, String classname, String jarFile, String description, String errorText, String homePage) throws IOException { return probeClass(out, "Warning", classname, jarFile, description, errorText, homePage); } /** * probe for a resource existing, * @param out * @param resource * @param errorText * @throws Exception */ int wantResource(JspWriter out, String resource, String errorText) throws Exception { if(!resourceExists(resource)) { out.write("
Warning: could not find resource "+resource
+"
"
+errorText);
return 0;
} else {
out.write("found "+resource+"
");
return 1;
}
}
/**
* get servlet version string
*
*/
public String getServletVersion() {
ServletContext context=getServletConfig().getServletContext();
int major = context.getMajorVersion();
int minor = context.getMinorVersion();
return Integer.toString(major) + '.' + Integer.toString(minor);
}
/**
* what parser are we using.
* @return the classname of the parser
*/
private String getParserName() {
SAXParser saxParser = getSAXParser();
if (saxParser == null) {
return "Could not create an XML Parser";
}
// check to what is in the classname
String saxParserName = saxParser.getClass().getName();
return saxParserName;
}
/**
* Create a JAXP SAXParser
* @return parser or null for trouble
*/
private SAXParser getSAXParser() {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
if (saxParserFactory == null) {
return null;
}
SAXParser saxParser = null;
try {
saxParser = saxParserFactory.newSAXParser();
} catch (Exception e) {
}
return saxParser;
}
/**
* get the location of the parser
* @return path or null for trouble in tracking it down
*/
private String getParserLocation(JspWriter out) {
SAXParser saxParser = getSAXParser();
if (saxParser == null) {
return null;
}
String location = getLocation(out,saxParser.getClass());
return location;
}
%>
Note: Even if everything this page probes for is present, there is no guarantee your web service will work, because there are many configuration options that we do not check for. These tests are necessary but not sufficient
Servlet version | <%= servletVersion %> |
XML Parser | <%= xmlParser %> |
XML ParserLocation | <%= xmlParserLocation %> |
We recommend Xerces 2 over Crimson as the XML parser for Axis
<% } %>"); for (;e.hasMoreElements();) { String key = (String) e.nextElement(); out.write(key + "=" + System.getProperty(key)+"\n"); } out.write("
"); } else { out.write("System properties are not accessible
"); } %>