You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Edoardo Panfili <ed...@aspix.it> on 2016/07/27 14:51:29 UTC
Re: warning during datasource configuration - SOLVED
Il 27/07/16 07:19, Romain Manni-Bucau ha scritto:
> Yes, (tomee/openejb is the same project): you got the replaced instance so
> lookup happens too late to get tomcat instance.
Very minimal working configurations:
The below $webapp/META-INF/context.xml configuration works with no warnings
<Context>
<Resource name="pool1" auth="Container" type="javax.sql.DataSource"
singleton="false"
url="jdbc:postgresql://127.0.0.1:5432/testdb"
username="testuser" password="testpassword"
driverClassName="org.postgresql.Driver"
initialSize="3" maxActive="10" maxWait="300" maxIdle="10"
removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true" />
</Context>
in TomEE+ 7.0 uses
org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
Tomcat 8.0 uses instead org.apache.tomcat.dbcp.dbcp2.BasicDataSource
Also the equivalent $webapp/WEB-INF/resources.xml works
<tomee>
<Resource id="pool2" type="javax.sql.DataSource">
jdbcDriver = org.postgresql.Driver
jdbcUrl = jdbc:postgresql://127.0.0.1:5432/testdb
jtaManaged = false
maxActive = 10
maxWaitTime = 10 seconds
minIdle = 3
maxIdle = 10
password = testpassword
userName = testuser
removeAbandoned = true
removeAbandonedTimeout = 30
logAbandoned = true
</Resource>
</tomee>
the last three properties are not documented at
http://tomee.apache.org/datasource-config.html
but are printed by dataSource.toString()
thank you for all the help
Edoardo
> Le 27 juil. 2016 06:53, "Edoardo Panfili" <ed...@aspix.it> a �crit :
>
>> Il 27/07/16 00:11, Romain Manni-Bucau ha scritto:
>>
>>> 2016-07-26 22:15 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>
>>> Il 26/07/16 20:48, Romain Manni-Bucau ha scritto:
>>>> 2016-07-26 20:43 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>
>>>>> Thank you for you propt response,
>>>>>
>>>>>> Il 26/07/16 20:24, Romain Manni-Bucau ha scritto:
>>>>>>
>>>>>> Hi Edoardo,
>>>>>>
>>>>>>> The "unusedProperty" is logged by tomee saying the setter doesn't
>>>>>>> exist
>>>>>>> and
>>>>>>> therefore the setting is just ignored.
>>>>>>>
>>>>>>> Yes, the proble is that I'd like to use that property.
>>>>>>>
>>>>>> The "is not used in DBCP2" comes from
>>>>>>
>>>>>>> tomcat org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
>>>>>>> (tomcat-dbcp)
>>>>>>> which is a dbcp bridge between tomcat config and their shade.
>>>>>>>
>>>>>>> Issue is tomee will wrap the tomcat resources - originally to add
>>>>>>> tomee
>>>>>>> features on tomcat defined datasources but since we upgraded to
>>>>>>> tomcat 8
>>>>>>> not sure it makes much sense anymore - and uses tomee factory (to
>>>>>>> allow
>>>>>>> you
>>>>>>> to get jta support, sql logging etc...) once the webapp is deployed
>>>>>>> but
>>>>>>> will also ensure resources are available before the webapp is deployed
>>>>>>> to
>>>>>>> make it available to startup events/beans. In other words you can end
>>>>>>> up
>>>>>>> using both kind of resources.
>>>>>>>
>>>>>>> The workaround is to not use singleton as resource for the datasource
>>>>>>> (but
>>>>>>> means it will create one instance per lookup) since the boot will not
>>>>>>> eagerly create the datasource the tomcat way and then you just have
>>>>>>> the
>>>>>>> tomee factory to configure.
>>>>>>>
>>>>>>> How to do that? One instance of datasource every time I use
>>>>>>>
>>>>>> Context.lookup()?
>>>>>>
>>>>>> singleton="false" I think
>>>>> Object ds1 = lookup();
>>>>> Object ds2 = lookup();
>>>>>
>>>>> and you will get ds1 != ds2 where singleton=true will make it equals.
>>>>>
>>>>> I found (only now) the reference here:
>>>> https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
>>>> I've read only:
>>>> https://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html
>>>>
>>>> I'm trying to understand: I did some tests using
>>>> -----------------------------------------------------
>>>> <Resource name="jdbc/test1" auth="Container" type="javax.sql.DataSource"
>>>> initialSize="4" maxActive="10" maxIdle="5" minIdle="3" maxWait="300"
>>>> username="testuser" password="testpassword"
>>>> driverClassName="org.postgresql.Driver"
>>>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>>>> removeAbandoned="true" removeAbandonedTimeout="60"
>>>> logAbandoned="true"
>>>> />
>>>> -----------------------------------------------------
>>>>
>>>> and adding some code to my test web service:
>>>> -----------------------------------------------------
>>>> DataSource pool1 = (DataSource) env.lookup("jdbc/test1");
>>>> DataSource pool2 = (DataSource) env.lookup("jdbc/test1");
>>>> sb.append("<p> compare = "+(pool1==pool2)+"</p>");
>>>> -----------------------------------------------------
>>>>
>>>> - with no singleton attribute I got warnings and the message
>>>> compare = true
>>>> the pool contains 10 connections (as per maxActive attribute, despite the
>>>> warning)
>>>>
>>>> - using singleton="true" I got warnings and the message
>>>> compare = true
>>>> the pool contains 10 connections (as per maxActive attribute, despite the
>>>> warning)
>>>>
>>>> - using singleton="false" I got *no* warnings and the message
>>>> compare = true
>>>> the pool contains 10 connections (as per maxActive attribute)
>>>>
>>>>
>>>> likely cause you do the lookup once tomee switch the resource definition
>>> and singleton is ignored there (all are singleton)
>>>
>>>
>>> if you log ds.getClass() you will get org.apache.openejb* or
>>> org.apache.tomcat* output and check that I think.
>>>
>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>>
>> Edoardo
>>
>>
>>> I did a mistake misunderstanding the measure unit of
>>>> removeAbandonedTimeout, using 60 (1 minute) I can see the logs of removed
>>>> connections despite the value of "singleton" and the warnings.
>>>>
>>>> thank you again to all
>>>> I will try also using resources.xml
>>>>
>>>> Edoardo
>>>>
>>>>
>>>>
Re: warning during datasource configuration - SOLVED
Posted by Romain Manni-Bucau <rm...@gmail.com>.
You can use the other one:
» ./bin/tomee.sh setters -c
'org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource'
- AbandonWhenPercentageFull
- AccessToUnderlyingConnectionAllowed
- AlternateUsernameAllowed
- CommitOnReturn
- ConnectionProperties
- DataSource
- DataSourceJNDI
- DbProperties
- DefaultAutoCommit
- DefaultCatalog
- DefaultReadOnly
- DefaultTransactionIsolation
- DriverClassName
- FairQueue
- IgnoreExceptionOnPreLoad
- InitSQL
- InitialSize
- JdbcInterceptors
- JmxEnabled
- LogAbandoned
- LogValidationErrors
- LogWriter
- LoginTimeout
- MaxActive
- MaxAge
- MaxIdle
- MaxWait
- MinEvictableIdleTimeMillis
- MinIdle
- Name
- NumTestsPerEvictionRun
- Password
- PoolProperties
- PropagateInterruptState
- RemoveAbandoned
- RemoveAbandonedTimeout
- RollbackOnReturn
- SuspectTimeout
- TestOnBorrow
- TestOnConnect
- TestOnReturn
- TestWhileIdle
- TimeBetweenEvictionRunsMillis
- Url
- UseDisposableConnectionFacade
- UseEquals
- UseLock
- Username
- ValidationInterval
- ValidationQuery
- ValidationQueryTimeout
- Validator
- ValidatorClassName
Used the other one to avoid the bash issue with $ and to need to escape it
but it browses the public API so both share the same
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2016-07-28 9:50 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
> Il 27/07/16 16:54, Romain Manni-Bucau ha scritto:
>
> 2016-07-27 16:51 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>
>> Il 27/07/16 07:19, Romain Manni-Bucau ha scritto:
>>>
>>> Yes, (tomee/openejb is the same project): you got the replaced instance
>>>> so
>>>> lookup happens too late to get tomcat instance.
>>>>
>>>> Very minimal working configurations:
>>>
>>> The below $webapp/META-INF/context.xml configuration works with no
>>> warnings
>>> <Context>
>>> <Resource name="pool1" auth="Container" type="javax.sql.DataSource"
>>> singleton="false"
>>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>>> username="testuser" password="testpassword"
>>> driverClassName="org.postgresql.Driver"
>>> initialSize="3" maxActive="10" maxWait="300" maxIdle="10"
>>> removeAbandoned="true" removeAbandonedTimeout="60"
>>> logAbandoned="true" />
>>> </Context>
>>> in TomEE+ 7.0 uses
>>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>>> Tomcat 8.0 uses instead org.apache.tomcat.dbcp.dbcp2.BasicDataSource
>>>
>>> Also the equivalent $webapp/WEB-INF/resources.xml works
>>> <tomee>
>>> <Resource id="pool2" type="javax.sql.DataSource">
>>> jdbcDriver = org.postgresql.Driver
>>> jdbcUrl = jdbc:postgresql://127.0.0.1:5432/testdb
>>> jtaManaged = false
>>> maxActive = 10
>>> maxWaitTime = 10 seconds
>>> minIdle = 3
>>> maxIdle = 10
>>> password = testpassword
>>> userName = testuser
>>> removeAbandoned = true
>>> removeAbandonedTimeout = 30
>>> logAbandoned = true
>>> </Resource>
>>> </tomee>
>>>
>>> the last three properties are not documented at
>>> http://tomee.apache.org/datasource-config.html
>>> but are printed by dataSource.toString()
>>>
>>>
>>> Well since tomee supports dynamic pool impl now the pool doc is mainly on
>> the related pool website.
>>
>> Once quick way to check what you can use is to rely on setters command
>> with
>> the pool class:
>>
>> $ ./bin/tomee.sh setters -c org.apache.tomcat.jdbc.pool.DataSource
>>
> this works fine, thank you again... but I am a little bit confused:
>
> I have to ask for "org.apache.tomcat.jdbc.pool.DataSource" because is a
> superclass of
> "org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource" ?
>
> Edoardo
>
>
>
>
>
>> thank you for all the help
>>> Edoardo
>>>
>>>
>>>
>>> Le 27 juil. 2016 06:53, "Edoardo Panfili" <ed...@aspix.it> a écrit :
>>>
>>>> Il 27/07/16 00:11, Romain Manni-Bucau ha scritto:
>>>>
>>>>> 2016-07-26 22:15 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>>
>>>>>> Il 26/07/16 20:48, Romain Manni-Bucau ha scritto:
>>>>>>
>>>>>> 2016-07-26 20:43 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>>>>
>>>>>>> Thank you for you propt response,
>>>>>>>
>>>>>>>> Il 26/07/16 20:24, Romain Manni-Bucau ha scritto:
>>>>>>>>
>>>>>>>>> Hi Edoardo,
>>>>>>>>>
>>>>>>>>> The "unusedProperty" is logged by tomee saying the setter doesn't
>>>>>>>>>
>>>>>>>>>> exist
>>>>>>>>>> and
>>>>>>>>>> therefore the setting is just ignored.
>>>>>>>>>>
>>>>>>>>>> Yes, the proble is that I'd like to use that property.
>>>>>>>>>>
>>>>>>>>>> The "is not used in DBCP2" comes from
>>>>>>>>>>
>>>>>>>>> tomcat org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
>>>>>>>>>
>>>>>>>>>> (tomcat-dbcp)
>>>>>>>>>> which is a dbcp bridge between tomcat config and their shade.
>>>>>>>>>>
>>>>>>>>>> Issue is tomee will wrap the tomcat resources - originally to add
>>>>>>>>>> tomee
>>>>>>>>>> features on tomcat defined datasources but since we upgraded to
>>>>>>>>>> tomcat 8
>>>>>>>>>> not sure it makes much sense anymore - and uses tomee factory (to
>>>>>>>>>> allow
>>>>>>>>>> you
>>>>>>>>>> to get jta support, sql logging etc...) once the webapp is
>>>>>>>>>> deployed
>>>>>>>>>> but
>>>>>>>>>> will also ensure resources are available before the webapp is
>>>>>>>>>> deployed
>>>>>>>>>> to
>>>>>>>>>> make it available to startup events/beans. In other words you can
>>>>>>>>>> end
>>>>>>>>>> up
>>>>>>>>>> using both kind of resources.
>>>>>>>>>>
>>>>>>>>>> The workaround is to not use singleton as resource for the
>>>>>>>>>> datasource
>>>>>>>>>> (but
>>>>>>>>>> means it will create one instance per lookup) since the boot will
>>>>>>>>>> not
>>>>>>>>>> eagerly create the datasource the tomcat way and then you just
>>>>>>>>>> have
>>>>>>>>>> the
>>>>>>>>>> tomee factory to configure.
>>>>>>>>>>
>>>>>>>>>> How to do that? One instance of datasource every time I use
>>>>>>>>>>
>>>>>>>>>> Context.lookup()?
>>>>>>>>>>
>>>>>>>>> singleton="false" I think
>>>>>>>>>
>>>>>>>>> Object ds1 = lookup();
>>>>>>>> Object ds2 = lookup();
>>>>>>>>
>>>>>>>> and you will get ds1 != ds2 where singleton=true will make it
>>>>>>>> equals.
>>>>>>>>
>>>>>>>> I found (only now) the reference here:
>>>>>>>>
>>>>>>>> https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
>>>>>>> I've read only:
>>>>>>> https://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html
>>>>>>>
>>>>>>> I'm trying to understand: I did some tests using
>>>>>>> -----------------------------------------------------
>>>>>>> <Resource name="jdbc/test1" auth="Container"
>>>>>>> type="javax.sql.DataSource"
>>>>>>> initialSize="4" maxActive="10" maxIdle="5" minIdle="3"
>>>>>>> maxWait="300"
>>>>>>> username="testuser" password="testpassword"
>>>>>>> driverClassName="org.postgresql.Driver"
>>>>>>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>>>>>>> removeAbandoned="true" removeAbandonedTimeout="60"
>>>>>>> logAbandoned="true"
>>>>>>> />
>>>>>>> -----------------------------------------------------
>>>>>>>
>>>>>>> and adding some code to my test web service:
>>>>>>> -----------------------------------------------------
>>>>>>> DataSource pool1 = (DataSource) env.lookup("jdbc/test1");
>>>>>>> DataSource pool2 = (DataSource) env.lookup("jdbc/test1");
>>>>>>> sb.append("<p> compare = "+(pool1==pool2)+"</p>");
>>>>>>> -----------------------------------------------------
>>>>>>>
>>>>>>> - with no singleton attribute I got warnings and the message
>>>>>>> compare = true
>>>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>>>> the
>>>>>>> warning)
>>>>>>>
>>>>>>> - using singleton="true" I got warnings and the message
>>>>>>> compare = true
>>>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>>>> the
>>>>>>> warning)
>>>>>>>
>>>>>>> - using singleton="false" I got *no* warnings and the message
>>>>>>> compare = true
>>>>>>> the pool contains 10 connections (as per maxActive attribute)
>>>>>>>
>>>>>>>
>>>>>>> likely cause you do the lookup once tomee switch the resource
>>>>>>> definition
>>>>>>>
>>>>>>> and singleton is ignored there (all are singleton)
>>>>>>
>>>>>>
>>>>>> if you log ds.getClass() you will get org.apache.openejb* or
>>>>>> org.apache.tomcat* output and check that I think.
>>>>>>
>>>>>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>>>>>>
>>>>> Edoardo
>>>>>
>>>>>
>>>>> I did a mistake misunderstanding the measure unit of
>>>>>
>>>>>> removeAbandonedTimeout, using 60 (1 minute) I can see the logs of
>>>>>>> removed
>>>>>>> connections despite the value of "singleton" and the warnings.
>>>>>>>
>>>>>>> thank you again to all
>>>>>>> I will try also using resources.xml
>>>>>>>
>>>>>>> Edoardo
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>
Re: warning during datasource configuration - SOLVED
Posted by Edoardo Panfili <ed...@aspix.it>.
Il 27/07/16 16:54, Romain Manni-Bucau ha scritto:
> 2016-07-27 16:51 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>
>> Il 27/07/16 07:19, Romain Manni-Bucau ha scritto:
>>
>>> Yes, (tomee/openejb is the same project): you got the replaced instance so
>>> lookup happens too late to get tomcat instance.
>>>
>> Very minimal working configurations:
>>
>> The below $webapp/META-INF/context.xml configuration works with no warnings
>> <Context>
>> <Resource name="pool1" auth="Container" type="javax.sql.DataSource"
>> singleton="false"
>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>> username="testuser" password="testpassword"
>> driverClassName="org.postgresql.Driver"
>> initialSize="3" maxActive="10" maxWait="300" maxIdle="10"
>> removeAbandoned="true" removeAbandonedTimeout="60"
>> logAbandoned="true" />
>> </Context>
>> in TomEE+ 7.0 uses
>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>> Tomcat 8.0 uses instead org.apache.tomcat.dbcp.dbcp2.BasicDataSource
>>
>> Also the equivalent $webapp/WEB-INF/resources.xml works
>> <tomee>
>> <Resource id="pool2" type="javax.sql.DataSource">
>> jdbcDriver = org.postgresql.Driver
>> jdbcUrl = jdbc:postgresql://127.0.0.1:5432/testdb
>> jtaManaged = false
>> maxActive = 10
>> maxWaitTime = 10 seconds
>> minIdle = 3
>> maxIdle = 10
>> password = testpassword
>> userName = testuser
>> removeAbandoned = true
>> removeAbandonedTimeout = 30
>> logAbandoned = true
>> </Resource>
>> </tomee>
>>
>> the last three properties are not documented at
>> http://tomee.apache.org/datasource-config.html
>> but are printed by dataSource.toString()
>>
>>
> Well since tomee supports dynamic pool impl now the pool doc is mainly on
> the related pool website.
>
> Once quick way to check what you can use is to rely on setters command with
> the pool class:
>
> $ ./bin/tomee.sh setters -c org.apache.tomcat.jdbc.pool.DataSource
this works fine, thank you again... but I am a little bit confused:
I have to ask for "org.apache.tomcat.jdbc.pool.DataSource" because is a
superclass of
"org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource" ?
Edoardo
>
>> thank you for all the help
>> Edoardo
>>
>>
>>
>> Le 27 juil. 2016 06:53, "Edoardo Panfili" <ed...@aspix.it> a �crit :
>>> Il 27/07/16 00:11, Romain Manni-Bucau ha scritto:
>>>> 2016-07-26 22:15 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>> Il 26/07/16 20:48, Romain Manni-Bucau ha scritto:
>>>>>
>>>>>> 2016-07-26 20:43 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>>>
>>>>>> Thank you for you propt response,
>>>>>>> Il 26/07/16 20:24, Romain Manni-Bucau ha scritto:
>>>>>>>> Hi Edoardo,
>>>>>>>>
>>>>>>>> The "unusedProperty" is logged by tomee saying the setter doesn't
>>>>>>>>> exist
>>>>>>>>> and
>>>>>>>>> therefore the setting is just ignored.
>>>>>>>>>
>>>>>>>>> Yes, the proble is that I'd like to use that property.
>>>>>>>>>
>>>>>>>>> The "is not used in DBCP2" comes from
>>>>>>>> tomcat org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
>>>>>>>>> (tomcat-dbcp)
>>>>>>>>> which is a dbcp bridge between tomcat config and their shade.
>>>>>>>>>
>>>>>>>>> Issue is tomee will wrap the tomcat resources - originally to add
>>>>>>>>> tomee
>>>>>>>>> features on tomcat defined datasources but since we upgraded to
>>>>>>>>> tomcat 8
>>>>>>>>> not sure it makes much sense anymore - and uses tomee factory (to
>>>>>>>>> allow
>>>>>>>>> you
>>>>>>>>> to get jta support, sql logging etc...) once the webapp is deployed
>>>>>>>>> but
>>>>>>>>> will also ensure resources are available before the webapp is
>>>>>>>>> deployed
>>>>>>>>> to
>>>>>>>>> make it available to startup events/beans. In other words you can
>>>>>>>>> end
>>>>>>>>> up
>>>>>>>>> using both kind of resources.
>>>>>>>>>
>>>>>>>>> The workaround is to not use singleton as resource for the
>>>>>>>>> datasource
>>>>>>>>> (but
>>>>>>>>> means it will create one instance per lookup) since the boot will
>>>>>>>>> not
>>>>>>>>> eagerly create the datasource the tomcat way and then you just have
>>>>>>>>> the
>>>>>>>>> tomee factory to configure.
>>>>>>>>>
>>>>>>>>> How to do that? One instance of datasource every time I use
>>>>>>>>>
>>>>>>>>> Context.lookup()?
>>>>>>>> singleton="false" I think
>>>>>>>>
>>>>>>> Object ds1 = lookup();
>>>>>>> Object ds2 = lookup();
>>>>>>>
>>>>>>> and you will get ds1 != ds2 where singleton=true will make it equals.
>>>>>>>
>>>>>>> I found (only now) the reference here:
>>>>>>>
>>>>>> https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
>>>>>> I've read only:
>>>>>> https://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html
>>>>>>
>>>>>> I'm trying to understand: I did some tests using
>>>>>> -----------------------------------------------------
>>>>>> <Resource name="jdbc/test1" auth="Container"
>>>>>> type="javax.sql.DataSource"
>>>>>> initialSize="4" maxActive="10" maxIdle="5" minIdle="3"
>>>>>> maxWait="300"
>>>>>> username="testuser" password="testpassword"
>>>>>> driverClassName="org.postgresql.Driver"
>>>>>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>>>>>> removeAbandoned="true" removeAbandonedTimeout="60"
>>>>>> logAbandoned="true"
>>>>>> />
>>>>>> -----------------------------------------------------
>>>>>>
>>>>>> and adding some code to my test web service:
>>>>>> -----------------------------------------------------
>>>>>> DataSource pool1 = (DataSource) env.lookup("jdbc/test1");
>>>>>> DataSource pool2 = (DataSource) env.lookup("jdbc/test1");
>>>>>> sb.append("<p> compare = "+(pool1==pool2)+"</p>");
>>>>>> -----------------------------------------------------
>>>>>>
>>>>>> - with no singleton attribute I got warnings and the message
>>>>>> compare = true
>>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>>> the
>>>>>> warning)
>>>>>>
>>>>>> - using singleton="true" I got warnings and the message
>>>>>> compare = true
>>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>>> the
>>>>>> warning)
>>>>>>
>>>>>> - using singleton="false" I got *no* warnings and the message
>>>>>> compare = true
>>>>>> the pool contains 10 connections (as per maxActive attribute)
>>>>>>
>>>>>>
>>>>>> likely cause you do the lookup once tomee switch the resource
>>>>>> definition
>>>>>>
>>>>> and singleton is ignored there (all are singleton)
>>>>>
>>>>>
>>>>> if you log ds.getClass() you will get org.apache.openejb* or
>>>>> org.apache.tomcat* output and check that I think.
>>>>>
>>>>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>>>> Edoardo
>>>>
>>>>
>>>> I did a mistake misunderstanding the measure unit of
>>>>>> removeAbandonedTimeout, using 60 (1 minute) I can see the logs of
>>>>>> removed
>>>>>> connections despite the value of "singleton" and the warnings.
>>>>>>
>>>>>> thank you again to all
>>>>>> I will try also using resources.xml
>>>>>>
>>>>>> Edoardo
>>>>>>
>>>>>>
>>>>>>
>>>>>>
Re: warning during datasource configuration - SOLVED
Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-07-27 16:51 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
> Il 27/07/16 07:19, Romain Manni-Bucau ha scritto:
>
>> Yes, (tomee/openejb is the same project): you got the replaced instance so
>> lookup happens too late to get tomcat instance.
>>
> Very minimal working configurations:
>
> The below $webapp/META-INF/context.xml configuration works with no warnings
> <Context>
> <Resource name="pool1" auth="Container" type="javax.sql.DataSource"
> singleton="false"
> url="jdbc:postgresql://127.0.0.1:5432/testdb"
> username="testuser" password="testpassword"
> driverClassName="org.postgresql.Driver"
> initialSize="3" maxActive="10" maxWait="300" maxIdle="10"
> removeAbandoned="true" removeAbandonedTimeout="60"
> logAbandoned="true" />
> </Context>
> in TomEE+ 7.0 uses
> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
> Tomcat 8.0 uses instead org.apache.tomcat.dbcp.dbcp2.BasicDataSource
>
> Also the equivalent $webapp/WEB-INF/resources.xml works
> <tomee>
> <Resource id="pool2" type="javax.sql.DataSource">
> jdbcDriver = org.postgresql.Driver
> jdbcUrl = jdbc:postgresql://127.0.0.1:5432/testdb
> jtaManaged = false
> maxActive = 10
> maxWaitTime = 10 seconds
> minIdle = 3
> maxIdle = 10
> password = testpassword
> userName = testuser
> removeAbandoned = true
> removeAbandonedTimeout = 30
> logAbandoned = true
> </Resource>
> </tomee>
>
> the last three properties are not documented at
> http://tomee.apache.org/datasource-config.html
> but are printed by dataSource.toString()
>
>
Well since tomee supports dynamic pool impl now the pool doc is mainly on
the related pool website.
Once quick way to check what you can use is to rely on setters command with
the pool class:
$ ./bin/tomee.sh setters -c org.apache.tomcat.jdbc.pool.DataSource
> thank you for all the help
> Edoardo
>
>
>
> Le 27 juil. 2016 06:53, "Edoardo Panfili" <ed...@aspix.it> a écrit :
>>
>> Il 27/07/16 00:11, Romain Manni-Bucau ha scritto:
>>>
>>> 2016-07-26 22:15 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>
>>>> Il 26/07/16 20:48, Romain Manni-Bucau ha scritto:
>>>>
>>>>> 2016-07-26 20:43 GMT+02:00 Edoardo Panfili <ed...@aspix.it>:
>>>>>
>>>>> Thank you for you propt response,
>>>>>>
>>>>>> Il 26/07/16 20:24, Romain Manni-Bucau ha scritto:
>>>>>>>
>>>>>>> Hi Edoardo,
>>>>>>>
>>>>>>> The "unusedProperty" is logged by tomee saying the setter doesn't
>>>>>>>> exist
>>>>>>>> and
>>>>>>>> therefore the setting is just ignored.
>>>>>>>>
>>>>>>>> Yes, the proble is that I'd like to use that property.
>>>>>>>>
>>>>>>>> The "is not used in DBCP2" comes from
>>>>>>>
>>>>>>> tomcat org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
>>>>>>>> (tomcat-dbcp)
>>>>>>>> which is a dbcp bridge between tomcat config and their shade.
>>>>>>>>
>>>>>>>> Issue is tomee will wrap the tomcat resources - originally to add
>>>>>>>> tomee
>>>>>>>> features on tomcat defined datasources but since we upgraded to
>>>>>>>> tomcat 8
>>>>>>>> not sure it makes much sense anymore - and uses tomee factory (to
>>>>>>>> allow
>>>>>>>> you
>>>>>>>> to get jta support, sql logging etc...) once the webapp is deployed
>>>>>>>> but
>>>>>>>> will also ensure resources are available before the webapp is
>>>>>>>> deployed
>>>>>>>> to
>>>>>>>> make it available to startup events/beans. In other words you can
>>>>>>>> end
>>>>>>>> up
>>>>>>>> using both kind of resources.
>>>>>>>>
>>>>>>>> The workaround is to not use singleton as resource for the
>>>>>>>> datasource
>>>>>>>> (but
>>>>>>>> means it will create one instance per lookup) since the boot will
>>>>>>>> not
>>>>>>>> eagerly create the datasource the tomcat way and then you just have
>>>>>>>> the
>>>>>>>> tomee factory to configure.
>>>>>>>>
>>>>>>>> How to do that? One instance of datasource every time I use
>>>>>>>>
>>>>>>>> Context.lookup()?
>>>>>>>
>>>>>>> singleton="false" I think
>>>>>>>
>>>>>> Object ds1 = lookup();
>>>>>> Object ds2 = lookup();
>>>>>>
>>>>>> and you will get ds1 != ds2 where singleton=true will make it equals.
>>>>>>
>>>>>> I found (only now) the reference here:
>>>>>>
>>>>> https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
>>>>> I've read only:
>>>>> https://tomcat.apache.org/tomcat-8.5-doc/jdbc-pool.html
>>>>>
>>>>> I'm trying to understand: I did some tests using
>>>>> -----------------------------------------------------
>>>>> <Resource name="jdbc/test1" auth="Container"
>>>>> type="javax.sql.DataSource"
>>>>> initialSize="4" maxActive="10" maxIdle="5" minIdle="3"
>>>>> maxWait="300"
>>>>> username="testuser" password="testpassword"
>>>>> driverClassName="org.postgresql.Driver"
>>>>> url="jdbc:postgresql://127.0.0.1:5432/testdb"
>>>>> removeAbandoned="true" removeAbandonedTimeout="60"
>>>>> logAbandoned="true"
>>>>> />
>>>>> -----------------------------------------------------
>>>>>
>>>>> and adding some code to my test web service:
>>>>> -----------------------------------------------------
>>>>> DataSource pool1 = (DataSource) env.lookup("jdbc/test1");
>>>>> DataSource pool2 = (DataSource) env.lookup("jdbc/test1");
>>>>> sb.append("<p> compare = "+(pool1==pool2)+"</p>");
>>>>> -----------------------------------------------------
>>>>>
>>>>> - with no singleton attribute I got warnings and the message
>>>>> compare = true
>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>> the
>>>>> warning)
>>>>>
>>>>> - using singleton="true" I got warnings and the message
>>>>> compare = true
>>>>> the pool contains 10 connections (as per maxActive attribute, despite
>>>>> the
>>>>> warning)
>>>>>
>>>>> - using singleton="false" I got *no* warnings and the message
>>>>> compare = true
>>>>> the pool contains 10 connections (as per maxActive attribute)
>>>>>
>>>>>
>>>>> likely cause you do the lookup once tomee switch the resource
>>>>> definition
>>>>>
>>>> and singleton is ignored there (all are singleton)
>>>>
>>>>
>>>> if you log ds.getClass() you will get org.apache.openejb* or
>>>> org.apache.tomcat* output and check that I think.
>>>>
>>>> org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource
>>>
>>> Edoardo
>>>
>>>
>>> I did a mistake misunderstanding the measure unit of
>>>>
>>>>> removeAbandonedTimeout, using 60 (1 minute) I can see the logs of
>>>>> removed
>>>>> connections despite the value of "singleton" and the warnings.
>>>>>
>>>>> thank you again to all
>>>>> I will try also using resources.xml
>>>>>
>>>>> Edoardo
>>>>>
>>>>>
>>>>>
>>>>>
>