I have a very simple servlet which hangs on the servlet init method.  Another 
similar example I have throws an OOM excetpion doing the same thing. All the 
code is doing is trying to parse the web.xml using the commons digester.

I hope this isn't too much code to paste.  I'm running a default 5.0.1 (same 
behavior on 5.0.0, but this code runs fine on the 4.2.2 server) server with 
1.6.0.11 jdk.

This code originates from the struts 1.1 ActionServlet.   There is a problem 
with the digester.parse() call.  Does this have something to do with VFS 
perhaps?


  | package org.test;
  | 
  | import java.io.IOException;
  | import java.io.InputStream;
  | import java.net.URL;
  | 
  | import javax.servlet.ServletException;
  | import javax.servlet.http.HttpServlet;
  | 
  | import org.apache.commons.digester.Digester;
  | import org.apache.commons.logging.Log;
  | import org.apache.commons.logging.LogFactory;
  | import org.apache.struts.Globals;
  | import org.xml.sax.SAXException;
  | 
  | public class TestServlet extends HttpServlet {
  | 
  |     public TestServlet() {
  |         super();
  |         // TODO Auto-generated constructor stub
  |     }
  |     
  |     protected static Log log = LogFactory.getLog(TestServlet.class);
  |     protected String registrations[] = {
  |             "-//Apache Software Foundation//DTD Struts Configuration 
1.0//EN",
  |             "/org/apache/struts/resources/struts-config_1_0.dtd",
  |             "-//Apache Software Foundation//DTD Struts Configuration 
1.1//EN",
  |             "/org/apache/struts/resources/struts-config_1_1.dtd",
  |             "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
  |             "/org/apache/struts/resources/web-app_2_2.dtd",
  |             "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
  |             "/org/apache/struts/resources/web-app_2_3.dtd"
  |         };
  | 
  |     protected String servletMapping = null;
  |     protected String servletName = null;
  | 
  |     /**
  |      * @see Servlet#init(ServletConfig)
  |      */
  |     protected void initServlet() throws ServletException
  |     {
  | 
  |         // Remember our servlet name
  |         this.servletName = getServletConfig().getServletName();
  | 
  |         // Prepare a Digester to scan the web application deployment 
descriptor
  |         Digester digester = new Digester();
  |         digester.push(this);
  |         digester.setNamespaceAware(true);
  |         digester.setValidating(false);
  | 
  |         // Register our local copy of the DTDs that we can find
  |         for (int i = 0; i < registrations.length; i += 2) {
  |             URL url = this.getClass().getResource(registrations[i+1]);
  |             if (url != null) {
  |                 digester.register(registrations, url.toString());
  |             }
  |         }
  | 
  |         // Configure the processing rules that we need
  |         digester.addCallMethod("web-app/servlet-mapping",
  |                                "addServletMapping", 2);
  |         digester.addCallParam("web-app/servlet-mapping/servlet-name", 0);
  |         digester.addCallParam("web-app/servlet-mapping/url-pattern", 1);
  | 
  |         // Process the web application deployment descriptor
  |         if (log.isDebugEnabled()) {
  |             log.debug("Scanning web.xml for controller servlet mapping");
  |         }
  | 
  |         InputStream input =
  |             getServletContext().getResourceAsStream("/WEB-INF/web.xml");
  | 
  |         try {
  |             digester.parse(input);
  | 
  |         } catch (IOException e) {
  |             log.error("io error", e);
  |             throw new ServletException(e);
  |             
  |         } catch (SAXException e) {
  |             log.error("error", e);
  |             throw new ServletException(e);
  |             
  |         } finally {
  |             if (input != null) {
  |                 try {
  |                     input.close();
  |                 } catch (IOException e) {
  |                     log.error("error", e);
  |                     throw new ServletException(e);
  |                 }
  |             }
  |         }
  | 
  |         // Record a servlet context attribute (if appropriate)
  |         if (log.isDebugEnabled()) {
  |             log.debug("Mapping for servlet '" + servletName + "' = '" +
  |                 servletMapping + "'");
  |         }
  | 
  |         if (servletMapping != null) {
  |             getServletContext().setAttribute(Globals.SERVLET_KEY, 
servletMapping);
  |         }
  | 
  |     }
  | 
  |     public void init() throws ServletException {
  |             log.info("start - init()");
  |             initServlet();
  |             log.info("done - init()");
  |     }
  |     
  | }
  | 

web.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <!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>jbtest</display-name>
  |     <servlet>
  |             <servlet-name>ActionServlet</servlet-name>
  |             <servlet-class>org.test.TestServlet</servlet-class>
  |             <load-on-startup>-1</load-on-startup>
  |     </servlet>
  |     <servlet-mapping>
  |             <servlet-name>ActionServlet</servlet-name>
  |             <url-pattern>/do/eforms-client</url-pattern>
  |     </servlet-mapping>
  | </web-app>
  | 

It's been over 5 minutes sitting there with the cpu spiked and the init method 
didn't finish.  My log only shows the start log, not the stop.


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4216182#4216182

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4216182
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to