JSF on Tomcat 6

I tried my hands on JSF last Friday. It didn’t go as smoothly as I expected.

Being the bleeding edge kind of person :P I set it up using Tomcat 6 and a quick start package from Exadel. The package already has all the jar files you need and you only need to type in (orĀ  cut-and-paste) some missing java code and jsp scripts. That done, I tried accessing /jskfs/pages. It didn’t work so I tried accessing directly inputname.jsp:

java.lang.NullPointerException
com.sun.faces.taglib.jsf_core.LoadBundleTag.doStartTag(LoadBundleTag.java:96)

I figured, hey maybe I should try the latest reference implementation. That would also be in keeping up with being a bleeding edge kind of person :P So I went to Sun and downloaded latestĀ  reference implementation mojarra-1.2_09-b02-FCS-binary.zip, installed it to /jskfs/WEB-INF/lib, and again tried accessing inputname.jsp:

javax.servlet.ServletException: java.lang.NoSuchMethodError: com.sun.faces.taglib.jsf_core.LoadBundleTag.setBasename(Ljava/lang/String;)

It got worse. Figuring that the reference implementation is incomplete (don’t ask why). So I went to Apache.org and downloaded MyFaces, their implementation of JSF: myfaces-core-1.2.4-bin.zip. I installed it and tried again:

SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener

I took a look at the web.xml file, found, and commented this out:

<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

I tried again:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sun/faces/taglib/jsf_core/LoadBundleTag

I read somewhere that flushing the web app’s files in the work directory sometimes works so I did and then tried again:

javax.servlet.jsp.JspException: No faces context?!
org.apache.myfaces.taglib.core.LoadBundleTag.doStartTag(LoadBundleTag.java:77)

I tried accessing via the entry point /jskfs/pages. It finally worked.

On a hunch, I went full circle and restored the original jar files, cleared the work directory, and tried accessing via the entry point again. Guess what? It worked 8-}

LDAP and JNDI

Today, instead of just dealing with people and papers, I actually worked on something a bit more interesting. I needed to allow users to change the passwords of their Active Directory accounts using a web page. Being a Java zealot, the solution I chose was JNDI which made things pretty much straightforward.

Of course it wouldn’t have been fun without problems and I encountered two, albeit minor, hitches with LDAP and Active Directory. LDAP is supposedly easy but it never ceases to give me just enough trouble to roundly irritate me. Active Directory only allows modification of passwords via a secure connection, either TLS or SSL. The latter is actually a good thing but I had to do a few extra steps. Besides, like I said, they were minor hitches.

So how to do it?

Continue reading “LDAP and JNDI”