You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Ingo Mahnke <in...@quvion.org> on 2018/10/22 08:12:57 UTC

TomEE with flexibe Db-Ressource

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

Aw: Re: TomEE with flexibe Db-Ressource

Posted by Ingo Mahnke <in...@quvion.org>.
Thank you!!!




> Gesendet: Montag, 22. Oktober 2018 um 10:35 Uhr
> Von: "Romain Manni-Bucau" <rm...@gmail.com>
> An: dev@tomee.apache.org
> 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 <in...@quvion.org> 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
> >
>

Re: TomEE with flexibe Db-Ressource

Posted by Romain Manni-Bucau <rm...@gmail.com>.
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 <in...@quvion.org> 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
>