Return-Path: Delivered-To: apmail-openejb-commits-archive@www.apache.org Received: (qmail 70475 invoked from network); 3 Aug 2007 05:22:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 05:22:57 -0000 Received: (qmail 94522 invoked by uid 500); 3 Aug 2007 05:22:57 -0000 Delivered-To: apmail-openejb-commits-archive@openejb.apache.org Received: (qmail 94497 invoked by uid 500); 3 Aug 2007 05:22:57 -0000 Mailing-List: contact commits-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openejb.apache.org Delivered-To: mailing list commits@openejb.apache.org Received: (qmail 94487 invoked by uid 99); 3 Aug 2007 05:22:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2007 22:22:57 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 05:22:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 831711A9829; Thu, 2 Aug 2007 22:22:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r562334 [7/8] - in /openejb/trunk/openejb3/server: ./ openejb-webadmin/ openejb-webadmin/src/ openejb-webadmin/src/main/ openejb-webadmin/src/main/etc/ openejb-webadmin/src/main/java/ openejb-webadmin/src/main/java/org/ openejb-webadmin/src... Date: Fri, 03 Aug 2007 05:22:00 -0000 To: commits@openejb.apache.org From: dblevins@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070803052203.831711A9829@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripe105.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripe105.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripes1.gif URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripes1.gif?view=auto&rev=562334 ============================================================================== Binary file - no diff available. Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripes1.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/stripes1.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_2.gif URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_2.gif?view=auto&rev=562334 ============================================================================== Binary file - no diff available. Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_2.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_2.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_3.gif URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_3.gif?view=auto&rev=562334 ============================================================================== Binary file - no diff available. Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_3.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/images/top_3.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/index.html URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/index.html?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/index.html (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/index.html Thu Aug 2 22:21:56 2007 @@ -0,0 +1,86 @@ + + + + OpenEJB Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + OpenEJB and Tomcat Integration Page + +
+
+

+ + Welcome to the OpenEJB/Tomcat integration page!

+ If you haven't already done so, please set the openejb.home init-param in the + web.xml of this application. Setting the openejb.home correctly is the most + important thing to do. In fact, it is the only thing you have to do. +

+ Once you think you have the openejb.home set, click on + the "Testing your setup" link below to verify it. When everything + is setup well, feel free to play around with the tools provided below! +

+ Setup
+ Testing your setup
+
+ Tools
+ OpenEJB JNDI Browser
+ OpenEJB Class Viewer
+ OpenEJB EJB Viewer
+ OpenEJB Object Invoker
+
+ FAQs
+ How does the integration work
+ Where to put your bean classes
+ How to configure java:comp/env lookups
+
+
+

+

+

+
+
+
+ + +  
+ + \ No newline at end of file Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/index.html ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/invokeobj.jsp URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/invokeobj.jsp?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/invokeobj.jsp (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/invokeobj.jsp Thu Aug 2 22:21:56 2007 @@ -0,0 +1,691 @@ +<%@ 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 +"%> + + + + OpenEJB Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + OpenEJB Object Invoker + +
+
+

+

+ +<% + 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; + + class Invocation { + + String id = "inv"; + String objID; + Class clazz; + Object target; + Method method; + Object[] args; + Object result; + Invocation(){ + synchronized (invLock){ + id += ++invCount; + } + } + + public Object invoke() throws Exception{ + if (target == null || method == null || args == null) { + throw new Exception("This invocation contains null objects."); + } + return method.invoke(target,args); + } + } + + /** + * 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; + + printObjectSection(); + } + + /** + * Print the list of objects with the focused object as + * selected in the box. + * If no object is selected, make an entry called "Pick an Object" + */ + public void printObjectSection() throws Exception{ + String removeID = request.getParameter("remove"); + if (removeID != null) { + removeObject(removeID); + } + + Invocation inv = null; + String invID = request.getParameter("inv"); + + if (invID == null) { + String objID = request.getParameter("obj"); + if (objID != null) { + inv = new Invocation(); + inv.target = getObject(objID); + inv.objID = objID; + setInvocation(inv.id,inv); + } + } else { + inv = getInvocation(invID); + } + + if (inv == null || inv.target == null) { + // Pick from the list + printObjectList(); + + } else { + out.print("Object:
"); + out.print(tab+inv.objID+" [change]

"); + + // Show the selected item and continue + printMethodSection(inv); + } + } + + /** + * Prints the list of objects that can be invoked + */ + public void printObjectList() throws Exception{ + + HashMap objects = getObjectMap(); + if (objects.size() == 0){ + out.print("No object have been created
"); + out.print(""); + printRow(pepperImg,"Browse for an EJB"); + out.print("
"); + + } else { + out.print("Pick and object to invoke
"); + + //out.print("Objects:
"); + Set keys = objects.keySet(); + Iterator iterator = keys.iterator(); + out.print(""); + while (iterator.hasNext()) { + String entry = (String)iterator.next(); + printRow(tab+""+entry+"", + "[remove]"); + } + out.print("
"); + } + } + /** + * Print the list of methods with the focused method as + * selected in the box. + * If no method is selected, make an entry called "Pick a Method" + */ + public void printMethodSection(Invocation inv) throws Exception{ + String methodID = request.getParameter("m"); + + if (methodID != null) { + int method = Integer.parseInt(methodID); + Method[] methods = inv.clazz.getMethods(); + if (method > -1 && method < methods.length) { + inv.method = methods[method]; + } else { + inv.method = null; + inv.args = null; + } + } + + if (inv.method == null) { + // Pick from the list + printMethodList(inv); + + } else { + out.print("Method:
"); + out.print(tab+formatMethod(inv.method)+" [change]

"); + + // Show the selected item and continue + printArgumentSection(inv); + } + + } + + /** + * Prints the list of methods that can be invoked + */ + public void printMethodList(Invocation inv) throws Exception{ + out.print("Pick a method to invoke
"); + //out.print("Methods:
"); + + Object obj = inv.target; + Class clazz = inv.target.getClass(); + if (obj instanceof javax.ejb.EJBHome) { + clazz = obj.getClass().getInterfaces()[0]; + } else if (obj instanceof javax.ejb.EJBObject) { + clazz = obj.getClass().getInterfaces()[0]; + } else { + clazz = obj.getClass(); + } + inv.clazz = clazz; + + out.print(""); + Method[] methods = clazz.getMethods(); + for (int i=0; i < methods.length; i++){ + Method m = methods[i]; + if (Modifier.isPublic(m.getModifiers())){ + out.print(""); + } + } + out.print("
"); + out.print(tab+""+formatMethod(m)+"
"); + out.print("
"); + } + + /** + * Print the list of arguments. + * If no arguments have been selected, + * show the argument entry form. + */ + public void printArgumentSection(Invocation inv) throws Exception{ + String args = request.getParameter("args"); + + if (args != null) { + parseArgs(inv); + } + + if (inv.method.getParameterTypes().length == 0) { + inv.args = new Object[]{}; + } + + if (inv.args == null) { + printArgumentList(inv); + } else { + out.print("Arguments:
"); + if (inv.args.length == 0) { + out.print(tab+"none
"); + } + for (int i=0; i < inv.args.length; i++){ + String val = formatObject(inv.args[i]); + out.print(tab+"arg"+i+"  "+val+"
"); + } + out.print("
"); + printInvokeSection(inv); + } + } + + public void parseArgs(Invocation inv) throws Exception{ + Class[] pTypes = inv.method.getParameterTypes(); + inv.args = new Object[pTypes.length]; + + for (int i=0; i < pTypes.length; i++){ + Class type = pTypes[i]; + String unparsedArg = request.getParameter("arg"+i); + inv.args[i] = getConverter(type).convert(type, unparsedArg); + } + } + + public void printArgumentList(Invocation inv) throws Exception{ + out.print("Fill in the arguments
"); + Class[] pTypes = inv.method.getParameterTypes(); + out.print("
"); + out.print(""); + out.print(""); + for (int i=0; i < pTypes.length; i++){ + Converter con = getConverter(pTypes[i]); + out.print(""); + out.print(""); + out.print(""); + out.print(""); + } + out.print("
"); + out.print(tab+getShortClassRef(pTypes[i])); + out.print(""); + out.print("  arg"+i); + out.print(""); + out.print("  "+con.getInputControl(i,pTypes[i])); + out.print("
"); + + out.print("

"); + out.print(""); + out.print("
"); + + } + + /** + * Print the list of arguments. + * If no arguments have been selected, + * show the argument entry form. + */ + public void printInvokeSection(Invocation inv) throws Exception{ + String doInvoke = request.getParameter("invoke"); + if (doInvoke != null) { + invoke(inv); + } else { + out.print("
"); + out.print(""); + out.print(""); + out.print("
"); + } + + } + String pepperImg = ""; + public void invoke(Invocation inv) throws Exception{ + + try{ + inv.result = inv.invoke(); + + out.print("Result:
"); + if (inv.method.getReturnType() == java.lang.Void.TYPE) { + out.print(tab+"Done"); + } else if (inv.result == null) { + out.print(tab+"null"); + } else { + String clazz = inv.result.getClass().getName(); + String objID = getObjectID(inv.result); + setObject(objID,inv.result); + + out.print(""); + printRow("id",objID); + printRow("class",""+clazz+""); + printRow("toString",formatObject(inv.result)); + out.print("
"); + + out.print("

Actions:
"); + out.print(""); + String invokerURL = "Invoke a method on the object"; + printRow(pepperImg,invokerURL); + String discardURL = "Discard the object"; + printRow(pepperImg,discardURL); + out.print("
"); + } + } catch (InvocationTargetException e){ + out.print("Exception:

"); + Throwable t = e.getTargetException(); + out.print("Received a "+t.getClass().getName()); + //out.print(inv.method+"

"); + if (t instanceof java.rmi.RemoteException) { + out.print(" [Tip]

"); + java.rmi.RemoteException re = (java.rmi.RemoteException)t; + out.print("RemoteException message:
"); + out.print(t.getMessage()+"

"); + out.print("Nested exception's stack trace:
"); + + while (t instanceof java.rmi.RemoteException) { + t = ((java.rmi.RemoteException)t).detail; + } + out.print(formatThrowable(t)); + } else { + out.print("

"+formatThrowable(t)); + } + + } catch (Throwable e){ + out.print("Exception:

"); + out.print(formatObject(e)); + } + } + + public String formatThrowable(Throwable err) throws Exception{ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + err.printStackTrace(new PrintStream(baos)); + byte[] bytes = baos.toByteArray(); + StringBuffer sb = new StringBuffer(bytes.length); + for (int i=0; i < bytes.length; i++){ + char c = (char)bytes[i]; + switch (c) { + case ' ': sb.append(" "); break; + case '\n': sb.append("
"); break; + case '\r': break; + default: sb.append(c); + } + } + return sb.toString(); + } + + + public String formatObject(Object obj) throws Exception{ + int max = 75; + String val = obj.toString(); + val = (val.length() > max)? val.substring(0,max-3)+"...":val; + char[] chars = new char[val.length()]; + val.getChars(0,chars.length,chars,0); + + StringBuffer sb = new StringBuffer(chars.length); + for (int j=0; j < chars.length; j++){ + char c = chars[j]; + switch (c) { + case '<': sb.append("<"); break; + case '>': sb.append(">"); break; + case '&': sb.append("&"); break; + default: sb.append(c); + } + } + return sb.toString(); + } + + /*-----------------------------------------------------------*/ + // Method name formatting + /*-----------------------------------------------------------*/ + public String formatMethod(Method m) throws Exception { + StringBuffer sb = new StringBuffer(); + + sb.append(getShortClassName(m.getReturnType())+"  "); + sb.append(m.getName()); + + Class[] params = m.getParameterTypes(); + sb.append("("); + for (int j=0; j < params.length; j++){ + sb.append(getShortClassName(params[j])); + if (j != params.length-1) { + sb.append(", "); + } + } + sb.append(")"); + + Class[] excp = m.getExceptionTypes(); + if (excp.length > 0) { + sb.append(" throws "); + for (int j=0; j < excp.length; j++){ + sb.append(getShortClassName(excp[j])); + if (j != excp.length-1) { + sb.append(", "); + } + } + } + return sb.toString(); + } + + /*-----------------------------------------------------------*/ + // Class name formatting + /*-----------------------------------------------------------*/ + public String getShortClassName(Class clazz) throws Exception { + if (clazz.isPrimitive()) { + return clazz.getName(); + } else if (clazz.isArray() && clazz.getComponentType().isPrimitive()) { + return clazz.getComponentType()+"[]"; + } else if (clazz.isArray()) { + String name = clazz.getComponentType().getName(); + int dot = name.lastIndexOf(".")+1; + String shortName = name.substring(dot,name.length()); + return shortName+"[]"; + } else { + String name = clazz.getName(); + int dot = name.lastIndexOf(".")+1; + String shortName = name.substring(dot,name.length()); + return shortName; + } + } + + public String getShortClassRef(Class clazz) throws Exception { + if (clazz.isPrimitive()) { + return ""+clazz.getName()+""; + } else if (clazz.isArray() && clazz.getComponentType().isPrimitive()) { + return ""+clazz.getComponentType()+"[]"; + } else if (clazz.isArray()) { + String name = clazz.getComponentType().getName(); + int dot = name.lastIndexOf(".")+1; + String shortName = name.substring(dot,name.length()); + return ""+shortName+"[]"; + } else { + String name = clazz.getName(); + int dot = name.lastIndexOf(".")+1; + String shortName = name.substring(dot,name.length()); + return ""+shortName+""; + } + } + + protected void printRow(String col1, String col2) throws Exception{ + out.print("" ); + out.print(col1); + out.print(""); + out.print(col2); + out.print(""); + } + + /*-----------------------------------------------------------*/ + // Object list support + /*-----------------------------------------------------------*/ + public String getObjectID(Object obj){ + Class clazz = obj.getClass(); + if (obj instanceof javax.ejb.EJBHome) { + clazz = obj.getClass().getInterfaces()[0]; + } else if (obj instanceof javax.ejb.EJBObject) { + clazz = obj.getClass().getInterfaces()[0]; + } + return clazz.getName()+"@"+obj.hashCode(); + } + + public Object getObject(String objID){ + return getObjectMap().get(objID); + } + + public void setObject(String objID, Object obj){ + getObjectMap().put(objID, obj); + } + + public void removeObject(String objID){ + getObjectMap().remove(objID); + } + + public HashMap getObjectMap(){ + HashMap objects = (HashMap)session.getAttribute("objects"); + if (objects == null) { + objects = new HashMap(); + session.setAttribute("objects",objects); + } + return objects; + } + + /*-----------------------------------------------------------*/ + // Invocation list support + /*-----------------------------------------------------------*/ + public Invocation getInvocation(String invID) { + return (Invocation)getInvocationMap().get(invID); + } + + public void setInvocation(String invID, Invocation obj){ + getInvocationMap().put(invID, obj); + } + + public HashMap getInvocationMap(){ + HashMap invocations = (HashMap)session.getAttribute("invocations"); + if (invocations == null) { + invocations = new HashMap(); + session.setAttribute("invocations",invocations); + } + return invocations; + } + + /*-----------------------------------------------------------*/ + // String conversion support + /*-----------------------------------------------------------*/ + final HashMap converters = initConverters(); + + public Converter getConverter(Class type){ + Converter con = (Converter) converters.get(type); + if (con == null) { + con = defaultConverter; + } + return con; + } + + final Converter defaultConverter = new ObjectConverter(); + + private HashMap initConverters(){ + HashMap map = new HashMap(); + + map.put(String.class, new StringConverter()); + map.put(Character.class, new CharacterConverter()); + map.put(Boolean.class, new BooleanConverter()); + map.put(Byte.class, new ByteConverter()); + map.put(Short.class, new ShortConverter()); + map.put(Integer.class, new IntegerConverter()); + map.put(Long.class, new LongConverter()); + map.put(Float.class, new FloatConverter()); + map.put(Double.class, new DoubleConverter()); + map.put(Object.class, new ObjectConverter()); + map.put(Character.TYPE, map.get(Character.class)); + map.put(Boolean.TYPE, map.get(Boolean.class)); + map.put(Byte.TYPE, map.get(Byte.class)); + map.put(Short.TYPE, map.get(Short.class)); + map.put(Integer.TYPE, map.get(Integer.class)); + map.put(Long.TYPE, map.get(Long.class)); + map.put(Float.TYPE, map.get(Float.class)); + map.put(Double.TYPE, map.get(Double.class)); + + return map; + } + + + abstract class Converter { + public abstract Object convert(Class type, String raw) throws Exception; + public String getInputControl(int argNumber, Class type) throws Exception{ + return ""; + } + } + + class StringConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return raw; + } + } + + class CharacterConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Character(raw.charAt(0)); + } + } + + class BooleanConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Boolean(raw); + } + } + + class ByteConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Byte(raw); + } + } + + class ShortConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Short(raw); + } + } + + class IntegerConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Integer(raw); + } + } + + class LongConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Long(raw); + } + } + + class FloatConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Float(raw); + } + } + + class DoubleConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return new Double(raw); + } + } + + class ObjectConverter extends Converter{ + public Object convert(Class type, String raw) throws Exception { + return raw; + } + } +%> + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/invokeobj.jsp ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/re-help.html URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/re-help.html?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/re-help.html (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/re-help.html Thu Aug 2 22:21:56 2007 @@ -0,0 +1,93 @@ + + + + OpenEJB Tomcat Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + OpenEJB and EJB Help + +
+
+

+ + The java.rmi.RemoteException is thrown whenever something unexcpected happens while invoking the requested method + on your enterprise bean instance. Usually, these are runtime exceptions that your bean didn't catch, + java.lang.NullPointerException being the most common.

+ The java.rmi.RemoteException itself is just a wrapper for the real exception. It may have a useful message + associated with it, but it's stack trace is usually worthless to you. To get the most useful output from a + RemoteException, use the error handling code bellow.

+
+

+try {
+    myEjb.businessMethod();
+} catch (java.rmi.RemoteException re){
+    System.out.println(re.getMessage());
+    Throwable realException = re.detail;
+    realException.printStackTrace();
+}
+
+ + Sometimes, the exception nested inside the java.rmi.RemoteException caught is actually another + java.rmi.RemoteException. A clever strategy to unwrap all the nested RemoteExceptions is to + cycle through them in a while loop as follows. This is the approach the OpenEJB Object Invoker + takes, so if you like the error messages you see here, just copy the this code: + + +
+try {
+    myEjb.businessMethod();
+} catch (java.rmi.RemoteException re){
+    System.out.println(re.getMessage());
+    Throwable t = re;
+    while (t instanceof java.rmi.RemoteException) {
+        t = ((java.rmi.RemoteException)t).detail;
+    }
+    t.printStackTrace();
+}
+
+

+ +
+ + +  
+ + + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/re-help.html ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testejb.jsp URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testejb.jsp?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testejb.jsp (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testejb.jsp Thu Aug 2 22:21:56 2007 @@ -0,0 +1,263 @@ +<%@ 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 +"%> + + + + OpenEJB Tomcat Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + Testing an Enterprise JavaBean + +
+
+

+

+ +<% + 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; + + InitialContext ctx = null; + ClassLoader myLoader = null; + try{ + myLoader = this.getClass().getClassLoader(); + Properties p = new Properties(); + + p.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory"); + + ctx = new InitialContext( p ); + + } catch (Exception e){ + formatThrowable(e); + } + + try{ + out.print(HR); + out.print(""); + + + // --------------------------------------------------- + // Can I lookup a home interface from the testsuite? + // --------------------------------------------------- + + printTest("Looking up an ejb home "); + + Object ejbHome = null; + try{ + ejbHome = ctx.lookup( "client/tests/stateless/BasicStatelessHome" ); + if (ejbHome instanceof java.rmi.Remote) out.println(OK); + } catch (Exception e){ + out.println(FAIL); + return; + } + + // --------------------------------------------------- + // Is the home interface visible? + // --------------------------------------------------- + + printTest("Checking for the home interface class definition "); + + Class homeInterface; + try{ + homeInterface = Class.forName("org.openejb.test.stateless.BasicStatelessHome",true, myLoader); + out.println(OK); + } catch (Exception e){ + out.println(FAIL); + return; + } + + // --------------------------------------------------- + // Can I invoke a create method on the ejb home? + // --------------------------------------------------- + + printTest("Invoking the create method on the ejb home "); + + Object ejbObject = null; + try{ + Class[] params = new Class[0]; + Method create = null; + create = homeInterface.getDeclaredMethod("create", params); + ejbObject = create.invoke(ejbHome, new Object[0]); + + if (ejbObject instanceof java.rmi.Remote) out.println(OK); + + } catch (Exception e){ + out.println(FAIL); + return; + } + + // --------------------------------------------------- + // Is the remote interface visible? + // --------------------------------------------------- + + printTest("Checking for the remote interface class definition "); + + Class remoteInterface; + try{ + remoteInterface = Class.forName("org.openejb.test.stateless.BasicStatelessObject",true, myLoader); + out.println(OK); + } catch (Exception e){ + out.println(FAIL); + return; + } + + // --------------------------------------------------- + // Can I invoke a business method on the ejb object? + // --------------------------------------------------- + + printTest("Invoking a business method on the ejb object "); + + Object returnValue = null; + try{ + String message = "!snoitalutargnoC ,skroW gnihtyrevE"; + Class[] params = new Class[]{String.class}; + Method businessMethod = null; + businessMethod = remoteInterface.getDeclaredMethod("businessMethod", params); + returnValue = businessMethod.invoke(ejbObject, new Object[]{message}); + + if (returnValue instanceof java.lang.String) out.println(OK); + + } catch (Exception e){ + out.println(FAIL); + return; + } + out.print("
"); + out.print(HR); + + out.println("
The Enterprise Bean returned the following message:

"); + + out.println(""+returnValue+""); + + + + } catch (Exception e){ + out.print(FAIL); + out.print(""); + out.print(HR); + + out.print(e.getMessage()); + } + } + + protected void printTest(String test) throws IOException{ + out.print("" ); + out.print(test); + out.print(""); + } + + public String formatThrowable(Throwable err) throws Exception{ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + err.printStackTrace(new PrintStream(baos)); + byte[] bytes = baos.toByteArray(); + StringBuffer sb = new StringBuffer(bytes.length); + for (int i=0; i < bytes.length; i++){ + char c = (char)bytes[i]; + switch (c) { + case ' ': sb.append(" "); break; + case '\n': sb.append("
"); break; + case '\r': break; + default: sb.append(c); + } + } + return sb.toString(); + } +%> + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testejb.jsp ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testhome.jsp URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testhome.jsp?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testhome.jsp (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testhome.jsp Thu Aug 2 22:21:56 2007 @@ -0,0 +1,196 @@ +<%@ 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); + } + + +%> + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testhome.jsp ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testint.jsp URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testint.jsp?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testint.jsp (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testint.jsp Thu Aug 2 22:21:56 2007 @@ -0,0 +1,243 @@ +<%@ 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 +"%> + + + + OpenEJB Tomcat Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + Testing integration + +
+
+

+

+ +<% + 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; + + InitialContext ctx = null; + try{ + Properties p = new Properties(); + + p.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory"); + + ctx = new InitialContext( p ); + + } catch (Exception e){ + formatThrowable(e); + } + + try{ + out.print(HR); + out.print(""); + + // --------------------------------------------------- + // Were the OpenEJB classes installed? + // --------------------------------------------------- + + printTest("Were the OpenEJB classes installed"); + ClassLoader myLoader = null; + Class openejb = null; + try{ + myLoader = this.getClass().getClassLoader(); + openejb = Class.forName("org.openejb.OpenEJB",true, myLoader); + out.print(OK); + } catch (Exception e){ + out.print(FAIL); + } + + + // --------------------------------------------------- + // Are the EJB libraries visible? + // --------------------------------------------------- + + printTest("Were the EJB classes installed"); + try{ + Class.forName("javax.ejb.EJBHome",true, myLoader); + out.print(OK); + } catch (Exception e){ + out.print(FAIL); + } + + // --------------------------------------------------- + // Was OpenEJB initialized (aka started)? + // --------------------------------------------------- + + printTest("Was OpenEJB initialized (aka started)"); + + try{ + Class[] params = new Class[0]; + Method isInitialized = null; + isInitialized = openejb.getDeclaredMethod("isInitialized", params); + Object val = isInitialized.invoke(openejb, new Object[0]); + boolean running = ((Boolean)val).booleanValue(); + + if (running) out.print(OK); + } catch (Exception e){ + out.print(FAIL); + } + + // --------------------------------------------------- + // Can I lookup anything? + // --------------------------------------------------- + + printTest("Performing a test lookup"); + + try{ + Object obj = ctx.lookup(""); + + if (obj.getClass().getName().equals("org.openejb.core.ivm.naming.IvmContext")) { + out.print(OK); + } else { + out.print(FAIL); + } + + } catch (Exception e){ + out.print(FAIL); + } + + out.print("
"); + out.print(HR); + try{ + Object obj = ctx.lookup( "client" ); + if (obj instanceof Context) { + out.print("
"+pepperImg+""); + out.print("Continue tests"); + out.print("
"); + } + + } catch (Exception e){} + + } catch (Exception e){ + out.print(FAIL); + out.print(""); + out.print(HR); + + out.print(e.getMessage()); + } + } + + protected void printTest(String test) throws IOException{ + out.print("" ); + out.print(test); + out.print(""); + } + + public String formatThrowable(Throwable err) throws Exception{ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + err.printStackTrace(new PrintStream(baos)); + byte[] bytes = baos.toByteArray(); + StringBuffer sb = new StringBuffer(bytes.length); + for (int i=0; i < bytes.length; i++){ + char c = (char)bytes[i]; + switch (c) { + case ' ': sb.append(" "); break; + case '\n': sb.append("
"); break; + case '\r': break; + default: sb.append(c); + } + } + return sb.toString(); + } +%> + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testint.jsp ------------------------------------------------------------------------------ svn:executable = * Added: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testsuite.jsp URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testsuite.jsp?view=auto&rev=562334 ============================================================================== --- openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testsuite.jsp (added) +++ openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testsuite.jsp Thu Aug 2 22:21:56 2007 @@ -0,0 +1,183 @@ +<%@ 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.*, +org.openejb.test.TestRunner, +org.openejb.test.ResultPrinter, +java.lang.reflect.Method, +java.lang.reflect.InvocationTargetException, +java.lang.reflect.Modifier +"%> + + + + OpenEJB Tomcat Integration/1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OpenEJBIndexJNDIEJBClassInvoke
   + + + + +

+ +
+
+ + OpenEJB Test Suite + +
+
+

+

+ +<% + 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; + + /** + * 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 doInvoke = request.getParameter("invoke"); + if (doInvoke != null) { + invoke(); + } else { + out.print("
"); + out.print(""); + out.print("
"); + } + } + String pepperImg = ""; + public void invoke() throws Exception{ + + try{ + System.setProperty("openejb.test.server","org.openejb.test.IvmTestServer"); + System.setProperty("openejb.test.database","org.openejb.test.InstantDbTestDatabase"); + //test.server.class=org.openejb.test.IvmTestServer + //out.print("B"); + //Object runner = this.getClass().forName("org.openejb.test.TestRunner").newInstance(); + //out.print("C"); + + + //Method main = runner.getClass().getMethod("main",new Class[]{new String[]{}.getClass()}); + + String[] args = new String[]{"org.openejb.test.ClientTestSuite"}; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + org.openejb.test.ResultPrinter printer = new org.openejb.test.ResultPrinter(new PrintStream(baos)); + TestRunner runner = new TestRunner(printer); + + runner.start(args); + byte[] bytes = baos.toByteArray(); + StringBuffer sb = new StringBuffer(bytes.length); + for (int i=0; i < bytes.length; i++){ + char c = (char)bytes[i]; + switch (c) { + case ' ': sb.append(" "); break; + case '\n': sb.append("
"); break; + case '\r': break; + default: sb.append(c); + } + } + out.print(sb.toString()); + + //main.invoke(runner, args); + + + } catch (Throwable e){ + out.print("
Bad Exception:

"); + out.print(formatThrowable(e)); + } + } + + public String formatThrowable(Throwable err) throws Exception{ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + err.printStackTrace(new PrintStream(baos)); + byte[] bytes = baos.toByteArray(); + StringBuffer sb = new StringBuffer(bytes.length); + for (int i=0; i < bytes.length; i++){ + char c = (char)bytes[i]; + switch (c) { + case ' ': sb.append(" "); break; + case '\n': sb.append("
"); break; + case '\r': break; + default: sb.append(c); + } + } + return sb.toString(); + } +%> + Propchange: openejb/trunk/openejb3/server/openejb-webadmin/src/main/webapp/testsuite.jsp ------------------------------------------------------------------------------ svn:executable = *