title: configure BasicDataSource as bean in web.xml
body: <p>I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6. (it's red5 with tomcat, we can ignore that the main server is actually red5 because i actually run jsp files under port 5080 and don't connect to the red5 directly using RTMP protocol)</p>
  
  <p>my web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;web-app 
  xmlns="http://java.sun.com/xml/ns/j2ee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/  j2ee/web-app_2_4.xsd" 
  version="2.4"&gt; 
  
  &lt;display-name&gt;gamesisland-login-red5&lt;/display-name&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;webAppRootKey&lt;/param-name&gt;
      &lt;param-value&gt;/[myapp]&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.red5.logging.ContextLoggingListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.red5.logging.LoggerContextFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.red5.server.net.rtmpt.RTMPTServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/fcs/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/open/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/close/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/send/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rtmpt&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/idle/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Forbidden&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/streams/*&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint/&gt;
  &lt;/security-constraint&gt;
  
  &lt;bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="location" value="/WEB-INF/red5-web.properties" /&gt;
  &lt;/bean&gt;
  
     &lt;bean id="idDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
              &lt;property name="driverClassName"&gt;&lt;value&gt;${db.driver}&lt;/value&gt;&lt;/property&gt;
              &lt;property name="url"&gt;&lt;value&gt;${db.url}&lt;/value&gt;&lt;/property&gt;
              &lt;property name="username"&gt;&lt;value&gt;${db.username}&lt;/value&gt;&lt;/property&gt;
              &lt;property name="password"&gt;&lt;value&gt;${db.password}&lt;/value&gt;&lt;/property&gt;
              &lt;property name="poolPreparedStatements"&gt;&lt;value&gt;true&lt;/value&gt;&lt;/property&gt;
              &lt;property name="maxActive"&gt;&lt;value&gt;10&lt;/value&gt;&lt;/property&gt;
              &lt;property name="maxIdle"&gt;&lt;value&gt;10&lt;/value&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>my red5-web.properties:</p>
  
  <pre><code>webapp.contextPath=/myapp
  webapp.virtualHosts=*
  db.driver=com.mysql.jdbc.Driver
  db.url=jdbc:mysql://127.0.0.1:3306/dbname
  db.username=user
  db.password=pass
  </code></pre>
  
  <p>does tomcat automatically searches for WEB-INF/web.xml for configuration?</p>
  
  <p>why don't I get any relevant errors to the creation of idDataSource ?</p>
  
  <p>I really don't have any clue how to pinpoint or debug the problem. 
  any assistance would be greatly appreciated. </p>
  
  <p>thank you!</p>
  
  <p>kfir</p>