tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 8630] New: - TomCat crashes and server shutdown automatically, when error occurs
Date Mon, 29 Apr 2002 19:52:33 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8630>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8630

TomCat crashes and server shutdown automatically, when error occurs

           Summary: TomCat crashes and server shutdown automatically, when
                    error occurs
           Product: Tomcat 4
           Version: 4.0 Release Candidate 2
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Servlet & JSP API
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: cuongbavo@yahoo.com


I don't know if this is a TomCat or ODBC driver problem, but basically I am 
trying to update the MS Access database; and within 3 trials, the server 
crashes.  In other words, the crash point varies; but reproducable. If it 
doesn't crashes, then the database is updated correctly.

here is the update database code:
---------------------------------
/*
**  ProcCheckout.java
**
*/

import java.io.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.net.*;
import java.util.*;

public class ProcCheckout extends HttpServlet
{
  public static final int MAXCART = 20;
  public static final double SHIPPINGRATE = 5.99;
  public static final double DISCOUNTRATE = 0.10;

  private ShoppingCart[] myCart;
  private Integer numItem;
  private ServletConfig config;
  private Connection theConnection;
  private Statement theStatement;
  private ResultSet theResult;
  private String LastName, FirstName, Street, City, State, ZipCode, Phone, 
Email,
                 sLastName, sFirstName, sStreet, sCity, sState, sZipCode,
		 CardNum, CardType, ExpireDate, strError, orderid, password;

/*******************************************************************************
***/
public void init(ServletConfig config) throws ServletException
{
  try
  {	
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    theConnection = DriverManager.getConnection("jdbc:odbc:Sale", "admin", ""); 
    theStatement = theConnection.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,
                                                        
ResultSet.CONCUR_UPDATABLE);
  }catch(Exception e){
    //out.println(e.getMessage());
  }
}

/*******************************************************************************
***/
public void doGet (HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException 
{
  HttpSession session = req.getSession(true);
  PrintWriter out = res.getWriter();
  String Receipt = "";
  res.setContentType("text/html");

  if (! getBilling(req))    //not valid billing information
  {
    out.println("<html><head><title>Billing Information 
Error</title></head></body>");
    out.println(strError);
    out.println("</body></head>");
    return;
  }

  myCart  = (ShoppingCart[]) session.getAttribute("ShoppingCart");
  numItem = (Integer) session.getAttribute("NumItem");

  if ((numItem == null) || (myCart == null) || (myCart[0] == null))
  {
    out.println("<html><head><title>Invalid Transaction 
Checkout</title></head></body>");
    out.println("<font color=\"red\">Sorry, your Shopping Cart is empty. Please 
continue"
              + " your shopping.</font>");
    out.println("</body></head>");
    return;
  }
    
  Date transDate = new Date();
  orderid  = Phone + transDate.toString();
  password = CardNum;

  Receipt = "<b>Customer:</b> " + FirstName + " " + LastName 
+ "<br><b>Phone:</b> " + Phone
          + "<br><b>Email:</b> " + Email 
+ "<br><b><u>Address:</u></b><br>&nbsp;&nbsp;&nbsp;&nbsp;"

          + Street + "<br>&nbsp;&nbsp;&nbsp;&nbsp;"
          + City + ", " + State + " " + ZipCode + "\n<br><br><b>Ship 
To:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;"
          + sFirstName + " " + sLastName + "<br>&nbsp;&nbsp;&nbsp;&nbsp;"
+ 
sStreet + "<br>&nbsp;&nbsp;&nbsp;&nbsp;"
          + sCity + ", " + sState + " " + sZipCode + "\n"
          + "<br><br><hr width=\"90%\">"
          + "<table align=\"center\" width=\"90%\">"
          + "<tr>" 
          + "<th bgcolor=\"#0000FF\" align=\"left\">Items Bought</th>"
          + "<th bgcolor=\"#0000FF\" align=\"center\">Qty</th>"
          + "<th bgcolor=\"#0000FF\" align=\"right\">Unit Price</th>"
          + "<th bgcolor=\"#0000FF\" align=\"right\">Cost</th>" 
          + "</tr>\n";

  double cost = 0.0,
         subtotal = 0.0,
         discount = 0.0,
         shipping = 0.0;

  for (int x = 0;x < numItem.intValue();x++)
  {
    cost = myCart[x].getPrice() * myCart[x].getQty();
    subtotal = subtotal + cost;
    shipping = shipping + SHIPPINGRATE * myCart[x].getQty();

    if (myCart[x].getQty() > 1)  //give 10% off each additional item for qty > 1
      discount = discount + (myCart[x].getQty() - 1) * myCart[x].getPrice() * 
DISCOUNTRATE;

    Receipt = Receipt + "<tr>"
            + "<td>" + myCart[x].getProdName() + "</td>" 
            + "<td align=\"center\">" + myCart[x].getQty() + "</td>"
            + "<td align=\"right\">" + curFormat(myCart[x].getPrice()) 
+ "</td>" 
            + "<td align=\"right\">" + curFormat(cost) + "</td>"
            + "</tr>\n";
  }
    
  Receipt = Receipt + "<tr><td colspan=\"2\"></td><td colspan=\"2\"><hr

width=\"100%\"></td></tr>\n"
          + "<tr><td colspan=\"2\"></td><td><b>SubTotal:</b></td><td

align=\"right\">" + curFormat(subtotal) + "</td></tr>\n"
          + "<tr><td colspan=\"2\"></td><td><b>Discount:</b></td><td

align=\"right\"> - " + curFormat(discount) + "</td></tr>\n"
          + "<tr><td colspan=\"2\"></td><td><b>Shipping:</b></td><td

align=\"right\"> + " + curFormat(shipping) + "</td></tr>\n"
          + "<tr><td colspan=\"2\"></td><td colspan=\"2\"><hr width=\"100%
\"></td></tr>\n"
          + "<tr><td colspan=\"2\"></td><td><b>TOTAL:</b></td><td

align=\"right\">" + curFormat(subtotal - discount + shipping) 
          + "</td></tr>\n"
          + "<TR><TD width=\"100%\" colspan=\"4\">"
          + "<font size=\"0.5\" color=\"red\">Discount: 10% off each additional 
quantity per item.<br>"
          + "Shipping: $5.99/Qty per item.</font>"
          + "</TD></TR></table><hr width=\"100%\">";

  try
  {
    theResult = theStatement.executeQuery("select * from SALEORDER");
    theResult.moveToInsertRow();
    theResult.updateString(1, orderid);
    theResult.updateString(2, password);
    theResult.updateString(3, FirstName);
    theResult.updateString(4, LastName);
    theResult.updateBoolean(5, false);
    theResult.updateString(6, transDate.toString());
    theResult.updateString(7, CardNum);
    theResult.updateString(8, CardType);
    theResult.updateString(9, ExpireDate);
    theResult.updateString(10, Email);
    theResult.updateString(11, req.getRemoteAddr());
    theResult.updateString(12, Receipt);
    theResult.insertRow();
    theResult.close();
  }catch(Exception e){
    out.println("<html><head><title>Database ORDER 
Error</title></head></body>");
    out.println("<font color=\"red\">Sorry, We have problem placing your Order "
              + "at this time. Please try again. If this problem persists, 
please "
              + "contact our Customer Service Representatives. Thank you!!!
</font>");
    out.println("</body></head>");
    return;
  }

  out.println("<html><head><title>SportShop Sale Receipt</title></head><body>");
  out.println("<br><h2 align=\"center\">SportShop Sale Receipt</h2>");
  out.println(Receipt);
  out.println("<b><u>Tracking Information:</u></b><br>" 
            + "&nbsp;&nbsp;&nbsp;&nbsp;<b>OrderID:</b> " + orderid
+ "<br>"
            + "&nbsp;&nbsp;&nbsp;&nbsp;<b>Password:</b> " + password
+ "<hr 
width=\"50%\">"
            + "<center><b>Thank you for Shopping with us.<br>Have a nice
day!!!
</b></center>");
  out.println("<br></body></head>");
}

/*******************************************************************************
***/
public void doPost (HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException 
{
  doGet(req, res);
}

/*******************************************************************************
***/
public void destroy()
{
  try
  {
    theResult.close();					
    theStatement.close();				
    theConnection.close(); 
  }catch(Exception e){
    //out.println(e.getMessage());
  }
}

/*******************************************************************************
***/
private String curFormat(double Value)
{
  DecimalFormat Currency = new DecimalFormat("$###,##0.00");
  return(Currency.format(Value));
}

/***************************************************************************/
public boolean getBilling(HttpServletRequest request) 
			throws IOException, ServletException
{
  boolean valid = true;
  strError = "<h2>Invalid/Missing Billing Information</h2><p>Please "
           + "Click on the \"<--BACK\" arrow and update the following "
	   + "input fields:<br>\n<ul>\n";

  //Get Personal Information
  LastName = request.getParameter("LastName");
  if (LastName.equals(""))
  {
    strError = strError + "<li>Last Name is missing.</li>\n";
    valid = false;
  }
  FirstName = request.getParameter("FirstName");
  if (FirstName.equals(""))
  {
    strError = strError + "<li>First Name is missing.</li>\n";
    valid = false;
  }
  Phone = request.getParameter("Phone");
  if (Phone.equals(""))
  {
    strError = strError + "<li>Phone Number is missing.</li>\n";
    valid = false;
  }
  Email = request.getParameter("Email");
  if (Email.equals(""))
  {
    Email = "None";
  }
  Street = request.getParameter("Street");
  if (Street.equals(""))
  {
    strError = strError + "<li>Street is missing.</li>\n";
    valid = false;
  }
  City = request.getParameter("City");
  if (City.equals(""))
  {
    strError = strError + "<li>City is missing.</li>\n";
    valid = false;
  }
  State = request.getParameter("State");
  if (State.equals(""))
  {
    strError = strError + "<li>State is missing.</li>\n";
    valid = false;
  }
  ZipCode = request.getParameter("ZipCode");
  if (ZipCode.equals(""))
  {
    strError = strError + "<li>Zip Code is missing.</li>\n";
    valid = false;
  }

  //Get Shipping Information
  sLastName = request.getParameter("sLastName");
  sFirstName = request.getParameter("sFirstName");
  if (sLastName.equals("") && sFirstName.equals(""))
  {
    sLastName = LastName;
    sFirstName = FirstName;
  }
  sStreet = request.getParameter("sStreet");
  sCity = request.getParameter("sCity");
  sState = request.getParameter("sState");
  sZipCode = request.getParameter("sZipCode");
  if (sStreet.equals("") || sCity.equals("") 
                         || sState.equals("") || sZipCode.equals(""))
  {
    sStreet = Street;
    sCity = City;
    sState = State;
    sZipCode = ZipCode;
  }
  
  //Check Credit Card information
  CardNum = request.getParameter("CardNumber");
  if (CardNum.equals("") || (CardNum.length() != 16))
  {
    strError = strError + "<li>Credit Card number is not valid.</li>\n";
    valid = false;
  }
  CardType = request.getParameter("CardType");
  ExpireDate = request.getParameter("ExpireDate");
  if (ExpireDate.equals(""))
  {
    strError = strError + "<li>Must enter Card Expiration Date.</li>\n";
    valid = false;
  }

  return(valid);
}

/*******************************************************************************
***/
}

Here is the Crash data:
-----------------------

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x77FCB892
Function=RtlFreeHeap+0x25F
Library=C:\WINNT\System32\ntdll.dll

Current Java thread:
	at sun.jdbc.odbc.JdbcOdbc.ReleaseStoredBytes(Native Method)
	at sun.jdbc.odbc.JdbcOdbcResultSet.FreeCols(Unknown Source)
	- locked <02A4FA78> (a sun.jdbc.odbc.JdbcOdbcResultSet)
	at sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(Unknown Source)
	at ProcCheckout.doGet(ProcCheckout.java:145)
	at ProcCheckout.doPost(ProcCheckout.java:171)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.servlets.InvokerServlet.serveRequest
(InvokerServlet.java:446)
	at org.apache.catalina.servlets.InvokerServlet.doPost
(InvokerServlet.java:216)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:201)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2344)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:164)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:462)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:163)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.connector.http.HttpProcessor.process
(HttpProcessor.java:1011)
	at org.apache.catalina.connector.http.HttpProcessor.run
(HttpProcessor.java:1106)
	at java.lang.Thread.run(Unknown Source)

Dynamic libraries:
0x00400000 - 0x00406000 	C:\Program Files\Java\j2re1.4.0\bin\java.exe
0x77F80000 - 0x77FFB000 	C:\WINNT\System32\ntdll.dll
0x77DB0000 - 0x77E0B000 	C:\WINNT\system32\ADVAPI32.dll
0x77E80000 - 0x77F35000 	C:\WINNT\system32\KERNEL32.DLL
0x77D40000 - 0x77DB0000 	C:\WINNT\system32\RPCRT4.DLL
0x78000000 - 0x78046000 	C:\WINNT\system32\MSVCRT.dll
0x6D330000 - 0x6D442000 	C:\Program Files\Java\j2re1.4.0
\bin\client\jvm.dll
0x77E10000 - 0x77E74000 	C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F7C000 	C:\WINNT\system32\GDI32.DLL
0x77570000 - 0x775A0000 	C:\WINNT\System32\WINMM.dll
0x6D1D0000 - 0x6D1D7000 	C:\Program Files\Java\j2re1.4.0\bin\hpi.dll
0x6D300000 - 0x6D30D000 	C:\Program Files\Java\j2re1.4.0\bin\verify.dll
0x6D210000 - 0x6D228000 	C:\Program Files\Java\j2re1.4.0\bin\java.dll
0x6D320000 - 0x6D32D000 	C:\Program Files\Java\j2re1.4.0\bin\zip.dll
0x6D2D0000 - 0x6D2DD000 	C:\Program Files\Java\j2re1.4.0\bin\net.dll
0x75050000 - 0x75058000 	C:\WINNT\System32\WSOCK32.dll
0x75030000 - 0x75043000 	C:\WINNT\System32\WS2_32.DLL
0x75020000 - 0x75028000 	C:\WINNT\System32\WS2HELP.DLL
0x74FD0000 - 0x74FEF000 	C:\WINNT\system32\msafd.dll
0x75010000 - 0x75017000 	C:\WINNT\System32\wshtcpip.dll
0x6D250000 - 0x6D25A000 	C:\Program Files\Java\j2re1.4.0\bin\JdbcOdbc.dll
0x1F7D0000 - 0x1F804000 	C:\WINNT\System32\ODBC32.dll
0x76B30000 - 0x76B6E000 	C:\WINNT\system32\comdlg32.dll
0x77C70000 - 0x77CBA000 	C:\WINNT\system32\SHLWAPI.DLL
0x77B50000 - 0x77BD9000 	C:\WINNT\system32\COMCTL32.DLL
0x782F0000 - 0x78532000 	C:\WINNT\system32\SHELL32.DLL
0x1F8C0000 - 0x1F8D6000 	C:\WINNT\System32\odbcint.dll
0x1F8F0000 - 0x1F932000 	C:\WINNT\System32\odbcjt32.dll
0x1B000000 - 0x1B16F000 	C:\WINNT\System32\msjet40.dll
0x1B5C0000 - 0x1B655000 	C:\WINNT\System32\mswstr10.dll
0x77A50000 - 0x77B46000 	C:\WINNT\system32\ole32.dll
0x779B0000 - 0x77A4B000 	C:\WINNT\system32\OLEAUT32.dll
0x1F8E0000 - 0x1F8EE000 	C:\WINNT\System32\odbcji32.dll
0x1B2C0000 - 0x1B2CD000 	C:\WINNT\System32\msjter40.dll
0x1B2D0000 - 0x1B2F6000 	C:\WINNT\System32\MSJINT40.DLL
0x775A0000 - 0x77625000 	C:\WINNT\System32\CLBCATQ.DLL
0x1B7F0000 - 0x1B82A000 	C:\WINNT\System32\msjtes40.dll
0x117F0000 - 0x117FB000 	C:\WINNT\System32\VBAJET32.DLL
0x11C10000 - 0x11C72000 	C:\WINNT\System32\expsrv.dll
0x77920000 - 0x77943000 	C:\WINNT\system32\imagehlp.dll
0x72A00000 - 0x72A2D000 	C:\WINNT\system32\DBGHELP.dll
0x690A0000 - 0x690AB000 	C:\WINNT\System32\PSAPI.DLL

Local Time = Sat Apr 20 00:09:20 2002
Elapsed Time = 57
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.0-b92 mixed mode)
#

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message