Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-2008, 10:11 AM
Trained Alumni
 
Posts: 342
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
Reply With Quote
  #2 (permalink)  
Old 11-26-2008, 10:25 AM
tgx tgx is offline
Elite Member
 
Posts: 291
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.
Reply With Quote
  #3 (permalink)  
Old 11-26-2008, 11:25 AM
tgx tgx is offline
Elite Member
 
Posts: 291
Default Look here

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

Zimlets in Academia

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.
Reply With Quote
  #4 (permalink)  
Old 11-26-2008, 11:36 AM
Trained Alumni
 
Posts: 342
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");
Reply With Quote
  #5 (permalink)  
Old 11-26-2008, 11:42 AM
Trained Alumni
 
Posts: 342
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)
Reply With Quote
  #6 (permalink)  
Old 11-26-2008, 11:47 AM
Trained Alumni
 
Posts: 342
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" %>
Reply With Quote
  #7 (permalink)  
Old 11-26-2008, 12:08 PM
Trained Alumni
 
Posts: 342
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
Reply With Quote
  #8 (permalink)  
Old 11-26-2008, 12:21 PM
Trained Alumni
 
Posts: 342
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.