Unable to get servlets to run - error from TOMCAT4

Hi,

I have some problems running my servlets in tomcat4. Here's the error generated from TOMCAT. Sorry i have not used tomcat or jsp/servlets too frequent and not very familiar with it. Please help me have a look what does the error means.

thanks

2006-12-01 10:56:10 invoker: Cannot allocate servlet instance for path /servlet/DT_2DBServlet
javax.servlet.ServletException: Servlet.init() for servlet org.apache.catalina.INVOKER.DT_2DBServlet threw exception
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:871)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
      at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:396)
      at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
jaxrpcAsked:
Who is Participating?
 
suprapto45Connect With a Mentor Commented:
Just get back to my machine.

Are you still getting error of your servlet?

David
0
 
suprapto45Commented:
Hi,

It means that your Servlet is not available. Have you added the entries in your web.xml? If so, can you post your web.xml?
0
 
jaxrpcAuthor Commented:
sorry, but where can i find web.xml...can't seems to find it because i am following the installation manual provided by the software maker 4years ago.

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
suprapto45Commented:
No problem.

Now, do you know where Tomcat is installed? Normaly, it would be like C:/tomcat4. Let's call it TOMCAT_HOME.

If you have found it, do you find the folder called "webapps" in <TOMCAT_HOME>/webapps. The web.xml is located in <TOMCAT_HOME>/webapps/<YOUR WEB APP NAME>/WEB-INF/web.xml

Can you find it?
0
 
suprapto45Commented:
>>"i am following the installation manual provided by the software maker 4years ago."
So it is an existing system. Are you trying to enhance the existing system?
0
 
suprapto45Commented:
If everything is okay, you may need to enable your /servlet invoker.

http://tomcat.apache.org/faq/misc.html#invoker
0
 
jaxrpcAuthor Commented:
yup, there's no web.xml in myWebApp/Web-INF

actually i am trying to reinstall an existing system. Anyway how do i go about create a web.xml?

i have DT_2DBServlet.class in the web-inf and HDBIDSServlet.class in the web-inf.
where do i create or insert the servlet tags into the web.xml?

thanks
0
 
suprapto45Commented:
Hi,

>>"actually i am trying to reinstall an existing system"
Well, do they provide you with any WAR file?
0
 
jaxrpcAuthor Commented:
hi,

really appreciate your help and fast reply.

Nope. Just an instruction manaul which instructs me to copy and paste the whole TOMCAT4 folder into C:\ and set a few system variables and stuffs.
0
 
suprapto45Commented:
Can you possibly post the instructions here (if no privacy exposed)?
0
 
suprapto45Commented:
>>"really appreciate your help and fast reply."
:), we are here to help
0
 
jaxrpcAuthor Commented:
Under tomcat i have the following files.

C:\Tomcat4\webapps\ROOT\WEB-INF\classes

DT_2.class
DT_2DataAccessor.class
DT_2DBServlet.class
HDBIDSServlet.class
HDBIDSDataAccessor.class
HDBIDSDBServlet.class

HDBIDS.java
HDBIDSDataAccessor.java
HDBIDSDBServlet.java

and another program written in VB6 which will call a java applet which communicates with the servlet.

So far i have got the web server running and i am able to call the java applet but it won't communicate with the servlet which might be the problem you suspected.

anyway the manual is just pure copy & paste TOMCAT4 folder to C:\ and everything will work...according to the manual.

thanks
0
 
suprapto45Commented:
Ok,

Is there any web.xml in your C:\Tomcat4\webapps\ROOT\WEB-INF\
0
 
jaxrpcAuthor Commented:
no...there isnt
0
 
suprapto45Commented:
ok, give me a sec
0
 
suprapto45Commented:
Assuming that your Tomcat's port is 8080.

What happen if you execute http://localhost:8080. Is there any Tomcat page displayed? Additionally, when you run your Tomcat, is there any error in the Tomcat's console?
0
 
jaxrpcAuthor Commented:
The root directory for the tomcat appear. There's no error in the catalina when i started it. infact each time i launch the applet...there will be some messages from the program.
0
 
jaxrpcAuthor Commented:
i have checked the web.xml in the conf folder but i dont see any servlet tags belonging to my servlets.

Do i need a web.xml for the servlets?
0
 
suprapto45Commented:
Try to go to your <TOMCAT_HOME>/conf/web.xml and enable the invoker by changing

 <!--
    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
  -->

into

    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
0
 
suprapto45Commented:
>>"Do i need a web.xml for the servlets?"
If you follow the normal and recommended ways to deploy web app in J2EE in Tomcat, YES, each web app will have its own web.xml.

Now, what you used is to deploy the application in the ROOT folder of Tomcat which is actually not recommended (though can run). If you run this in Production environment, you are actually opening the security hole of the Tomcat to your user (although I am not sure how but it is not recommended).
0
 
jaxrpcAuthor Commented:
hi,

it is already

 <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>

but...still not working... any other ideas?

thanks...
0
 
suprapto45Commented:
Okay,

Just curious, is there any entry for DT_2DBServlet in your <TOMCAT_HOME>/conf/web.xml such as

<servlet>
<servlet-name>DT_2DBServlet</servlet-name>
0
 
jaxrpcAuthor Commented:
nope..there's not such an entry.
0
 
suprapto45Commented:
Try to add that then.

Add below codes after your last </servlet> entry.

<servlet>
<servlet-name>DT_2DBServlet</servlet-name>
<servlet-class>YOUHAVETOPROVIDETHIS.DT_2DBServlet</servlet-class>
</servlet>

Then add

    <servlet-mapping>
        <servlet-name>DT_2DBServlet</servlet-name>
        <url-pattern>/servlet/DT_2DBServlet</url-pattern>
    </servlet-mapping>

after your last </servlet-mapping> entry
0
 
suprapto45Commented:
and restart your Tomcat and try your applet again
0
 
jaxrpcAuthor Commented:
hi,

now i have another error from the log. unable to find the DT_2DBServlet class

the DT_2DBServlet is physically located in the root/web-inf/classes

so do i write the full path? or just the class name is enough?

thanks alot!!..
0
 
suprapto45Commented:
Hi,

>>"<servlet>
<servlet-name>DT_2DBServlet</servlet-name>
<servlet-class>YOUHAVETOPROVIDETHIS.DT_2DBServlet</servlet-class>
</servlet>"

YOUHAVETOPROVIDETHIS is actually the package of your class. You can find this on your DT_2DBServlet.java

DT_2DBServlet.java
-----------------------

package xx.xx.xx;

If that is the case then
<servlet>
<servlet-name>DT_2DBServlet</servlet-name>
<servlet-class>xx.xx.xx.DT_2DBServlet</servlet-class>
</servlet>
0
 
jaxrpcAuthor Commented:
hi,

really sorry....but i dont know how to read java code. ... still can't figure out which is the package.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import DT_2;
import DT_2DataAccessor;


public class DT_2DBServlet extends HttpServlet implements SingleThreadModel
{

    private DT_2DataAccessor myDataAccessor;
      private String CR = "\n";
      private boolean booShowVideo=false;
      String strReqDTName = null;
      String strIPAddress = null;
      boolean booUseDTName = false;
0
 
suprapto45Commented:
Any other codes before import java.io.*; ?

If not,
<servlet>
<servlet-name>DT_2DBServlet</servlet-name>
<servlet-class>DT_2DBServlet</servlet-class>
</servlet>

should be okay
0
 
jaxrpcAuthor Commented:
no other codes.

yup..this is the error i got

2006-12-01 15:37:54 StandardWrapper[:DT_2DBServlet]: Marking servlet DT_2DBServlet as unavailable
2006-12-01 15:37:54 StandardWrapperValve[DT_2DBServlet]: Allocate exception for servlet DT_2DBServlet
javax.servlet.ServletException: Wrapper cannot find servlet class DT_2DBSerlet or a class it depends on
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:807)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
0
 
suprapto45Commented:
>>"Wrapper cannot find servlet class DT_2DBSerlet or a class it depends on"
I am afraid that you have to provide all the necessary classes which would be hard if you do not know what are the files involved and only your original coders know it :(.
0
 
suprapto45Commented:
Worth to try though. If you know what are the servlets? Try to add all of them to your web.xml

DT_2.class
DT_2DataAccessor.class
DT_2DBServlet.class
HDBIDSServlet.class
HDBIDSDataAccessor.class
HDBIDSDBServlet.class
0
 
jaxrpcAuthor Commented:
i found out... i mis-spelled the servletname but after i corrected it... i got back the same error as in the 1st post....

heh...
0
 
suprapto45Commented:
Can you post the entire stack trace (error codes)?
0
 
suprapto45Commented:
Oh yes,

I will be leaving in 30 mins time and will only be back by Monday. Just in case that your problem is not solved at that time, I hope that other experts may pop in during weekend and help you.

One more thing. Is this working previously? If so, what is the URL that you used before to run this?
0
 
jaxrpcAuthor Commented:
ok thanks alot!! for your help..

enjoy...your weekends.
0
 
jaxrpcAuthor Commented:
Anyone else has any ideas on what problem i am facing?

thanks
0
 
suprapto45Commented:
Hi,

http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_22079287.html

I have asked some pointer question so everyone can help you.

David
0
 
rrzConnect With a Mentor Commented:
I don't know if I can fill David's shoes, but I'll give it go. First let's try without using invoker.  Change the file  C:\Tomcat4/conf/web.xml   back to what it was originally.  Next use the following to create a file .
---------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>

<!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
   <servlet>
      <servlet-name>yourServlet</servlet-name>
      <servlet-class>DT_2DBServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>  

   <servlet-mapping>
      <servlet-name>yourServlet</servlet-name>
      <url-pattern>/Dt2db</url-pattern>
   </servlet-mapping>  
</web-app>
-----------------------------------------------------------------------------------------------------
it should be located at  C:\Tomcat4\webapps\ROOT\WEB-INF\web.xml  
Restart Tomcat and  try to access with   http://localhost:8080/Dt2db 
Show us any  error message.
0
 
rama_krishna580Connect With a Mentor Commented:
Hi,

The problem was a bug in version 4.1.27 of tomcat so anyone having this problem go to http://www.apache.org/dist/jakarta/tomcat-4/binaries/ and download hotfix 22096 extract it and copy the directory org to tomcat_install_dir\server\classes directory and restart tomcat.

R.K
0
 
jaxrpcAuthor Commented:
sorry. actually the servlet works another PC. it seems that the problem could be with the last PC that i worked with though i am not sure what it is.. i will split the points evenly to everyone who tried to help. Thanks for the time and effort.

Moderator - Please close this question for me. thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.