Servlet crashes TOMCAT

I am experimenting with buffered images in a servlet. This "Hello World" servlet crashes TOMCAT.
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
Java HotSpot(TM) Client VM (build 1.4.1, mixed mode)
JAVA_OPTS '-Xmx512m -Djava.awt.headless=true'
----servlet begins----
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import Acme.JPM.Encoders.GifEncoder;
public class MijnPollServlet extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
doPost(req,res);
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
BufferedImage image=
new BufferedImage(100,100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.setColor(Color.blue);
g2.fillRect(25,25,50,50);
g2.drawString("Hello World!", 10, 10);
ServletOutputStream out = res.getOutputStream(); // binary output!
res.setContentType("image/gif");
GifEncoder encoder = new GifEncoder(image, out);
encoder.encode();
----servlet ends----
If I run the servlet with the "g2.drawString("Hello World!", 10, 10);"
commented out there is no problem.
Is there something I am missing here?
Thank you,
-William

The whole Tomcat crashes, and no exception
displayed.
Do I have to write the log file, or it's kept by
Tomcat itself?yes, tomcat writes a log file, you find it in the tomcat dir. but it's just very highlevel. Having a look in it could help.
Is there a way to write a log file by myself?sure. you could get the log file from tomcat by getting it from the ServletContext:
ServletContext = getServletContext();
ServletContext.log("text to log");
When I view the output window in Forte, it doesn't
even write that Tomcat crashed.
I use Tomcat that is installed with the last version
of Forte(Sun 1 Studio, update 1), I guess it's the
last version of Tomcat also.No. The lastest is 4.1.12 and i guess it's 4.0.4 with forte.
Get Tomcat standalone from jakarta.apache.org and try to run your servlet with the standalone tomcat. this could help since i also expirenced problems sometimes with the forte-integrated tomcat.

Similar Messages

  • Native call in Servlet crashing tomcat

    I can execute the class from the unix prompt (invoking the main) and it works fine, however when I invoke it withing a servlet or jsp, i get a core dump.
    It seems to be a treading issue. I am including the tread dump of ONLY the thread that died.
    Any advice on getting this going would be appreciated.
    Derek
    SIGSEGV 11* segmentation violation
    si_signo [11]: SIGSEGV 11* segmentation violation
    si_errno [0]:
    si_code [2]: SEGV_ACCERR [addr: 0x0]
    stackpointer=ba12a2d4
    Full thread dump Classic VM (Caldera-UNIX-J2SE-1.3.0_02:*fixes-OU8*fixes-UW7*FCS-OSR5*:020322-03:47, native threads):
    "Thread-9" (TID:0xbca3aa50, sys_thread_t:0x83e7738, state:R, native ID:0xe) prio=5
    at JavaToCPageInterface.sendMessage(Native Method)
    at doit_3._jspService(doit_3.java, Compiled Code)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java, Compiled Code)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java, Compiled Code)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java, Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java, Compiled Code)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
    at java.lang.Thread.run(Thread.java:484)

    More Info:
    j2sdk 1.3.1
    Tomcat 3
    The program executes fine as a stand-along app, however if it is called from withing a servlet or JSP, Tomcat core dumps.
    Have tried -Xss10m as a parameter, however it does not work. I have also tried both green and native threads.
    Thanks,
    Derek

  • How to run a servlet in tomcat 5.0.

    Hi all,
    how to run a servlet in tomcat 5.0
    please tell me the entire procedure....(directory structure)
    step by step....

    hi :-)
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
    or
    http://www.google.com.ph/search?hl=en&q=java+servlet+tutorial&btnG=Google+Search&meta=
    regards,

  • Servlet on tomcat 4.1.18

    I am facing a problem of running servlets on Tomcat 4.1.18. The problem seems to be in the configuration. In the webapps folder, I created a folder greeting. In that, the WEB-Inf\classes folder has GreetingServlet.class.
    webapp\greeting has index.html that has to FORM ACTION set to /greeting/servlet/GreetingServlet.
    On clicking the submit button the message I get is that the resource /greeting/servlet/GreetingServlet is not found.
    Can anybody help in configuring the server so that the above mentioned servlet gets recognized?
    Thanks.
    Amitabh.
    [email protected]

    My application is located at %TOMCAT_HOME%\webapps.
    %TOMCAT_HOME%\webapps\greeting\WEB-INF\web.xml has the following:
    <web-app>
    <servlet>
    <servlet-name>greeting</servlet-name>
    <servlet-class>GreetingServlet</servlet-class>
    </servlet>
    </web-app>
    %TOMCAT_HOME%\webapps\greeting\index.html has the following:
    <FORM ACTION="/greeting/servlet/GreetingServlet" METHOD="POST">
    <P> Your name <INPUT TYPE="text" SIZE="40" NAME="name"></P>
    </FORM>
    Yet the problem persists.
    Have I missed some point?
    Help/assistance will be appreciated.
    Thanks.
    Amitabh.
    [email protected]

  • Servlets in Tomcat

    I am trying to run servlets using Tomcat. I have them working and displaying but as soon as I make a change to a servelt and re-compile and refresh the browser the change do not take effect. I have to shutdown and restart tocat. Surely this can't be right. can anyone help with correcting this problem?

    Lesta,
    For convenience there's a Tomcat admin console. The admin console runs through a web browser and allows you to restart an application, restart a context ect. I think you can also install or reinstall entire ears through it now.
    There's some setup to do before you can use the admin console. I seem to remember there being an XML user/password file somewhere...
    In a production environment you don't want to shutdown and restart the daemon like you are doing. It will just annoy the heck out of your users.
    Hope this helps.
    -Bryan

  • Need to enable autoreload feature for servlet in Tomcat

    Hello
    I wants to enable autoreload feature for servlet in tomcat so that i need not to stop tomcat 4.0 web server again and again
    Thanks

    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html
    It is amazing what reading the manual might do for ya.

  • How to run Servlet in TOMCAT

    I am new to Java Servlets. I am trying to run a servlet on TOMCAT but I don't know where to place my Servlet class file. TOMCAT works ok with sample jar file. Please guide.
    -- HTML code
    <HTML>
    <HEAD>
    <TITLE> Request Object </TITLE>
    </HEAD>
    <BODY>
    <FORM METHOD="POST" ACTION="/servlet/WelcomeServlet">
    Enter your Name: <INPUT TYPE=TEXT NAME="myName">
    <INPUT TYPE="SUBMIT" VALUE="Send Name">
    </FORM>
    </BODY>
    </HTML>
    -- Servlet Code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class WelcomeServlet extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    String Name = request.getParameter("myName");
    PrintWriter out = response.getWriter();
    String mName = "test";
    try {
    mName = gName("AAA","VVV");
    catch (SQLException ex)
    out.println("SQLException");
    out.println("Welcome 1.1 " + Name + " !" + " mName " + mName);
    public String gName(String inputUserid, String inputPwd)
    throws SQLException{
    String vname = "Test";
    return vname;
    thanks
    Vineet

    I have Tomcat version 4.0 installed on my machine. If you look at the directory where you have Tomcat installed, you should find the directory structure:
    tomcat-folder/webapps/root/web-inf/classes
    Try placing your class files in the classes folder.

  • How to Run servlet in Tomcat 5.5.9

    hi
    How to run servlet in tomcat 5.5.9?how to set context path in server.xml of conf folder in tomcat since there is no context tag in server.xml.
    Jiten

    Hi ! I have a similar problem, well, it's along the same line ...
    I'm using NetBeans 4.1, and i've coded a servlet. Using NetBeans to launch my servlet (with the bundled Tomcat 5.5.7) works fine, however i need to deploy my application unto a Tomcat 5.5.9 server.
    Thus, i copied the WAR file generated by NetBeans into the Tomcat 5.5.9 webapps directory, and Tomcat expands it.
    Problem is when i run my JSP pages with the form tags, they do not work on the Tomcat 5.5.9 environment. Anyone knows why?
    (These work on the NetBeans Tomcat bundle 5.5.7)
    My form action :
    <form name="index" method="get" action="PageServlet">
    My web.xml :
    <servlet>
    <servlet-name>PageServlet</servlet-name>
    <servlet-class>application.PageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>PageServlet</servlet-name>
    <url-pattern>/PageServlet</url-pattern>
    </servlet-mapping>
    I'm really stumbed on why it doesn't work in Tomcat 5.5.9, any help is greatly appreciated, thanks in advance ^_^

  • How to run Servlet in Tomcat 5.5.7 Server

    Hi,
    How to run Servlet in Tomcat 5.5.7 Server. I mean where I should copy my *.class file.
    Thanks in Advance.
    bbye.

    In order to complile the servlet you need to tell java where to find the servlet libary (as stated above by setting the class path). or (much easier IMO)
    copy the servlet-api.jar to
    JavaInstallDirectory\jre\lib\ext

  • Running servlet in tomcat 4.1.18

    Hi,
    I am new to servlet and am having trouble running a simple servlet on tomcat 4.1.18. I keep getting an Error 404 resource not found. will someone show me how to run servlet on tomcat?Please.
    Thanks

    To start, make sure you have specified the servlet and mapping in your application's WEB-INF/web.xml file.
    <!-- for example -->
    <servlet>
        <servlet-name>yourServletName</servlet-name>
        <servlet-class>path.to.Servlet</servlet-class>
    </sevlet>
    <servlet-mapping>
        <servlet-name>yourServletName</servlet-name>
        <url-pattern>/servlet/yourServletName</url-pattern>
    </servlet-mapping>

  • How Can I Run Servlet in tomcat

    Hi My Friends
    Please can any one tell me how can I Run Servlet in tomcat using my own Virtual Directory � my ask about , what is the structure it must be make it in the hierarchy of the sub folder of Virtual Directory , and in watch folder it must be put the servlet files and there is any change it must be make it in any file of the tomcat files and so on
    Please give my full details about this thing
    And thanks

    What version of Tomcat are u using?

  • Run servlet in tomcat 4.1

    Hi ,
    could someone please help me.
    Iam trying to run servlet in tomcat4.1 but in vain.
    please help

    hi
    If you want run a servlet in tomcat4.1,First write one html file,and servlet file.
    finally you need to write web.xml.this file will be placed in web-inf folder.
    You need to write this tags to run a servlet in tomcat 4.1
    <servlet>
    <servlet-name> name of the servlet</servlet-name>
    <servlet-class>class name of the servlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>name of the servlet</servlet-name>
    <url-pattern>/the ref name which u want call servlet</url-pattern>
    <servlet-mapping>
    Here the servlet name sholud be same .
    The url pattern name must match with the action attribute value in html.
    now you place your html file in root folder.
    place your servlet class file in classes folder.
    start ur browser type this http://localhost:8080/htmlfilename.

  • Newbie question about loading servlets on tomcat

    I have what is probably a very basic question about loading simple servlets on to tomcat to test its installation. I have followed instructions from numerous tutorials to the letter but still I can't get it to work.
    I have installed tomcat on win2k in c:\tomcat. I set up the jdk, environment vars (JAVA_HOME, CATALINA_HOME, TOMCAT_HOME) which all point at the correct dirs. I can compile a servlet without errors. I can also place a test jsp and html file into the root directory and they both work fine.
    However, now I am trying a test servlet and no matter what I do it gives me a 404. I have a servlet class file called "HelloServlet.class" which I placed into the %install_dir%\webapps\ROOT\WEB-INF\classes directory. I try to reference it using this url:
    http://localhost/servlet/HelloServlet
    Tomcat is configured to use port 80 and has been restarted after adding the servlet class file. Does anyone have a clue why this is not working for me?
    Many thanks
    Marc

    You have to add in the web.xml file that it is in the WEB-INF dir, the information about your servlet. An example:
    <web-app>
    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/HelloServlet</url-pattern>
    </servlet-mapping>
    </web-app>

  • Getting error 404 when iam running a simple login servlet in tomcat

    hi
    this is my Login.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Login extends HttpServlet
         public void doPost(HttpServletRequest rq, HttpServletResponse rs)
              String username =rq.getParameter("username");
              String password =rq.getParameter("password");
    try{
              rs.setContentType("text/html");
              PrintWriter out=rs.getWriter();
              out.println("<html><body>");
              out.println("thank u, " + username + "you r logged sucessfully");
              out.println("</body></html>");
              out.close();
              }catch(Exception e){
                   e.printStackTrace();
    i have saved in the form ofC:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\classes\Login.class
    where sravan is my folder
    step 2: Login.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>login page</title></head>
    <body>
    <h1> WELCOME TO THE SERVLET HOME PAGE</h1>
    ENTER UR USERNAME AND PASSWORD
    <form action="/sravan/Login" method="Post">
         username<input type="text" name="username" >
         password<input type="password" name="password" >
         <input type="submit" value="submit"></form>
         </body>
    </html>
    i have saved in the form C:\Program Files\apache-tomcat-4.1\webapps\sravan\Login.html
    step3:
    my web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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>
    <display-name>beginning j2ee</display-name>
    <servlet>
    <servlet-name>Login</servlet-name>
    <servlet-class>Login</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>Login</url-pattern>
    </servlet-mapping>
    </web-app>
    i have saved in C:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\web.xml
    step4:
    here is my server.xml
    <Context path="/sravan" docBase="sravan" debug="0" reloadable="true" privileged="true"/>
    saved in C:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\server.xml
    everything is fine....program is compiled ...but when iam running the servlet in tomcat iam getting error 404 Login.html not found....
    so plz kindly help me this my first servlet .....

    There seems not to be any '.html' in your url-pattern
    <url-pattern>Login</url-pattern>- so i presume you should use
    http://yourhost/Logininstead.

  • How to run a servlet in tomcat

    how i can run a servlet in tomcat?

    how i can run a servlet in tomcat?Don't try to do that yet; in your other thread you have shown that your are
    not capable yet of setting up a proper development environment.
    Take my advice, you can't walk or run yet so start with the basics.
    kind regards,
    Jos

Maybe you are looking for

  • Issue with Wacom Intuos3 in Photoshop CS5

    New PC windows 7 home premium,/64 bit...old one was XP/CS2. Using a Wacom  Intuos3. With my old PC/PS, when I tapped the R touch strip, the window in  PS would zoom in 'even' increments - 25, 33, 50, etc. New PC/CS5 increments are  odd #s. I worked w

  • I can't delete photos

    I recently got my dads old phone and he had many old pictures on it. He and I both tried to delete the embarrassing pictures off the phone to no avail. There is no trash can button in the corner of the picture and you can not select them then delete

  • Accessing the photoshop api from flash.. within a photoshop window?

    I should maybe ask this in scripting.. but it's some ways related to the SDK. I dont want to crosspost.. if the feature exist, it's very likely that SDK developpers are aware of this (ps: i havent downloaded the sdk since the beta) I had the opportun

  • IMovie project not displayed

    My video camera was captured in the Event Library, but does not appear in the Project Library for me to send on to a DVD. Any help appreciated.

  • Ipod does not shut off

    my ipod classic, after being removed "unsafely" from the computer, now it is impossible to shut it off. all the other functions seem fine. Please, do you know how to restart or reset it? Thanks!