Hi, 

I am having trouble with the sample Hypersonic Servlet - something which
should be more or less straight forward I think. I have the servlet in
the .\servlets dir and the hSQL classes in a .\servlets\hSql dir [if I
have them anywhere else, the hsqlServlet constructor fails with a
hDatabase "class not found". 

So far so good. Except that the servlet fails with a
java.lang.NoSuchMethod error.

Thinking I had a method signature problem of some sort, I unzipped the
Orion.jar into a \class dir, and recompiled hsqlServlet which gave me a
slightly smaller .class file - some hope - which unfortunately gives the
same method not found. I had hoped for a compiler error to identify the
problem, but I am now at a loss.

Any help appreciated,

CIA

Neville Burnell
Business Manager Software

PS: NT + JDK1.3 + Orion 0.8.1

========================================================================
=====
site.log
========================================================================
=====
17/12/99 17:05 Started
17/12/99 17:05 com.evermind.servlet.XSLServlet: init
17/12/99 17:05 hsqlServlet: init
17/12/99 17:05 Servlet error
java.lang.NoSuchMethodError
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:189)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:297)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:324)
        at cq.i5(JAX)
        at cq.forward(JAX)
        at c_.k2(JAX)
        at c.run(JAX)

========================================================================
=====
access.log
========================================================================
=====
192.168.0.9 - - [17/Dec/1999:17:05:43 +1000] "GET /servlet/hsqlServlet
HTTP/1.1" 500 458

========================================================================
=====
hsqlServlet.java
========================================================================
=====
/*
 * Servlet.java
 */

import hSql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class hsqlServlet extends HttpServlet {
  hDatabase dDatabase;
  public hsqlServlet() {
    try {
        String n = ".";
      dDatabase=new hDatabase(n);
    } catch(Exception e) {
    }
  }
  static long lModified=0;
  protected long getLastModified (HttpServletRequest req) {
    // this is made so that the cache of the webserver is not used
    // maybe there is some other way
    return lModified++;
  }
  public void doGet(HttpServletRequest request,HttpServletResponse
response)
  throws IOException, ServletException {
    String query=request.getQueryString();
    if(query=="" || query==null) {
      response.setContentType("text/html");
      PrintWriter out=response.getWriter();
      out.println("<html><head><title>Hypersonic SQL Servlet</title>");
      out.println("</head><body><h1>The servlet is running.</h1>");
      if(dDatabase!=null) {
        out.println("<h1>The database is also running.</h1>");
      } else {
        out.println("<h1>The database is not running!</h1>");
      }
      out.println("</body></html>");
    } else {
      processQuery(response,hConnectionHTTP.decodeURL(query));
    }
  }
  public void processQuery(HttpServletResponse response,String query)
  throws IOException, ServletException {
    System.out.println("hSql: "+query);
    response.setContentType("application/octet-stream");
    ServletOutputStream out=response.getOutputStream();
    byte result[]=dDatabase.getResult(query);
    response.setContentLength(result.length);
    out.write(result);
    out.flush();
    out.close();
  }
  public void doPost(HttpServletRequest request,HttpServletResponse
response)
  throws IOException, ServletException {
    ServletInputStream input=request.getInputStream();
    StringBuffer s=new StringBuffer();
    try {
      int b;
      int len=Integer.MAX_VALUE;
      while(len-->0) {
        b=input.read();
        if(b==0) {
          break;
        }
        s.append((char)b);
      }
    } catch(Exception e) {}
    String q=hConnectionHTTP.decodeURL(s.toString());
    if(q.startsWith("HypersonicSQL=")) {
      q=q.substring(14); // skip 'HypersonicSQL='
      processQuery(response,q);
    } else {
      doGet(request,response);
    }
  }
}

Reply via email to