Receiving NullPointerException while using Jasypt and Spring Security 3.1 - spring

I am trying to configure Jasypt with Spring Security. My configuration file looks like this:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:8090/sample
jdbc.username=ENC(*****) where the *****=the salted username
jdbc.password=ENC(*****) where the *****=the salted password
My servlet xml contains the proper bean setup in this format:
<bean id="propertyPlaceholderConfigurer"
class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="location" value="/WEB-INF/jdbc.properties" />
</bean>
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
<bean id="environmentVariablesConfiguration"
class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
<!--<property name="password" value="**********" />-->
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
My environment variable is set in windows properly for APP_ENCRYPTION_PASSWORD. It is visible when I echo it from command line. When I use this setup, I get the null pointer stack trace below. When I use the hard coded salt password "-->", my application runs smoothly. Can someone show me why Jasypt or Spring might not be picking up on my environment variable properly? Any information would be welcomed. Thanks.
org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
java.lang.NullPointerException
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:121)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperties(PropertyResourceConfigurer.java:104)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:81)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
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:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Aug 7, 2013 8:46:15 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NullPointerException
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:121)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperties(PropertyResourceConfigurer.java:104)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:81)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
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:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

May be you can try restarting windows command prompt and try again.
I got similar error and after setting up env variable, I forgot to restart windows command prompt and was getting same error.
Restarting windows command prompt resolved this issue for me.

For anyone else facing this issue and stumbling upon this question, restarting Eclipse fixed the issue.
Note: you must close Eclipse fully then re-open. Clicking "Restart" won't work as it doesn't kill the Java process completely.

In my case it was an environment variable we were counting on to use as seed
Whoever has created your setup readme, read it
:)

If you are in Linux environment,
type:
export APP_ENCRYPTION_PASSWORD=CUSTOM_KEY
If you are in Windows environment, set the environment variable:
set APP_ENCRYPTION_PASSWORD as variable, set CUSTOM_KEY as value

Related

Unable to get Impala JDBC connection with Java 1.8 [duplicate]

This question already has an answer here:
DriverManager unable to return connection after Java 8 upgrade
(1 answer)
Closed 3 years ago.
I am trying to get the impala jdbc connection in an application deployed on Jboss 6;
below is the spring bean (ID1) datasource definition for same. I am getting the exception while connecting; please refer to the exception below.
It occurs with Java 1.8 version; if I change it to Java 1.7, it works fine.
The below exception occurs only when the application also tries to connect to Oracle DB using the spring bean (ID2). If Oracle connection ID2 is not used, impala connects successfully.
Can someone please help?
Exception :
==java.lang.NullPointerException
===Stack trace...
java.util.Hashtable.put(Unknown Source)
com.cloudera.jdbc.common.AbstractDriver.copyProperties(Unknown Source)
com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source) org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFrom
DriverManager(DriverManagerDataSource.java:173) org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFrom
Driver(DriverManagerDataSource.java:164) org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnect onFromDriver(AbstractDriverBasedDataSource.java:149) org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119) org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
I tried to debug into AbstractDriver.copyProperties(), the values in properties are as follows -
{user=myuser, password=pwd}
beans defined in Spring-config.xml
<bean id="ID1"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="com.cloudera.impala.jdbc41.Driver" />
<property name="url" value="jdbc:impala://impalahost:21050/;AuthMech=1;KrbRealm=myrealm;KrbServiceName=impala;KrbHostFQDN=xxx" />
</bean>
<bean id="ID2"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"
/>
<property name="url"
value="jdbc:oracle:thin:#//oraclehost:1523/DB" />
<property name="username" value="myuser" />
<property name="password" value="pwd" />
<property name="connectionProperties">
<props>
<prop key="defaultRowPrefetch">5000</prop>
</props>
</property>
</bean>
your url property should be like <property name="url" value="jdbc:oracle:thin:#localhost:1521:ORCL"></property> not with the double slash

IBM WAS Liberty Error + missing type com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource

I'm converting a glassfish project over to IBM WAS Liberty, with much difficulty I am presently having an issue accessing my connection pool configured in Liberty (server.xml) utilizing jndi (jdbc/dataphile).
I contuinually get a missing type com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource error.
Here is some more added detail:
<library id="DB2JCC4Lib">
<fileset dir="C:/MyApps/db2/jdbc" id="db-fileset" includes="db2jcc4-9.5.jar"/>
</library>
<dataSource id="dataSource" jndiName="jdbc/dataphile" type="javax.sql.DataSource">
<jdbcDriver libraryRef="DB2JCC4Lib"/>
<connectionManager minPoolSize="2" numConnectionsPerThreadLocal="10"/>
<properties.db2.jcc databaseName="DUNDEEPD" id="DataphileProperties" password="username" portNumber="30001" serverName="xxx.xx.xxx.xxx" user="username"/>
</dataSource>
My stack trace is below;
[ERROR ] Context initialization failed
Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine modifiers of missing type com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource
[Xlint:cantFindType]
at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129)
at org.aspectj.weaver.Lint$Kind.signal(Lint.java:340)
at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)
at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getModifiers(MissingResolvedTypeWithKnownSignature.java:104)
at org.aspectj.weaver.ResolvedType.isInterface(ResolvedType.java:876)
at org.aspectj.weaver.ResolvedType.getHierarchy(ResolvedType.java:355)
at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:126)
at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:84)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1561)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162)
... 58 more
I am not an expert on this but a similar problem was reported here:
https://developer.ibm.com/answers/questions/9498/datasource-issue-on-liberty-in-spring-hibernate-application.html
The solution required adding this to the datasource:
<property name="resourceRef" value="true" />
<property name="expectedType" value="javax.sql.DataSource"/>
Try creating META-INF/aop.xml file as described in the following post: Why aspect j can't weave show Xlint cantFindType and exclude the com.ibm.ws.rsadapter.jdbc.* classes or better yet, include only your application classes.
I do have enough theory as to why, but this is how I fundamentally how to fix my issue:
Originally, in my Spring XML schema configuration, I had the following:
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/mydatasource" />
But I had to convert it to the following:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/mydatasource" />
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>
So essentially as suggested I had to enforce this configuration change which added the following properties:
<property name="proxyInterface" value="javax.sql.DataSource"
Hopefully that help someone else out there
Thanks

Spring WorkManagerTaskExecutor cannot initialize in websphere

i want use Websphere work manager for executing async jobs in jee context but i have problem with creating spring WorkManager.
bean definition:
<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor"> <property name="workManagerName" value="wm/default" /> </bean>
this definition i found in websphere help. But problem is this ends with noClassDefFound. I noticed pckg org.springframework.scheduling.commonj is missing from spring-context since version 2.x.x
Is it replaced with org.springframework.jca.work.WorkManagerTaskExecutor ?
when i use this other spring class, i get error:
Caused by: org.springframework.jndi.TypeMismatchNamingException:
Object of type [class com.ibm.ws.asynchbeans.WorkManagerImpl]
available at JNDI location [wm/default] is not assignable to
[javax.resource.spi.work.WorkManager]
so whats deal here? thx
was - 7.0.0.23
spring - 3.1.2
Class org.springframework.scheduling.commonj.WorkManagerTaskExecutor resides in spring-context-support-3.1.2.RELEASE.jar
Configuration succeeds with javax.resource.spi.work.WorkManager in applicationContext-service.xml in deployment.....
In my case deployment fails for bean injection org.springframework.scheduling.commonj.WorkManagerTaskExecutor as it fails to take WorkManager JNDI Configured in Application Server.... I just replaced javax.resource.spi.work.WorkManager. And so far it is success deployment.
I yet to see application works fine with it.
<bean id="taskExecutor" class="javax.resource.spi.work.WorkManager">
<property name="workManagerName" value="wm/default" />
</bean>
In our scenario we were managed it by ThreadPoolTaskExecutor instead of WorkManagerTaskExecutor
Here is configuration that comes in ApplicationContext.xml
<!--
<bean id="rtSenderTaskExecutor"
class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName">
<value>${org.quartz.threadPool.jndi}</value>
</property>
</bean> -->
<!-- Local Thread Pool -->
<bean id="rtSenderTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="${org.quartz.threadPool.corePoolSize}" />
<property name="maxPoolSize" value="${org.quartz.threadPool.maxPoolSize}" />
<property name="queueCapacity" value="${org.quartz.threadPool.queueCapacity}" />
<property name="keepAliveSeconds" value="${org.quartz.threadPool.keepAliveSeconds}"></property>
</bean>

BoneCP sometimes cannot get config from spring property holder

I have been facing this issue for a while now. My config is as following
<!-- Load Properties Files -->
<context:property-placeholder location="classpath:*-${environment}.properties" ignore-unresolvable="true"/>
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="idleConnectionTestPeriodInMinutes" value="${boneCP.idleConnectionTestPeriodInMinutes}"/>
<property name="idleMaxAgeInMinutes" value="${boneCP.idleMaxAgeInMinutes}"/>
<property name="maxConnectionsPerPartition" value="${boneCP.maxConnectionsPerPartition}"/>
<property name="minConnectionsPerPartition" value="${boneCP.minConnectionsPerPartition}"/>
<property name="partitionCount" value="${boneCP.partitionCount}"/>
<property name="acquireIncrement" value="${boneCP.acquireIncrement}"/>
<property name="statementsCacheSize" value="${boneCP.statementsCacheSize}"/>
<property name="lazyInit" value="true"/>
<property name="maxConnectionAgeInSeconds" value="${boneCP.maxConnectionAgeInSeconds}"/>
</bean>
The project is running on Tomcat 7
On the local machine, the project deploy with no error as well as for the dev server. Unfortunately, the project cannot be deployed on dev server any more (server configuration remain same) while local machine is still fine. Every time I deploy the project on the dev server, Tomcat just hang at INFO: Deploying web application archive /etc/tomcat/webapps/project.war. But if I config BoneCP with real values, everything is fine.
Could any one tell me what's wrong with it?
It turned out to be the lazyInit problem. If I comment it out, the server can start normally. But now I'm facing the new issue though. Mybatis cannot access the db at all while the local machine is 100% fine. and yet dont throw any exception. But when I stop the server, I found the following exceptions
INFO: Illegal access: this web application instance has been stopped already. Could not load com.jolbox.bonecp.PoolUtil. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:94)
at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:90)
at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:540)
at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:66)
AND
INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.ibatis.reflection.ExceptionUtil. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:363)
at sun.proxy.$Proxy15.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
at sun.proxy.$Proxy45.selectByExample(Unknown Source)
Well it could be many things but its most likely
properties are not being replaced with the values you think
the database number of connections has been exceeded or the wrong host
A combination of 1 + 2
For #1 I would a make a separate bean that needs com.jolbox.bonecp.BoneCPDataSource as a dependency and have it print out the getters of BoneCPDataSource.
For #2 I would turn on as much logging as possible (see log4j or logback or whatever your logging framework is).

org.apache.tomcat.jdbc.pool.DataSource is no longer in the tomcat 7 dbcp jar?

I am trying to create a spring-managed standalone pool for tomcat-dbcp using the version 7.0.30 of tomcat-dbcp.jar
However it seems the org.apache.tomcat.jdbc.DataSource class that is referred to in the Tomcat's documentation (http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Standalone)
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close">
<property name="factory"
value="org.apache.tomcat.jdbc.pool.DataSourceFactory" />
<property name="type" value="javax.sql.DataSource" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/ym" />
<property name="username" value="admin" />
<property name="password" value="admin" />
<property name="initialSize" value="5" />
<property name="maxActive" value="10" />
</bean>
So this spring bean definition is correct according to Tomcat doc, however when I start the app up, I get CNF exception:
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.tomcat.jdbc.pool.DataSource] for bean with name 'dataSource' defined in class path resource [application-context.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.DataSource
Am I being super stupid and missing the obvious here???
Class org.apache.tomcat.jdbc.pool.DataSource is included in tomcat-jdbc.jar, not tomcat-dbcp.jar. The Tomcat JDBC Connection Pool is a replacement for commons-dbcp, of which tomcat-dbcp is just a renamed version.
The jar file tomcat-jdbc.jar is not included in all Tomcat installations (e.g. it is not included in the standard Debian/Ubuntu package). You can download it from Maven Central or you can find it in the Tomcat binary distribution archive.

Resources