Il 27/07/16 00:11, Romain Manni-Bucau ha scritto:
2016-07-26 22:15 GMT+02:00 Edoardo Panfili <[email protected]>:
Il 26/07/16 20:48, Romain Manni-Bucau ha scritto:
2016-07-26 20:43 GMT+02:00 Edoardo Panfili <[email protected]>:
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