Link to home
Start Free TrialLog in
Avatar of jaxrpc
jaxrpc

asked on

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)
Avatar of suprapto45
suprapto45
Flag of Singapore image

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?
Avatar of jaxrpc
jaxrpc

ASKER

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.

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?
>>"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?
If everything is okay, you may need to enable your /servlet invoker.

http://tomcat.apache.org/faq/misc.html#invoker
Avatar of jaxrpc

ASKER

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
Hi,

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

ASKER

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.
Can you possibly post the instructions here (if no privacy exposed)?
>>"really appreciate your help and fast reply."
:), we are here to help
Avatar of jaxrpc

ASKER

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
Ok,

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

ASKER

no...there isnt
ok, give me a sec
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?
Avatar of jaxrpc

ASKER

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.
Avatar of jaxrpc

ASKER

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?
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>
>>"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).
Avatar of jaxrpc

ASKER

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...
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>
Avatar of jaxrpc

ASKER

nope..there's not such an entry.
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
and restart your Tomcat and try your applet again
Avatar of jaxrpc

ASKER

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!!..
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>
Avatar of jaxrpc

ASKER

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;
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
Avatar of jaxrpc

ASKER

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)
>>"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 :(.
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
Avatar of jaxrpc

ASKER

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...
Can you post the entire stack trace (error codes)?
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?
Avatar of jaxrpc

ASKER

ok thanks alot!! for your help..

enjoy...your weekends.
Avatar of jaxrpc

ASKER

Anyone else has any ideas on what problem i am facing?

thanks
SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jaxrpc

ASKER

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