web analytics
Skip to main content

Problem: Lucene demo Web application does not work

After installing Lucene 3 with Tomcat 6 in Ubuntu Linux, I’ve spent some hours trying to put Lucene’s demo Web application to work. Lucene console demo was working nice, but when I tried to run any query in the demo Web application, it returned this error:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.lucene.store.FSDirector

(Note: The demo Web application home page worked fine. The problem ocurred when I tried to run a query).

This was very strange, because everything seemed to be correct, I had followed all the instructions found in the “Apache Lucene – Building and Installing the Basic Demo” document.

I googled it in many forums, but I found no trace of a decent answer that was fit to my problem.

It seemed that the problem was somehow related to some security configuration, maybe file permissions, because sometimes I also got this message in the log:

java.security.AccessControlException: access denied (java.util.PropertyPermission sun.arch.data.model read)

But even after giving all possible permissions to the Tomcat user in the directory where my Lucene index was, it did not work. I kept receiving the same messages.

Finally, after hours struggling, looking at the tomcat6 initialization script (located in /etc/init.d), I noticed that there was this option:

# Use the Java security manager? (yes/no)
TOMCAT6_SECURITY=yes

Well, why not give a try? Let’s change this to “no”:

TOMCAT6_SECURITY=no

Now let’s test it: restart Tomcat6… Run a query… BINGO! It worked!!!

Why is this? I didn’t have time to investigate, but it seems that it’s a Tomcat 6 security directive that forces applications to adhere to some security scheme. Obviously, that wasn’t the case with Lucene demo Web application.  :)

After making some more googling, I’ve found that this bizarre problem affects a lot of other programs, and sometimes even database connections started from Tomcat do not work when this option is on.

In fact, there’s a whole bunch of forum discussions and applications’ installation pages telling people to disable this directive in order to work. But nobody gives a clue about the reason behind this…

Anyway, at least we have the solution.