Re: jsp - newbie problem: java.lang.NoClassDefFoundError
On 7 Okt., 17:28, Lew <l...@lewscanon.com> wrote:
First of all thanks for your time. I really thought that my posting
was clear but I lately read some of my postings to mysql and php
newsgroups from 10 years ago and the stupidity of those postings lets
me assume that you are right ;) From my open source work for php I
know that it's annoying to solve problems without knowing everything
needed. But now I learned that it's hard to provide everything when
you don't know what's important :)
Java is really new for me and I thought that my mistake was really an
easy one.
There shouldn't be Java scriptlet in the JSP. JSP is a view artifact. You
should POST to a "regular" servlet and have the servlet invoke business logic.
Then, based on the outcome, the servlet does a RequestDispatcher forward()
to a JSP to present the results.
I start from the beginning now. I am planning a serverside application
which acts as webservice and returns the result of a lucene search as
xml.
For _testing_ purposes I took a jsp page and tried to access a class
called Indexer.
Please don't shoot me for the formatting - I am typing this in google
groups as I don't have a nntp server available here.
Inside Test.jsp
<%
Indexer Indexer = new Indexer();
Indexer.startup();
%>
Inside Indexer.java:
import org.apache.lucene.store.*;
public class Indexer extends HttpServlet {
public void startup() throws SQLException {
File indexDir = new File("/tmp");
initIndex(indexDir);
}
private void initIndex(File indexDir) {
try {
System.out.println("Init Index");
Directory dir = FSDirectory.getDirectory(indexDir);
writer = new IndexWriter(dir, simpleAnalyzer(), true);
writer.close();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
That means that either 'Directory' or 'FSDirectory' is not in your class path.
Where do these classes come from?
Directory is org.apache.lucene.store.Directory and FSDirectory is
org.apache.lucene.store.FSDirectory
org.apache.lucene is provided by the Lucene jar file located inside
the lib directory of the webservice.
Looking at the libraries of my Eclipse project I have:
- Apache Tomcat v.5.5
- Ear Libraries
- JRE System Librarie
- Web App Libraries
Which contains the Lucene jar files.
Does this make anything clearer?
I appreciate your help and patience - thank you!
--
Daniel Khan