I have a problem with loading classes from Servlet using JServ.
What  I'm trying to do is to instantiate a class based upon the servlet
initialization parameters in a servlet init() method, something like this:

  public void init(ServletConfig config) throws ServletException{
    super.init(config);
    String dbname = getInitParameter("dbtype");
    this.component = new DataCraftServer(dbname);
    .....
  }

There are 2 problems with that:

1. With the servlet init parameters given in datacraft.properties file
(datacraft is the name of servlet zone),
    the system doesn't open the URL.   It times out.
    The way I specified initArgs in datacraft.properties is as follows:

servlet.DataCraftServlet.initArgs=\
 name=DataCraftServlet,\
 dbtype=db2,\
 dbname=flights,\
 demo=demo

  I tried both alias and full class name for initArgs specification.  Both
of them fails.


2. Due to the problem of 1, I modified the init() code so that it doesn't
read the parameter:

  public void init(ServletConfig config) throws ServletException{
    super.init(config);                   // line # 89
    this.component = new DataCraftServer("flights");
    .....
  }

  The problem with this case is ClassLoader doesn't seem to find the class
that I'm instantiating.
    With the class instantiation, I receive "500 Internal Server Error".
    The error message in jserv.log file is as follows:

[05/05/1999 12:39:11:330 PDT] Connection from
datacraft.almaden.ibm.com/9.1.10.21
[05/05/1999 12:39:11:330 PDT] Initializing servlet request
[05/05/1999 12:39:11:330 PDT] Reading request data
[05/05/1999 12:39:11:470 PDT] Parsing cookies
[05/05/1999 12:39:11:500 PDT] DataCraftServlet: init
[05/05/1999 12:39:11:540 PDT] Sending response headers.
[05/05/1999 12:39:11:540 PDT] java.lang.ClassNotFoundException
 at java.lang.Throwable.<init>(Compiled Code)
 at org.apache.java.lang.AdaptiveClassLoader.loadClass(Compiled Code)
 at java.lang.ClassLoader.loadClassInternal(Compiled Code)
 at DataCraftServlet.init(DataCraftServlet.java:89)
 at org.apache.jserv.JServServletManager.load_init(Compiled Code)
 at org.apache.jserv.JServServletManager.loadServlet(Compiled Code)
 at org.apache.jserv.JServConnection.run(Compiled Code)
 at java.lang.Thread.run(Compiled Code)

  Though the exceptio occur at  super.init() at line 89, actually that's not
a problem.
   Without the class instantiation at line 90, the init() method doesn't
have any problem and it performs doGet() method gracefully.
   BTW, the class file to be instantiated, DataCraftServer(), is in the same
directory as the servlet that I'm invoking.

 Could anyone tell me what's problem with the way I instantiate another
class inside of servlet ?
 And please let me know what's the right way of providing initArgs.
 BTW,  the same code works fine with ServletRunner from SUN.


My jserv environment is as follows:
- Apache version : 1.3.6
- JServ version : 1.0.b3
- OS : NT 4.0 (Service Pack 4)
- My configuration files :
  ----------------------------- jserv.properties -------------------------
zones=root,datacraft
root.properties=C:\Program Files\Apache Group\Apache
JServ\conf\zone.properties
datacraft.properties=C:\Program Files\Apache Group\Apache
JServ\conf\datacraft.properties

--------------------------------
datacraft.properties -----------------------
repositories=c:\development\datacraft\java\com\ibm\datacraft\server
servlet.DataCraftServlet.initArgs=\
 name=DataCraftServlet,\
 dbtype=db2,\
 dbname=flights,\
 demo=demo


Thank you very much for your help in advance.

Jeonghee





----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to