TomEE with flexibe Db-Ressource

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

TomEE with flexibe Db-Ressource

Ingo Mahnke
Hallo!
We are using "apache-tomee-plus-1.7.4".
In the file "conf/tomee.xml" I setup the database resource:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
 <Deployments dir="apps" />
   <Resource id="jdbc/QuvionPool" type="DataSource">    
JdbcDriver org.mariadb.jdbc.Driver    
JdbcUrl jdbc:mariadb://xxxxxxxxxx
UserName xxxxx    
Password xxxxx  
JtaManaged true    
</Resource>
</tomee>


Everthing works fine.

Now we switch to docker and one thing I have to do is to make the db configuation more flexibe.
so the "jdbcURL" now comes via a environment variable.

So my question now is: Is it possible to use placeholder in the tomee.xml, like ${JdbcUrl}, wich will
be replaces during tomee startup with the values from the same named envionment variable?


Thank you very much!!

Ingo
Reply | Threaded
Open this post in threaded view
|

Re: TomEE with flexibe Db-Ressource

Romain Manni-Bucau
Hi,

yes, it will work. What we often do to keep the java side and not loose
users in dev and prod env is to bridge system properties so you use:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
 <Deployments dir="apps" />
   <Resource id="jdbc/QuvionPool" type="DataSource">
JdbcDriver org.mariadb.jdbc.Driver
JdbcUrl ${quviondb.url}
UserName xxxxx
Password xxxxx
JtaManaged true
</Resource>
</tomee>


and for docker you do -e CATALINA_OPTS=-Dquviondb.url=xxxx

it allows to use the same config in dev (local) and docker since setting
system props will work in all env and with any tooling (compared to env
vars which are less reliable by experience - some tools dont support them)

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le lun. 22 oct. 2018 à 10:13, Ingo Mahnke <[hidden email]> a écrit :

> Hallo!
> We are using "apache-tomee-plus-1.7.4".
> In the file "conf/tomee.xml" I setup the database resource:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tomee>
>  <Deployments dir="apps" />
>    <Resource id="jdbc/QuvionPool" type="DataSource">
> JdbcDriver org.mariadb.jdbc.Driver
> JdbcUrl jdbc:mariadb://xxxxxxxxxx
> UserName xxxxx
> Password xxxxx
> JtaManaged true
> </Resource>
> </tomee>
>
>
> Everthing works fine.
>
> Now we switch to docker and one thing I have to do is to make the db
> configuation more flexibe.
> so the "jdbcURL" now comes via a environment variable.
>
> So my question now is: Is it possible to use placeholder in the tomee.xml,
> like ${JdbcUrl}, wich will
> be replaces during tomee startup with the values from the same named
> envionment variable?
>
>
> Thank you very much!!
>
> Ingo
>
Reply | Threaded
Open this post in threaded view
|

Aw: Re: TomEE with flexibe Db-Ressource

Ingo Mahnke
Thank you!!!




> Gesendet: Montag, 22. Oktober 2018 um 10:35 Uhr
> Von: "Romain Manni-Bucau" <[hidden email]>
> An: [hidden email]
> Betreff: Re: TomEE with flexibe Db-Ressource
>
> Hi,
>
> yes, it will work. What we often do to keep the java side and not loose
> users in dev and prod env is to bridge system properties so you use:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tomee>
>  <Deployments dir="apps" />
>    <Resource id="jdbc/QuvionPool" type="DataSource">
> JdbcDriver org.mariadb.jdbc.Driver
> JdbcUrl ${quviondb.url}
> UserName xxxxx
> Password xxxxx
> JtaManaged true
> </Resource>
> </tomee>
>
>
> and for docker you do -e CATALINA_OPTS=-Dquviondb.url=xxxx
>
> it allows to use the same config in dev (local) and docker since setting
> system props will work in all env and with any tooling (compared to env
> vars which are less reliable by experience - some tools dont support them)
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
>
> Le lun. 22 oct. 2018 à 10:13, Ingo Mahnke <[hidden email]> a écrit :
>
> > Hallo!
> > We are using "apache-tomee-plus-1.7.4".
> > In the file "conf/tomee.xml" I setup the database resource:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <tomee>
> >  <Deployments dir="apps" />
> >    <Resource id="jdbc/QuvionPool" type="DataSource">
> > JdbcDriver org.mariadb.jdbc.Driver
> > JdbcUrl jdbc:mariadb://xxxxxxxxxx
> > UserName xxxxx
> > Password xxxxx
> > JtaManaged true
> > </Resource>
> > </tomee>
> >
> >
> > Everthing works fine.
> >
> > Now we switch to docker and one thing I have to do is to make the db
> > configuation more flexibe.
> > so the "jdbcURL" now comes via a environment variable.
> >
> > So my question now is: Is it possible to use placeholder in the tomee.xml,
> > like ${JdbcUrl}, wich will
> > be replaces during tomee startup with the values from the same named
> > envionment variable?
> >
> >
> > Thank you very much!!
> >
> > Ingo
> >
>