<%@ page import=" javax.naming.InitialContext, javax.naming.Context, javax.naming.*, java.util.Properties, javax.naming.Context, javax.naming.InitialContext, javax.servlet.ServletConfig, javax.servlet.ServletException, javax.servlet.http.HttpServlet, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.jsp.JspWriter, java.io.PrintWriter, java.util.*, java.io.*, java.lang.reflect.Method, java.lang.reflect.InvocationTargetException, java.lang.reflect.Modifier , org.openejb.loader.SystemInstance"%> OpenEJB Tomcat Integration/1.0
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; String home = SystemInstance.get().getProperty("openejb.home"); out.print("openejb.home = "+ home+"

"); try{ out.print(HR); out.print(""); // The openejb.home must be set out.print(" "); String homePath = 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 = new File(openejbHome, "lib"); if ( !openejbHomeLib.exists() ) handleError(BAD_HOME+homePath, NO_LIBS, 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_DIST = "The path specified is not correct, it does not contain a 'dist' 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); } %>