You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by sv...@apache.org on 2003/11/11 15:05:33 UTC
cvs commit: ws-juddi/webapps/juddi fingerprint.jsp happyjuddi.jsp index.html search.jsp
sviens 2003/11/11 06:05:33
Added: webapps/juddi fingerprint.jsp happyjuddi.jsp index.html
search.jsp
Log:
Moved from jUDDI CVS at SourceForge
Revision Changes Path
1.1 ws-juddi/webapps/juddi/fingerprint.jsp
Index: fingerprint.jsp
===================================================================
<%@ page import="java.io.File,
java.io.IOException,
java.util.Date"
session="false" %>
<html>
<head>
<title>System Fingerprint</title>
</head>
<body bgcolor=#ffffff>
<%!
/*
* Fingerprint the users system. This is mainly for use in
* diagnosing classpath problems. It is intended to dump out
* a copy of the environment this webapp is running in,
* and additionally attempt to identify versions of each jar
* in the classpath.
*
* @author Brian Ewins
*/
private java.util.Properties versionProps=new java.util.Properties();
/**
* Identify the version of a jar file. This uses a properties file
* containing known names and sizes in the format
* 'name(size)=version'. Version strings should be like 'xerces-1.4'
* ie they should include the name of the library.
*/
public String getFileVersion(File file) throws IOException {
String key="<td>"+file.getName()+"</td>";
key+= "<td>"+file.length()+"</td>";
Date timestamp=new Date(file.lastModified());
key+= "<td>"+timestamp.toString()+"</td>";
return key;
/* TODO: implement
String value=versionProps.getProperty(key);
if (value==null) {
// make it possible to have jars without version nos
value=versionProps.getProperty(file.getName());
}
if (value==null) {
// fall back on something obvious
value=key;
Date timestamp=new Date(file.lastModified());
value+=" / "+timestamp.toString();
}
return value;
*/
}
/**
* Split up a classpath-like variable. Returns a list of files.
* TODO: this can't cope with relative paths. I think theres code in BCEL that
* can be used for this?
*/
File[] splitClasspath(String path) throws IOException {
java.util.StringTokenizer st=
new java.util.StringTokenizer(path,
System.getProperty("path.separator"));
int toks=st.countTokens();
File[] files=new File[toks];
for(int i=0;i<toks;i++) {
files[i]=new File(st.nextToken());
}
return files;
}
/** given a list of files, return a list of jars which actually exist */
File[] scanFiles(File[] files) throws IOException {
File[] jars=new File[files.length];
int found=0;
for (int i=0; i<files.length; i++) {
if (files[i].getName().toLowerCase().endsWith(".jar")
&& files[i].exists()) {
jars[found]=files[i];
found++;
}
}
if (found<files.length) {
File[] temp=new File[found];
System.arraycopy(jars,0,temp,0,found);
jars=temp;
}
return jars;
}
private static final File[] NO_FILES=new File[0];
/** scan a directory for jars */
public File[] scanDir(String dir) throws IOException
{
return scanDir(new File(dir));
}
public File[] scanDir(File dir) throws IOException {
if (!dir.exists() || !dir.isDirectory()) {
return NO_FILES;
}
return scanFiles(dir.listFiles());
}
/** scan a classpath for jars */
public File[] scanClasspath(String path) throws IOException {
if (path==null) {
return NO_FILES;
}
return scanFiles(splitClasspath(path));
}
/**
* scan a 'dirpath' (like the java.ext.dirs system property) for jars
*/
public File[] scanDirpath(String path) throws IOException {
if (path==null) {
return NO_FILES;
}
File[] current=new File[0];
File[] dirs=splitClasspath(path);
for(int i=0; i<dirs.length; i++) {
File[] jars=scanDir(dirs[i]);
File[] temp=new File[current.length+jars.length];
System.arraycopy(current,0,temp,0,current.length);
System.arraycopy(jars,0,temp,current.length,jars.length);
current=temp;
}
return scanFiles(current);
}
/** print out the jar versions for a directory */
public void listDirectory(String title, JspWriter out,String dir, String comment) throws IOException {
listVersions(title, out,scanDir(dir), comment);
}
/** print out the jar versions for a directory-like system property */
public void listDirProperty(String title, JspWriter out,String key, String comment) throws IOException {
listVersions(title, out,scanDir(System.getProperty(key)), comment);
}
/** print out the jar versions for a classpath-like system property */
public void listClasspathProperty(String title, JspWriter out,String key, String comment) throws IOException {
listVersions(title, out,scanClasspath(System.getProperty(key)), comment);
}
/** print out the jar versions for a 'java.ext.dirs'-like system property */
public void listDirpathProperty(String title, JspWriter out,String key, String comment) throws IOException {
listVersions(title, out,scanDirpath(System.getProperty(key)), comment);
}
/** print out the jar versions for a context-relative directory */
public void listContextPath(String title, JspWriter out, String path, String comment) throws IOException {
listVersions(title, out,scanDir(getServletConfig().getServletContext().getRealPath(path)), comment);
}
/** print out the jar versions for a given list of files */
public void listVersions(String title, JspWriter out,File[] jars, String comment) throws IOException {
out.print("<h2>");
out.print(title);
out.println("</h2>");
out.println("<table>");
for (int i=0; i<jars.length; i++) {
out.println("<tr>"+getFileVersion(jars[i])+"</tr>");
}
out.println("</table>");
if(comment!=null && comment.length()>0) {
out.println("<p>");
out.println(comment);
out.println("<p>");
}
}
%>
<h1>System Fingerprint</h1>
<h2>JVM and Server Version</h2>
<table>
<tr>
<td>Servlet Engine</td>
<td><%= getServletConfig().getServletContext().getServerInfo() %></td>
<td><%= getServletConfig().getServletContext().getMajorVersion() %></td>
<td><%= getServletConfig().getServletContext().getMinorVersion() %></td>
</tr>
<tr>
<td>Java VM</td>
<td><%= System.getProperty("java.vm.vendor") %></td>
<td><%= System.getProperty("java.vm.name") %></td>
<td><%= System.getProperty("java.vm.version") %></td>
</tr>
<tr>
<td>Java RE</td>
<td><%= System.getProperty("java.vendor") %></td>
<td><%= System.getProperty("java.version") %></td>
<td> </td>
</tr>
<tr>
<td>Platform</td>
<td><%= System.getProperty("os.name") %></td>
<td><%= System.getProperty("os.arch") %></td>
<td><%= System.getProperty("os.version") %></td>
</tr>
</table>
<%
listClasspathProperty("Boot jars", out,"sun.boot.class.path", "Only valid on a sun jvm");
listClasspathProperty("System jars", out,"java.class.path", null);
listDirpathProperty("Extra system jars", out,"java.ext.dirs", null);
listContextPath("Webapp jars", out, "/WEB-INF/lib", null);
// identify the container...
String container=getServletConfig().getServletContext().getServerInfo();
if (container.startsWith("Tomcat Web Server/3.2")) {
String home=System.getProperty("tomcat.home");
if(home!=null) {
listDirectory("Tomcat 3.2 Common Jars", out,
home+File.separator
+"lib",
null);
}
} else if (container.startsWith("Tomcat Web Server/3.3")) {
String home=System.getProperty("tomcat.home");
if(home!=null) {
listDirectory("Tomcat 3.3 Container Jars", out,
home+File.separator
+"lib"+File.separator
+"container",
null);
listDirectory("Tomcat 3.3 Common Jars", out,
home+File.separator
+"lib"+File.separator
+"common",
null);
}
} else if (container.startsWith("Apache Tomcat/4.0")) {
//handle catalina common dir
String home=System.getProperty("catalina.home");
if(home!=null) {
listDirectory("Tomcat 4.0 Common Jars", out,
home+File.separator
+"common"+File.separator
+"lib",
null);
}
} else if (container.startsWith("Apache Tomcat/4.1")) {
//handle catalina common dir
String home=System.getProperty("catalina.home");
if(home!=null) {
listDirectory("Tomcat 4.1 Common Jars", out,
home+File.separator
+"shared"+File.separator
+"lib",
null);
}
} else if (System.getProperty("resin.home")!=null) {
String home=System.getProperty("resin.home");
if(home!=null) {
listDirectory("Resin Common Jars", out,
home+File.separator
+"lib",
null);
}
} else if (System.getProperty("weblogic.httpd.servlet.classpath")!=null) {
listClasspathProperty("Weblogic Servlet Jars", out,
"weblogic.httpd.servlet.classpath",
null);
} else {
//TODO: identify more servlet engine classpaths.
}
%>
</body>
</html>
1.1 ws-juddi/webapps/juddi/happyjuddi.jsp
Index: happyjuddi.jsp
===================================================================
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="javax.sql.*" %>
<%!
/**
* Look for the named class in the classpath
*
* @param name of the class to lookup
* @return the location of the named class
* @throws IOException
*/
String lookupClass(String className)
throws IOException
{
// load the class (if it exists)
Class clazz = null;
try {
clazz = Class.forName(className);
if (clazz == null)
return null;
}
catch (ClassNotFoundException e) {
return null;
}
// class was found, now get it's URL
URL url = null;
try {
url = clazz.getProtectionDomain().getCodeSource().getLocation();
if (url == null)
return "";
}
catch(Throwable t) {
return "";
}
// got the classes URL, now determine it's location
String location = getLocation(url);
if (location == null)
return "";
else
return location;
}
/**
* Look for the named resource or properties file.
*
* @param resourceName
* @return true if the file was found
*/
String lookupResource(String resourceName)
{
URL url = null;
ClassLoader classLoader = null;
classLoader = this.getClass().getClassLoader();
if (classLoader != null)
{
url = classLoader.getResource(resourceName);
if (url != null) {
return getLocation(url);
}
}
else
{
classLoader = System.class.getClassLoader();
if (classLoader != null)
{
url = classLoader.getResource(resourceName);
if (url != null) {
return getLocation(url);
}
}
}
return null;
}
/**
* Determine the location of the Java class.
*
* @param clazz
* @return the file path to the jar file or class
* file where the class was located.
*/
String getLocation(URL url)
{
try
{
String location = url.toString();
if (location.startsWith("jar:file:/"))
{
File file = new File(url.getFile());
return file.getPath().substring(6);
}
else if (location.startsWith("jar"))
{
url = ((JarURLConnection)url.openConnection()).getJarFileURL();
return url.toString();
}
else if (location.startsWith("file"))
{
File file = new File(url.getFile());
return file.getAbsolutePath();
}
else
{
return url.toString();
}
}
catch (Throwable t) {
return null;
}
}
%>
<html>
<head>
<title>jUDDI Happiness Page</title>
<link rel="stylesheet" href="juddi.css">
</head>
<body>
<div class="nav" align="right"><font size="-2"><a href="http://www.juddi.org/">jUDDI.org</a></font></div>
<h1>jUDDI</h1>
<div class="announcement">
<p>
<h3>Happy jUDDI!</h3>
<h4>jUDDI Dependencies: Class Files & Libraries</h4>
<pre>
<%
String[] classArray = {
"org.apache.juddi.registry.Registry",
"javax.xml.soap.SOAPMessage",
"javax.xml.rpc.Service",
"org.apache.axis.transport.http.AxisServlet",
"org.apache.commons.collections.BeanMap",
"org.apache.commons.dbcp.PoolingDataSource",
"org.apache.commons.discovery.Resource",
"org.apache.commons.logging.Log",
"org.apache.commons.pool.impl.GenericObjectPool",
"org.apache.log4j.Layout",
"com.ibm.wsdl.factory.WSDLFactoryImpl",
"javax.xml.parsers.SAXParserFactory",
"javax.activation.DataHandler"
};
for (int i=0; i<classArray.length; i++)
{
out.write("<b>Looking for</b>: "+classArray[i]+"<br>");
String result = lookupClass(classArray[i]);
if (result == null)
{
out.write("<font color=\"red\">-Not Found</font><br>");
}
else if (result.length() == 0)
{
out.write("<font color=\"blue\">+Found in an unknown location</font><br>");
}
else
{
out.write("<font color=\"green\">+Found in: "+ result +"</font><br>");
}
}
%>
</pre>
<h4>jUDDI Dependencies: Resource & Properties Files</h4>
<pre>
<%
String[] resourceArray = {
"log4j.properties",
"juddi.properties"
};
for (int i=0; i<resourceArray.length; i++)
{
out.write("<b>Looking for</b>: "+resourceArray[i]+"<br>");
String result = lookupResource(resourceArray[i]);
if (result == null)
{
out.write("<font color=\"red\">-Not Found</font><br>");
}
else if (result.length() == 0)
{
out.write("<font color=\"blue\">+Found in an unknown location</font><br>");
}
else
{
out.write("<font color=\"green\">+Found in: "+ result +"</font><br>");
}
}
%>
</pre>
<h4>jUDDI DataSource Check</h4>
<pre>
<%
String dsname = null;
Context ctx = null;
DataSource ds = null;
Connection conn = null;
String sql = "SELECT COUNT(*) FROM PUBLISHER";
try
{
dsname = request.getParameter("dsname");
if ((dsname == null) || (dsname.trim().length() == 0))
dsname = "java:comp/env/jdbc/juddiDB";
ctx = new InitialContext();
if (ctx == null )
throw new Exception("No Context");
out.print("<font color=\"green\">");
out.print("+ Got a JNDI Context!");
out.println("</font>");
}
catch(Exception ex)
{
out.print("<font color=\"red\">");
out.print("- No JNDI Context ("+ex.getMessage()+")");
out.println("</font>");
}
try
{
ds = (DataSource)ctx.lookup(dsname);
if (ds == null)
throw new Exception("No Context");
out.print("<font color=\"green\">");
out.print("+ Got a JDBC DataSource (dsname="+dsname+")");
out.println("</font>");
}
catch(Exception ex)
{
out.print("<font color=\"red\">");
out.print("- No '"+dsname+"' DataSource Located("+ex.getMessage()+")");
out.println("</font>");
}
try
{
conn = ds.getConnection();
if (conn == null)
throw new Exception("No Connection (conn=null)");
out.print("<font color=\"green\">");
out.print("+ Got a JDBC Connection!");
out.println("</font>");
}
catch(Exception ex)
{
out.print("<font color=\"red\">");
out.print("- DB connection was not aquired. ("+ex.getMessage()+")");
out.println("</font>");
}
try
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
out.print("<font color=\"green\">");
out.print("+ "+sql+" = ");
if (rs.next())
out.print(rs.getString(1));
out.println("</font>");
conn.close();
}
catch (Exception ex)
{
out.print("<font color=\"red\">");
out.print("- "+sql+" failed ("+ex.getMessage()+")");
out.println("</font>");
}
%>
</pre>
<h4>jUDDI Properties</h4>
<pre>
<%
try
{
Properties juddiProps = org.apache.juddi.util.Config.getProperties();
if (juddiProps != null)
{
SortedSet sortedProperties = new TreeSet(juddiProps.keySet());
for (Iterator keys = sortedProperties.iterator(); keys.hasNext();)
{
String key = (String)keys.next();
out.println(key + ": " + juddiProps.getProperty(key));
}
}
else
{
out.println("No jUDDI Properties (juddiPropEnum=null)");
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</pre>
<h4>System Properties</h4>
<pre>
<%
try
{
Properties sysProps = System.getProperties();
SortedSet sortedProperties = new TreeSet(sysProps.keySet());
for (Iterator keys = sortedProperties.iterator(); keys.hasNext();)
{
String key = (String)keys.next();
out.println(key + ": " + sysProps.getProperty(key));
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</pre>
<hr>
Platform: <%= getServletConfig().getServletContext().getServerInfo() %>
<table width="100%" border="0">
<tr><td height="50" align="center" valign="bottom" nowrap><div class="footer">Copyright © 2003, <a href="mailto:steve@viens.net" target="_top">Steve Viens</a> and contributors, All rights reserved</div></td></tr>
</table>
</body>
</div>
</html>
1.1 ws-juddi/webapps/juddi/index.html
Index: index.html
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<link rel="stylesheet" href="juddi.css"/>
</head>
<body>
<div class="nav" align="right"><font size="-2"><a href="http://www.juddi.org/" target="_top">jUDDI.org</a></font></div>
<h1>jUDDI</h1>
<h3><em>Welcome</em> to jUDDI!</h3>
<ul>
<li><a href="happyjuddi.jsp">Validate</a> the local installation's configuration</li>
<li><a href="search">Browse</a> around the jUDDI Registry [not yet implemented]</li>
<li><a href="manage">Manage</a> your Web Services [not yet implemented]</li>
<li><a href="admin">Administer</a> jUDDI [not yet implemented]</li>
<li><a href="http://www.juddi.org">Visit</a> jUDDI.org</li>
</ul>
To enable the disabled features, uncomment the appropriate declarations in WEB-INF/web.xml
in the webapplication and restart it.
<hr>
If the "happyjuddi" validation page returns some kind of
error, it is invariably a configuration issue.
<table width="100%" border="0">
<tr><td height="50" align="center" valign="bottom" nowrap><div class="footer">Copyright © 2003, <a href="mailto:steve@viens.net" target="_top">Steve Viens</a> and contributors, All rights reserved</div></td></tr>
</table>
</body>
</html>
1.1 ws-juddi/webapps/juddi/search.jsp
Index: search.jsp
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>jUDDI</title>
<link rel="stylesheet" href="juddi.css"/>
<script>function setFocus() { document.sform.qstring.focus(); }</script>
</head>
<body onLoad=setFocus()>
<div class="nav" align="right"><font size="-2"><a href="http://www.juddi.org/" target="_top">jUDDI.org</a></font></div>
<p>
<center>
<form name="sform">
<table cellspacing="5" cellpadding="5" border="0">
<tr><td align="center" colspan="2"><img border="0" height="60" width="180" src="images/search_logo.gif"></td></tr>
<tr>
<td align="center" colspan="2">
<input type="hidden" name="lang" value="en">
<input maxLength="256" size="35" name="qstring" value="">
<input type="submit" value="Search" name="search"></td>
</tr>
<tr>
<td nowrap>
<font size="-2">Search for:</font><br>
<input type="checkbox" title="Business Entity" name="business" value="true" checked>Business Entities<br>
<input type="checkbox" title="Business Service" name="service" value="true" checked>Business Services<br>
<input type="checkbox" title="Service Type (TModel)" name="tmodel" value="true" checked>Service Types (TModels)</td>
<td valign="top" nowrap> <font size="-2"> • <a href=advanced>Advanced Search</a><br>
• <a href=manage>Manage Your Services</a><br>
• <a href=admin>jUDDI Administration</a> </font></td>
</tr>
</table>
</form>
</center>
</p>
<table width="100%" border="0">
<tr><td height="25" align="center" valign="bottom" nowrap><div class="footer">Copyright © 2003, <a href="mailto:steve@viens.net" target="_top">Steve Viens</a> and contributors, All rights reserved</div></td></tr>
</table>
</body>
</html>