Archive for Tomcat

SEVERE: Error listenerStart

When you start tomcat server and get the error “SEVER: Error listenerStart”… “SEVERE: Context [/xxxxxxxxxx] startup failed due to previous errors”, it is because you have multiple apps under webapp/ folder. You need add the following lines in every app’s web.xml

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>xxxxxxxxxx.root</param-value>
</context-param>

It is Log4jWebConfigurer’s requirement…

http://opensource.objectsbydesign.com/spring-1.1.4/org/springframework/web/util/Log4jWebConfigurer.html

Advertisements

Leave a Comment

Spring + DBCP

Adding a connection pool to a Spring app is simply a matter of specifying the relevant entries in the Spring servlet configuration file. The XML snippet below shows an example of how a database connection pool can easily be configured.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName">
    <value>net.sourceforge.jtds.jdbc.Driver</value>
  </property>
  <property name="url">
    <value>jdbc:jtds:sqlserver://localhost:1433/db;prepareSQL=0;SendStringParametersAsUnicode=False;</value>
  </property>
  <property name="username">
    <value>username</value>
  </property>
  <property name="password">
    <value>password</value>
  </property>
  <property name="initialSize">
    <value>2</value>
  </property>
  <property name="maxActive">
    <value>5</value>
  </property>
  <property name="maxIdle">
    <value>2</value>
  </property>
</bean>

There are more options that can be used to configure the DBCP connection pool,
eg whether to test connections when getting from the pool or the time to wait
before getting a connection. The complete list of options is given
here.

Comments (16)

Upgrade JSTL from 1.0 to 1.1

  1. Use Tomcat >5.0
  2. Download jstl.jar and standard.jar to WEB-INF/lib
  3. Change include tag from
    <%@ taglib prefix=”c” uri=”http://java.sun.com/jstl/core&#8221; %>
    <%@ taglib prefix=”fmt” uri=”http://java.sun.com/jstl/fmt&#8221; %>
    to
    <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core&#8221; %>
    <%@ taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt&#8221; %>
  4. In web.xml, use tag
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&#8221;
    version=”2.4″>

Leave a Comment

Solution for error: Tomcat:port already in use

If port is 8080:

$ netstat -nab | grep 8080

TCP 127.0.0.1:8080 127.0.0.1:1968 CLOSE_WAIT 2112
TCP 127.0.0.1:8080 127.0.0.1:2025 CLOSE_WAIT 2112
TCP 127.0.0.1:8080 127.0.0.1:1964 CLOSE_WAIT 2112
$ ps -e | grep 2112

2112 3:47 java

$ kill 2112

Comments (1)