<%@ page import=" javax.servlet.http.HttpServletRequest, javax.servlet.jsp.JspWriter, java.io.File "%> <%@ page import="org.apache.openejb.tomcat.common.TomcatVersion"%> OpenEJB/Tomcat
OpenEJBIndexJNDIEJBClassInvoke
   



Testing openejb.home validity

<% try{ synchronized (this) { main(request, session, out); } } catch (Exception e){ out.println("FAIL"); //throw e; return; } %>


 
<%! String tab = "    "; static String invLock = "lock"; static int invCount; HttpSession session; HttpServletRequest request; JspWriter out; String OK = "OK"; String FAIL = "FAIL"; String HR = "
"; String pepperImg = ""; /** * The main method of this JSP */ public void main(HttpServletRequest request, HttpSession session, JspWriter out) throws Exception { this.request = request; this.session = session; this.out = out; // out.print("openejb.home = " + System.getProperty("openejb.home") + "

"); try { out.print(HR); out.print(""); // The openejb.home must be set out.print(" "); String homePath = System.getProperty("openejb.home"); if (homePath == null) handleError(NO_HOME, INSTRUCTIONS); out.print(OK); // The openejb.home must exist out.print(" "); File openejbHome = new File(homePath); if (!openejbHome.exists()) handleError(BAD_HOME + homePath, NOT_THERE, INSTRUCTIONS); out.print(OK); // The openejb.home must be a directory out.print(" "); if (!openejbHome.isDirectory()) handleError(BAD_HOME + homePath, NOT_DIRECTORY, INSTRUCTIONS); out.print(OK); // The openejb.home must contain a 'lib' directory out.print(" "); File openejbHomeLib; if (TomcatVersion.v6.isTheVersion()) { openejbHomeLib = new File(openejbHome, "lib"); } else { File common = new File(openejbHome, "common"); openejbHomeLib = new File(common, "lib"); } if (!openejbHomeLib.exists()) handleError(BAD_HOME + homePath, NO_LIB, INSTRUCTIONS); out.print(OK); // // The openejb.home there must be openejb*.jar files in the 'lib' directory // out.print(" "); // String[] libs = openejbHomeLib.list(); // boolean found = false; // for (int i = 0; i < libs.length && !found; i++) { // found = (libs[i].startsWith("openejb-") && libs[i].endsWith(".jar")); // } // if (!found) handleError(BAD_HOME + homePath, NO_LIBS, INSTRUCTIONS); // out.print(OK); out.print("
openejb.home is set
openejb.home exists
openejb.home is a directory
has lib directory
has openejb* libraries
"); out.print(HR); out.print("
" + pepperImg + ""); out.print("Continue tests"); out.print("
"); } catch (Exception e) { out.print(FAIL); out.print(""); out.print(HR); out.print(e.getMessage()); } } String NO_HOME = "The openejb.home is not set."; String BAD_HOME = "Invalid openejb.home: "; String NOT_THERE = "The path specified does not exist."; String NOT_DIRECTORY = "The path specified is not a directory."; String NO_LIB = "The path specified is not correct, it does not contain a 'lib' directory."; String NO_LIBS = "The path specified is not correct, it does not contain any OpenEJB libraries."; String INSTRUCTIONS = "Please edit the web.xml of the openejb_loader webapp and set the openejb.home init-param to the full path where OpenEJB is installed."; private void handleError(String m1, String m2, String m3) throws Exception { String msg = "
Please Fix:

"; msg += m1 + "

"; msg += m2 + "

"; msg += m3 + "
"; throw new Exception(msg); } private void handleError(String m1, String m2) throws Exception { String msg = "
Please Fix:

"; msg += m1 + "

"; msg += m2 + "
"; throw new Exception(msg); } %>