[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: JNDI datasource failing
From:       Martin Grogan <mgrogan () keizensoftware ! com>
Date:       2006-05-31 8:18:59
Message-ID: 447D5173.2000703 () keizensoftware ! com
[Download RAW message or body]

I know how you feel. I would have preferred to do that aswell. I'm not 
sure how our hosting company has their servers set up, but that was the 
only way (after weeks of trying) that we could get things working. It 
may be different in our case though, because we are on a shared environment.
Martin


Dan Simmonds wrote:

> I have tried to put the resource in the server.xml file, and found 
> that the same problem occurred.
>
> Also the exact same configuration works flawlessly in my test 
> environment, so I don't know. I'd rather keep the details in my 
> webapp's context if possible.
>
> Dan
>
>
> Martin Grogan wrote:
>
>> Hi Dan,
>> I had the exact problem with my hosting company. The problem was the 
>> resource was not being read from our context.xml file on Tomcat 
>> startup. The guys at the hosting company had to put the entry for the 
>> resource inside our context in the Tomcat common config.
>> Maybe you are experiencing something like this?
>> Martin
>>
>>
>> Dan Simmonds wrote:
>>
>>> I hope someone can help me with this problem. I have a webapp that 
>>> used an JNDI datasource that runs fine on my local test environment. 
>>> When I put it on my server it fails with the following error:
>>>
>>> javax.servlet.jsp.JspException: Unable to get connection, DataSource 
>>> invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot 
>>> create JDBC driver of class '' for connect URL 'null'"
>>>
>>> JDBC drivers for postgreSQL are in <tomcat_home>/common/lib.
>>> I wrote a java app that uses straight JDBC with the same connection 
>>> URL and other parameters and it worked just fine.
>>>
>>> My local test environment is tomcat 5.5 running through eclipse with 
>>> the web tools plugins.
>>> In production I'm using tomcat 5.5 also, exporting my project as a 
>>> WAR file.
>>>
>>> I'm at a loss as to what could be wrong. Can anyone help me?
>>>
>>> Dan
>>>
>>> Here are my configuration files:
>>>
>>> server.xml
>>> --------------------------
>>>
>>> <Server port="8005" shutdown="SHUTDOWN">
>>>
>>>  <Listener 
>>> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" 
>>> />
>>>  <Listener 
>>> className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/> 
>>>
>>>
>>>  <!-- Define the Tomcat Stand-Alone Service -->
>>>  <Service name="Catalina">
>>>    <!-- Define an AJP 1.3 Connector on port 8009 -->
>>>    <Connector port="8009"
>>>               enableLookups="false" redirectPort="8443" 
>>> protocol="AJP/1.3" />
>>>
>>>    <!-- An Engine represents the entry point (within Catalina) that 
>>> processes
>>>         every request.  The Engine implementation for Tomcat stand 
>>> alone
>>>         analyzes the HTTP headers included with the request, and 
>>> passes them
>>>         on to the appropriate Host (virtual host). -->
>>>         <!-- Define the top level container in our container 
>>> hierarchy -->
>>>    <Engine name="Catalina" defaultHost="localhost">
>>>
>>>
>>>      <!-- Define the default virtual host -->
>>>      <Host name="localhost" appBase="webapps"
>>>       unpackWARs="true" autoDeploy="true"
>>>       xmlValidation="false" xmlNamespaceAware="false">
>>>
>>>        <Valve className="org.apache.catalina.valves.AccessLogValve"
>>>                 directory="logs"  prefix="localhost_access_log." 
>>> suffix=".txt"
>>>                 pattern="common" resolveHosts="false"/>
>>>      </Host>
>>>
>>>      <Host name="xxxx.xxxxx.com" appBase="/var/www/xxxx"
>>>        unpackWARs="false" autoDeploy="true">
>>>
>>>        <Context path="/" docBase="xxxxWeb.war" debug="0" 
>>> reloadable="true"/>
>>>
>>>        <Valve className="org.apache.catalina.valves.AccessLogValve"
>>>                 directory="logs"  prefix="trinket_access_log." 
>>> suffix=".txt"
>>>                 pattern="common" resolveHosts="false"/>
>>>        </Host>
>>>    </Engine>
>>>  </Service>
>>> </Server>
>>>
>>> META-INF/context.xml
>>> --------------------------------------------
>>>
>>> <Context>
>>> <!-- defines the trinket database as a resource -->
>>> <Resource name="jdbc/xxxxDB"
>>>    auth="Container"
>>>    factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>>>    type="javax.sql.DataSource"
>>>    driverClassName="org.postgresql.Driver"
>>>    url="jdbc:postgresql://localhost:5432/database"
>>>    username="user"
>>>    password="pass"
>>>    maxActive = "10"
>>>    maxWait = "10000"
>>>    removeAbandoned = "true"
>>>    removeAbandonedTimeout = "60"
>>>    maxIdle = "5"
>>>    validationQuery = "select 1"
>>>    testWhileIdle = "true"
>>>    initialSize = "5"
>>>    minIdle = "3"
>>>    timeBetweenEvictionRunsMillis = "30000"
>>>    numTestsPerEvictionRun = "3"
>>>    minEvictableIdleTimeMillis = "24000" />
>>> </Context>
>>>
>>>
>>>
>>> WEB-INF/web.xml
>>> -----------------------------------------------
>>>
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <web-app id="WebApp_ID" version="2.4"
>>>    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">
>>>    <display-name>Website</display-name>
>>>      <welcome-file-list>
>>>        <welcome-file>index.jsp</welcome-file>
>>>    </welcome-file-list>
>>>
>>>    <!-- defines the datasource for database lookups -->
>>>    <resource-ref>
>>>        <description>Database Connection</description>
>>>        <res-ref-name>jdbc/xxxxDB</res-ref-name>
>>>        <res-type>javax.sql.DataSource</res-type>
>>>        <res-auth>Container</res-auth>
>>>    </resource-ref>
>>> </web-app>
>>>
>>>
>>> index.jsp
>>> ---------------------------------------
>>>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>>> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
>>> pageEncoding="ISO-8859-1"%>
>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>> <%-- here we test to see if an email address has been submitted or 
>>> not --%>
>>> <c:if test="${param.go == 'go'}">
>>>    <sql:query var="emailCheck" dataSource="jdbc/trinketDB">select 
>>> address from email_store where address='${param.email}'</sql:query>
>>>    ${emailCheck.rowCount}
>>>    <c:if test="${emailCheck.rowCount < 1}">
>>>        <sql:update dataSource="jdbc/trinketDB">insert into 
>>> email_store (address) values ('${param.email}')</sql:update>
>>>        <c:set var="emailGiven" value="true" scope="session" />
>>>    </c:if>
>>> </c:if>
>>>
>>> ....
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


-- 
------------
Martin Grogan
Keizen Software

mgrogan@keizensoftware.com
www.keizensoftware.com


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic