%@ page import="java.io.InputStream, java.io.IOException"%> <%! /** * Happiness tests for axis. These look at the classpath and warn if things * are missing. Normally addng this much code in a JSP page is mad * but here we want to validate JSP compilation too, and have a drop-in * page for easy re-use * @author Steve 'configuration problems' Loughran */ /** * Get a string providing install information. * TODO: make this platform aware and give specific hints */ public String getInstallHints(HttpServletRequest request) { String hint= "On Tomcat 4.x, you may need to put libraries that contain" +"java.* or javax.* into TOMCAT_HOME/commons/lib"; return hint; } /** * test for a class existing * @param classname * @return */ boolean classExists(String classname) { try { Class t = Class.forName(classname); return true; } catch (ClassNotFoundException e) { return false; } } boolean resourceExists(String resource) { boolean found; InputStream instream=this.getClass().getResourceAsStream(resource); found=instream!=null; if(instream!=null) { try { instream.close(); } catch (IOException e) { } } return found; } /** * bail out 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 */ boolean needClass(JspWriter out, String classname, String jarFile, String errorText, String homePage) throws IOException { if(!classExists(classname)) { String url=""; if(homePage!=null) { url="; see "+homePage+""; } out.write("
Error: could not find class "+classname
+" from file "+jarFile
+"
"+errorText
+url
+"
");
return false;
} else {
out.write("Found "+jarFile+"
");
return true;
}
}
/**
* 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
*/
boolean wantClass(JspWriter out,
String jarFile,
String classname,
String errorText,
String homePage) throws IOException {
if(!classExists(classname)) {
String url="";
if(homePage!=null) {
url="
See "+homePage+"";
}
out.write("
Warning: could not find class "+classname
+" from file "+jarFile
+"
"+errorText
+url
+"
");
return false;
} else {
out.write("Found "+jarFile+"
");
return true;
}
}
/**
* probe for a resource existing,
* @param out
* @param resource
* @param errorText
* @throws Exception
*/
void wantResource(JspWriter out,
String resource,
String errorText) throws Exception {
if(!resourceExists(resource)) {
out.write("
Warning: could not find resource "+resource
+"
"
+errorText);
} else {
out.write("found "+resource+"
");
}
}
%>
<% boolean needed,wanted; needed=needClass(out, "javax.xml.soap.SOAPMessage", "saaj.jar", "from Apache or Sun", "http://xml.apache.org/axis/"); needed&=needClass(out, "javax.xml.rpc.Service", "jaxrpc.jar", "from Apache or Sun", "http://xml.apache.org/axis/"); needed&=needClass(out, "org.apache.axis.transport.http.AxisServlet", "axis.jar", "from Apache", "http://xml.apache.org/axis/"); wanted=wantClass(out,"javax.activation.DataHandler", "activation.jar", "Soap With Attachments will not work.", "http://java.sun.com/products/javabeans/glasgow/jaf.html"); wanted&=wantClass(out,"javax.mail.internet.MimeMessage", "mail.jar", "Soap With Attachments will not work;", "http://java.sun.com/products/javamail/"); wantResource(out,"server-config.wsdd", "There is no a server configuration file;" +"run AdminClient to create one"); /* add more libraries here */ //error text if(needed) { out.write("