>> Hi,
>>
>>> We are using Tomcat 7.0.40 version. We are using Tomcat DBCP for
>>> pooling connections.
>>>
>>> We are able to pool connections for different aliases. But for
>>> one alias, connections are not pooling. The user and password is
>>> good because the
>>> same
>>> alias in apache dbcp works fine.
>>>
>>> What do you mean by “alias”?  Not following you there.
>>>
>> Well, alias is the resource name.

>>That wasn't clear in your first post.

>>> Why are we not able to pool any connections here?
>>>
>>> Also, what do you mean when you say it’s “not pooling”?  Are you
>>> getting
>>> an >error or exception?  If so, what is it?
>>>
>>> Yes, whenever a connection is requested from this particular
>>> resource, a null pointer exception is thrown at the point of
>>> invoking getConnection.

>Stack trace?
java.lang.NullPointerException
        at
org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:285)
        at
org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:189)
        at com.xxxx.CustomFactory.createDataSource(CustomFactory.java:90)
        at
org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:237)
        at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
        at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
        at
org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1093)
        at
org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:672)
        at
org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:271)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1654)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)


>>> Here is a sample of context xml entry:
>
>>> Are you putting this in “conf/context.xml”?  If so, are you sure
>>> that’s
>> what you want?
>>>
>>> Yes, this is from context.xml.

>>There can be more than one context.xml. Dan was asking if you are sure
>>you wanted to modify the site-wide context.xml file instead of just
>>doing it for a single web application (which is much more popular and
>>safe).

Sorry, I got you wrong the first time. This entry is in the web
application's context.xml. conf/context.xml does not have any entry related
to this web application.

>>> All the resources work except for one. What could be the reason?
>>>
>>> <Resource name="jdbc/resource" auth="Container"
>>> type="javax.sql.DataSource" fairQueue="true" factory="<
>>> customEncrytpedFactory>”
>>>
>>> Have you tried taking your custom factory out of the mix and
>>> using a stock
>>> one? > Do you still see the same issue?
>>>
>>> Since the same custom factory is working for other resources except
>>> for this one, I have not tried this out.
>>>
>>> username="<username>" password="<encrypted_password>"
>>> driverClassName="oracle.jdbc.OracleDriver" url="<url>"
>>> timeBetweenEvictionRunsMillis="1800000" validationQuery="SELECT 1
>>> from dual" validationInterval="30000" maxActive="50" minIdle="4"
>>> maxIdle="4" maxWait="10000" initialSize="4"
>>> removeAbandonedTimeout="60" removeAbandoned="true"
>>> logAbandoned="false" minEvictableIdleTimeMillis="600000"
>>> initSQL="<initSQL>” testOnBorrow="false" testOnReturn="false"
>>> testWhileIdle="true" />

> Okay, what are the differences between the <Resource> configuration
> and your usage of them? NPE would likely point to an incorrect
> resource name being used in your code, but since you haven't posted
> any stack trace, I can only guess.

Reply via email to