<% out.print(""); %> <%@ page import=" javax.servlet.http.HttpServletRequest, javax.servlet.jsp.JspWriter, java.io.File "%> <%@ page import="org.apache.tomee.common.TomcatVersion"%> TomEE

Testing openejb.home validity

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

<%! static String invLock = "lock"; static int invCount; HttpSession session; HttpServletRequest request; JspWriter out; String OK = "OK"; String FAIL = "FAIL"; /** * 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; try { // The openejb.home must be set out.print("openejb.home is set "); String homePath = System.getProperty("openejb.home"); if (homePath == null) handleError(NO_HOME, INSTRUCTIONS); out.print(OK); out.print(""); // The openejb.home must exist out.print("openejb.home exists "); File openejbHome = new File(homePath); if (!openejbHome.exists()) handleError(BAD_HOME + homePath, NOT_THERE, INSTRUCTIONS); out.print(OK); out.print(""); // The openejb.home must be a directory out.print("openejb.home is a directory "); if (!openejbHome.isDirectory()) handleError(BAD_HOME + homePath, NOT_DIRECTORY, INSTRUCTIONS); out.print(OK); out.print(""); // The openejb.home must contain a 'lib' directory out.print("has lib directory "); File openejbHomeLib; if (TomcatVersion.v6.isTheVersion() || TomcatVersion.v7.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); out.print(""); } catch (Exception e) { out.print(FAIL); 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 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); } %>