Results 1 to 8 of 8

Thread: Debugging Zimlet JSP

  1. #1
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default Debugging Zimlet JSP

    Hi...

    Does anyone know how to debug Zimlet JSP? I've written some but it's not doing what it is supposed to, and I don't get any errors in the WebUI, or in any logfiles that I can see.

    I've tried using '?dev=1' and ?debug=1' in the URL but neither of those are telling me if there are errors with my JSP.

    Help...

    Thanks,
    Matt

  2. #2
    Join Date
    Mar 2006
    Posts
    300
    Rep Power
    9

    Default

    Quote Originally Posted by Chewie71 View Post
    Hi...

    Does anyone know how to debug Zimlet JSP? I've written some but it's not doing what it is supposed to, and I don't get any errors in the WebUI, or in any logfiles that I can see.

    I've tried using '?dev=1' and ?debug=1' in the URL but neither of those are telling me if there are errors with my JSP.

    Help...

    Thanks,
    Matt
    You can also use your browsers error log. Firefox it is Tools>Error Console.
    Many times though there seems to be nothing to go on. Might have to increase verbosity or turn debugging on in Jetty.

  3. #3
    Join Date
    Mar 2006
    Posts
    300
    Rep Power
    9

    Default Look here

    Chewie, you might also want to look at this thread:

    http://www.zimbra.com/forums/zimbra-...-academia.html

    There is some source code attached in there that is a good reference to look at in how to construct the ZImlet with XML, CSS and JS files, which gives you much more visual
    control.

  4. #4
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default

    OK....nothing shows up in Firefox (Tools/Error Console). I also tried Firebug and did not see anything there. I'm posting my code below, and I know I'm getting an error because I'm seeing the "Caught Error: " in my output window, which is in the catch section of the try block. It doesn't tell me what the problem was though. Also the LDAP server logs do not show any binds....so I haven't even gotten to the point where I successfully connect yet.

    I get the following in my output window.

    Hello BEGIN
    (DN of the auth user)
    Caught Error:
    Hello END

    Code:
    PrintWriter output = response.getWriter();
      output.println("Hello BEGIN\n\n");
      output.println(dn);
    
      Properties env = new Properties();
      
      env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.LdapCtxFactory" );
      env.put("java.naming.ldap.version", "3");
      env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName + "/");
      env.put( Context.SECURITY_AUTHENTICATION, "simple");
      env.put( Context.SECURITY_PRINCIPAL, dn );
      env.put( Context.SECURITY_CREDENTIALS, pass);
    
    
      try {
    	//Create the initial directory context
    	DirContext ctx = new InitialDirContext( env );
    	//Ask for all attributes of the object
    	Attributes attrs = ctx.getAttributes("uid=username, ou=people");
    	//Find the surname attribute ("sn") and print it
    	//System.out.println(mySn);
    	response.setContentType("text/html");  
    	output.println("Hello MIDDLE");
    	output.println("sn: "+ attrs.get("sn").get());
    	}
      catch (NamingException e){
    	//Authentication Failed
    	output.println("Caught Error: ");
    	}
    
    	output.println("Hello END");

  5. #5
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default

    OK....I dropped the following in my catch block and got the error to print for me....it would be nice if there was a log somewhere this JSP stuff was going to.

    Code:
    output.println(e)

  6. #6
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default

    Code:
    javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.LdapCtxFactory]
    That is the error....so I'm not importing the right stuff? Here are my imports...

    Code:
    <%@ page language="java" import="com.sun.jndi.ldap.*, java.io.*, java.util.*, javax.naming.*, javax.naming.dir
    ectory.*"%>
    <%@ page import="com.zimbra.cs.account.Account" %>

  7. #7
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default

    OK....so I think the problem is this line...
    Code:
    env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.LdapCtxFactory" );
    ...it should be this...
    Code:
    env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory" );

    So I've changed it, but I still get the exact same error...
    Code:
    javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.LdapCtxFactory]
    So it hasn't picked up the change? I've done a 'zmmailboxdctl restart' and a 'zmcontrol stop/start'....but the error still exists even though I've fixed it in the code.

    Is Jetty caching this somewhere?

    Matt

  8. #8
    Join Date
    Sep 2006
    Location
    Illinois
    Posts
    374
    Rep Power
    9

    Default

    What a pain....but at least I'm learning something....I found the JSP cached in...
    /opt/zimbra/jetty/work/service/jsp/org/apache/jsp/zimlet/_005fdev/ZIMLETNAME.

    I deleted the .jsp and .class files from in there, did a 'zmmailboxdctl restart', and now it works...almost. It queried my LDAP directory (WOOT!!)....but my LDAP filter isn't correct yet so I didn't get any results. Back to the drawing board...

    Matt

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 09:06 AM
  2. Outlook 2007 Beta error
    By bersrker in forum Zimbra Connector for Outlook
    Replies: 13
    Last Post: 07-17-2008, 07:38 AM
  3. [SOLVED] Install Problem in Ubuntu 6.06 Server
    By xtimox in forum Installation
    Replies: 16
    Last Post: 03-27-2008, 09:36 AM
  4. Replies: 5
    Last Post: 01-11-2008, 04:34 AM
  5. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 10:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •