You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Emmanuel Touzery <em...@lit-transit.com> on 2021/03/23 16:01:58 UTC
setting up the hikari connection pool with tomee
Hello,
I'm trying to configure hibernate+hikarip connection pool for TOMEE.
I made it work without issues (at first sight), by configuring
everything in the persistence.xml, basically as described in the answer
to this stackoverflow question:
https://stackoverflow.com/questions/49366198/how-to-configure-hikaricp-via-tomee-xml
I would rather configure it through TOMEE data sources, as I'm used
to, in the conf/tomee.xml or conf/context.xml
I've attempted to do so, also helping myself with
https://github.com/brettwooldridge/HikariCP/wiki/JNDI-DataSource-Factory-(Tomcat,-etc.)
But I didn't manage to. I got errors like described in the
stackoverflow question, but also some others.
I have two questions:
1. is it supported to specify the connection purely through the
persistence.xml without any datasource in the tomee.xml? Will
UserTransactions, container-managed transactions work as expected?
2. could I configure tomee+hibernate+hikaricp through a tomee
datasource? If so, how? (One reason I'd rather have a datasource is
also so that it's possible to edit the JDBC configuration (eg IP,
password, connection pool size..) without redeploying the
application (because the persistence.xml is in the war)
Thank you!
Emmanuel
Re: setting up the hikari connection pool with tomee
Posted by "Zowalla, Richard" <ri...@hs-heilbronn.de>.
Hi Emmanuel,
I think, you can get JTA support by wrapping the HikariDS
inside JTADataSourceWrapperFactory as mentioned in [1].
I did some quick tests with Hibernate /HikariCP. The following might
work via tomee.xml / resource.xml:
<Resource id="hikariCP" class-
name="com.zaxxer.hikari.HikariDataSource">
driverClassName org.hsqldb.jdbcDriver
jdbcUrl jdbc:hsqldb:mem:demo
username sa
password
</Resource>
<Resource id="demo" type="DataSource" class-
name="org.apache.openejb.resource.jdbc.managed.JTADataSourceWrapperFact
ory" factory-name="create">
Delegate = hikariCP
</Resource>
You can then use
<jta-data-source>java:openejb/Resource/demo</jta-data-source>
to define the JTA datasource in your persistence.xml.
Setting "hibernate.connection.provider_class" will create a connection
pool within Hibernate, which is not managed by the container.
Hope it helps.
Gruss,
Richard
Am Dienstag, den 23.03.2021, 21:54 +0100 schrieb Emmanuel Touzery:
> Hello,
>
> thank you for the answer!
>
> These links focus on the DataSource approach, which I've failed to
> make work as well. What I did get to work was through the
> persistence.xml, completely bypassing TOMEE's datasources (as
> described in the stackoverflow link I gave), but then I'm not sure
> whether UserTransactions and container-managed transactions are
> supported (at first sight things seem to work, but the devil is in
> the details).
>
> I hope maybe someone can answer on that?
>
> Thank you again,
>
> Emmanuel
>
> ----- Original Message -----
> From: "Zowalla, Richard" <ri...@hs-heilbronn.de>
> To: users@tomee.apache.org
> Sent: Tuesday, 23 March, 2021 20:28:01
> Subject: Re: setting up the hikari connection pool with tomee
>
> Hi,
>
> there were some discussions related to HikariCP on the lists a few
> days
> ago [1], [2], and [3]. I would try with [1] and [2]. Hope it helps.
>
> Gruss
> Richard
>
>
> [1]
> http://tomee-openejb.979440.n4.nabble.com/HikariCP-configuration-in-TomEE-td4678838.html
> [2]
> http://tomee-openejb.979440.n4.nabble.com/Configuring-HikariCP-with-OpenEjb-need-inputs-td4691576.html
> [3]
> http://tomee-openejb.979440.n4.nabble.com/HikariCp-to-set-JtaManaged-td4689571.html
>
> Am Dienstag, den 23.03.2021, 17:01 +0100 schrieb Emmanuel Touzery:
> > Hello,
> >
> > I'm trying to configure hibernate+hikarip connection pool for
> > TOMEE.
> >
> > I made it work without issues (at first sight), by
> > configuring
> > everything in the persistence.xml, basically as described in the
> > answer
> > to this stackoverflow question:
> >
> > https://stackoverflow.com/questions/49366198/how-to-configure-hikaricp-via-tomee-xml
> >
> > I would rather configure it through TOMEE data sources, as I'm
> > used
> > to, in the conf/tomee.xml or conf/context.xml
> >
> > I've attempted to do so, also helping myself with
> > https://github.com/brettwooldridge/HikariCP/wiki/JNDI-DataSource-Factory-(Tomcat,-etc.)
> >
> > But I didn't manage to. I got errors like described in the
> > stackoverflow question, but also some others.
> >
> > I have two questions:
> >
> > 1. is it supported to specify the connection purely through the
> > persistence.xml without any datasource in the tomee.xml? Will
> > UserTransactions, container-managed transactions work as
> > expected?
> > 2. could I configure tomee+hibernate+hikaricp through a tomee
> > datasource? If so, how? (One reason I'd rather have a
> > datasource
> > is
> > also so that it's possible to edit the JDBC configuration (eg
> > IP,
> > password, connection pool size..) without redeploying the
> > application (because the persistence.xml is in the war)
> >
> > Thank you!
> >
> > Emmanuel
> >
> >
--
Richard Zowalla, M.Sc.
Research Associate, PhD Student | Medical Informatics
Hochschule Heilbronn – University of Applied Sciences
Max-Planck-Str. 39
D-74081 Heilbronn
phone: +49 7131 504 6791
mail: richard.zowalla@hs-heilbronn.de
web: https://www.mi.hs-heilbronn.de/
Re: setting up the hikari connection pool with tomee
Posted by Emmanuel Touzery <em...@lit-transit.com>.
Hello,
thank you for the answer!
These links focus on the DataSource approach, which I've failed to make work as well. What I did get to work was through the persistence.xml, completely bypassing TOMEE's datasources (as described in the stackoverflow link I gave), but then I'm not sure whether UserTransactions and container-managed transactions are supported (at first sight things seem to work, but the devil is in the details).
I hope maybe someone can answer on that?
Thank you again,
Emmanuel
----- Original Message -----
From: "Zowalla, Richard" <ri...@hs-heilbronn.de>
To: users@tomee.apache.org
Sent: Tuesday, 23 March, 2021 20:28:01
Subject: Re: setting up the hikari connection pool with tomee
Hi,
there were some discussions related to HikariCP on the lists a few days
ago [1], [2], and [3]. I would try with [1] and [2]. Hope it helps.
Gruss
Richard
[1]
http://tomee-openejb.979440.n4.nabble.com/HikariCP-configuration-in-TomEE-td4678838.html
[2]
http://tomee-openejb.979440.n4.nabble.com/Configuring-HikariCP-with-OpenEjb-need-inputs-td4691576.html
[3]
http://tomee-openejb.979440.n4.nabble.com/HikariCp-to-set-JtaManaged-td4689571.html
Am Dienstag, den 23.03.2021, 17:01 +0100 schrieb Emmanuel Touzery:
> Hello,
>
> I'm trying to configure hibernate+hikarip connection pool for
> TOMEE.
>
> I made it work without issues (at first sight), by configuring
> everything in the persistence.xml, basically as described in the
> answer
> to this stackoverflow question:
>
> https://stackoverflow.com/questions/49366198/how-to-configure-hikaricp-via-tomee-xml
>
> I would rather configure it through TOMEE data sources, as I'm
> used
> to, in the conf/tomee.xml or conf/context.xml
>
> I've attempted to do so, also helping myself with
> https://github.com/brettwooldridge/HikariCP/wiki/JNDI-DataSource-Factory-(Tomcat,-etc.)
>
> But I didn't manage to. I got errors like described in the
> stackoverflow question, but also some others.
>
> I have two questions:
>
> 1. is it supported to specify the connection purely through the
> persistence.xml without any datasource in the tomee.xml? Will
> UserTransactions, container-managed transactions work as
> expected?
> 2. could I configure tomee+hibernate+hikaricp through a tomee
> datasource? If so, how? (One reason I'd rather have a datasource
> is
> also so that it's possible to edit the JDBC configuration (eg
> IP,
> password, connection pool size..) without redeploying the
> application (because the persistence.xml is in the war)
>
> Thank you!
>
> Emmanuel
>
>
Re: setting up the hikari connection pool with tomee
Posted by "Zowalla, Richard" <ri...@hs-heilbronn.de>.
Hi,
there were some discussions related to HikariCP on the lists a few days
ago [1], [2], and [3]. I would try with [1] and [2]. Hope it helps.
Gruss
Richard
[1]
http://tomee-openejb.979440.n4.nabble.com/HikariCP-configuration-in-TomEE-td4678838.html
[2]
http://tomee-openejb.979440.n4.nabble.com/Configuring-HikariCP-with-OpenEjb-need-inputs-td4691576.html
[3]
http://tomee-openejb.979440.n4.nabble.com/HikariCp-to-set-JtaManaged-td4689571.html
Am Dienstag, den 23.03.2021, 17:01 +0100 schrieb Emmanuel Touzery:
> Hello,
>
> I'm trying to configure hibernate+hikarip connection pool for
> TOMEE.
>
> I made it work without issues (at first sight), by configuring
> everything in the persistence.xml, basically as described in the
> answer
> to this stackoverflow question:
>
> https://stackoverflow.com/questions/49366198/how-to-configure-hikaricp-via-tomee-xml
>
> I would rather configure it through TOMEE data sources, as I'm
> used
> to, in the conf/tomee.xml or conf/context.xml
>
> I've attempted to do so, also helping myself with
> https://github.com/brettwooldridge/HikariCP/wiki/JNDI-DataSource-Factory-(Tomcat,-etc.)
>
> But I didn't manage to. I got errors like described in the
> stackoverflow question, but also some others.
>
> I have two questions:
>
> 1. is it supported to specify the connection purely through the
> persistence.xml without any datasource in the tomee.xml? Will
> UserTransactions, container-managed transactions work as
> expected?
> 2. could I configure tomee+hibernate+hikaricp through a tomee
> datasource? If so, how? (One reason I'd rather have a datasource
> is
> also so that it's possible to edit the JDBC configuration (eg
> IP,
> password, connection pool size..) without redeploying the
> application (because the persistence.xml is in the war)
>
> Thank you!
>
> Emmanuel
>
>