Solved

Unable to get servlets to run - error from TOMCAT4

Posted on 2006-11-30
42
202 Views
Last Modified: 2010-04-01
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)
0
Comment
Question by:jaxrpc
  • 23
  • 16
  • +1
42 Comments
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
>>"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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
If everything is okay, you may need to enable your /servlet invoker.

http://tomcat.apache.org/faq/misc.html#invoker
0
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Hi,

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

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Can you possibly post the instructions here (if no privacy exposed)?
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
>>"really appreciate your help and fast reply."
:), we are here to help
0
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Ok,

Is there any web.xml in your C:\Tomcat4\webapps\ROOT\WEB-INF\
0
 

Author Comment

by:jaxrpc
Comment Utility
no...there isnt
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
ok, give me a sec
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
>>"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
 

Author Comment

by:jaxrpc
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
nope..there's not such an entry.
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
and restart your Tomcat and try your applet again
0
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
>>"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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
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
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Can you post the entire stack trace (error codes)?
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 

Author Comment

by:jaxrpc
Comment Utility
ok thanks alot!! for your help..

enjoy...your weekends.
0
 

Author Comment

by:jaxrpc
Comment Utility
Anyone else has any ideas on what problem i am facing?

thanks
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
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
 
LVL 27

Assisted Solution

by:rrz
rrz earned 100 total points
Comment Utility
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
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 100 total points
Comment Utility
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
 
LVL 16

Accepted Solution

by:
suprapto45 earned 300 total points
Comment Utility
Just get back to my machine.

Are you still getting error of your servlet?

David
0
 

Author Comment

by:jaxrpc
Comment Utility
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now