Hi
I have a big problem.
I got t expain to u in detail.I have installed
tomcat 5.0.19 in windows xp.
I have set the classpath as follows:
C:\Documents and Settings\madhan\My Documents\servlets
C:\Tomcat\jakarta-tomcat-5.0.19\common\lib\servlet-api.jar
C:\Tomcat\jakarta-tomcat-5.0.19\common\lib\jsp-api.jar
catalina_home=c:\tomcat\jakarta-tomcat
path = c:\j2sdk1.4.2_04\bin;c:\tomcat\jakarta-tomcat\bin;%path%
Java_home=c:\j2sdk1.4.2_04
Iam able to run a simple
servlet in "http://localhost:8080/servlet/Hello"
I have used "bridge2java" software to convert a
Visual Basic dll(trimSDK.dll) to a
java dll
(bridge2java.dll)which contains the converted
java classes(COM objects).
Now i have these java classes(COM objects)
in c:\IBM\bridge2java
I can run a code using some classes
from it in c:\IBM\bridge2java
and it works fine.
c:\IBM\bridge2java\javac trim.java
c:\IBM\bridge2java\java trim
But when i include it in servlet it doesnt
run and i get an error like this:
Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot allocate servlet instance for path /servlet/trim
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:435)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: trimIBM/IDatabase
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:416)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
The code i used is:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.swing.*;
import trimIBM.*;
/** Simple servlet used to
test server.
* <P>
* Taken from Core Servlets and JavaServer Pages 2nd Edition
* from Prentice Hall and Sun Microsystems Press,
*
http://www.coreservlets.com/. * © 2003 Marty Hall; may be freely used or adapted.
*/
public class trim extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
com.ibm.bridge2java.OleEnvironment.Initialize();
IDatabase d = (IDatabase) new Database();
d.set_Id("11");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>"+d.get_Name()+"</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>"+d.get_Name()+"</H1>\n" +
"</BODY></HTML>");
}
}
please do reply me with the solution of how to
use COM objects in tom cat servlet...
Regards
Madhan