TomEE Maven Plugin: Can conf/system.properties be externalized?

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

TomEE Maven Plugin: Can conf/system.properties be externalized?

exabrial12
We want to store the configuration for our datasources separate from the
distribution of the one-jar. If you haven't seen Jonathan [Gallimore's]
excellent blog post on configuration TomEE, see here:
https://www.tomitribe.com/blog/tomee-configuration-techniques/

Looking at the TomEE plugin's options though, it allows you to include a
system.properties at build time, but I can't seem to find a way to set it at
runtime.

Any ideas or alternatives?



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

Romain Manni-Bucau
Hello,

You can always load system properties in setenv.sh before the server starts.

If it is properties settable after tomee.xml is read you can set them in it
and it supports <Import path=.... />

Finally you can always plug a tomcat listener before tomee one and set the
system properties the way you want peogrammatically.

Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :

> We want to store the configuration for our datasources separate from the
> distribution of the one-jar. If you haven't seen Jonathan [Gallimore's]
> excellent blog post on configuration TomEE, see here:
> https://www.tomitribe.com/blog/tomee-configuration-techniques/
>
> Looking at the TomEE plugin's options though, it allows you to include a
> system.properties at build time, but I can't seem to find a way to set it
> at
> runtime.
>
> Any ideas or alternatives?
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

Roberto Cortez
I guess you want to hide user, password, connection, schema etc.

You could use variable replacement with ${} and pack the file in the jar and then just set the properties to replace like Romain mentioned. I think it should work,

Cheers,
Roberto

> On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]> wrote:
>
> Hello,
>
> You can always load system properties in setenv.sh before the server starts.
>
> If it is properties settable after tomee.xml is read you can set them in it
> and it supports <Import path=.... />
>
> Finally you can always plug a tomcat listener before tomee one and set the
> system properties the way you want peogrammatically.
>
> Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
>
>> We want to store the configuration for our datasources separate from the
>> distribution of the one-jar. If you haven't seen Jonathan [Gallimore's]
>> excellent blog post on configuration TomEE, see here:
>> https://www.tomitribe.com/blog/tomee-configuration-techniques/
>>
>> Looking at the TomEE plugin's options though, it allows you to include a
>> system.properties at build time, but I can't seem to find a way to set it
>> at
>> runtime.
>>
>> Any ideas or alternatives?
>>
>>
>>
>> --
>> Sent from:
>> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>>

Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

exabrial12
Brilliant! I knew about setting system properties, but I didn't know ${var}
would pull from the unix environment!

What we're doing now is tomee-exec->deb package->sftp to ubuntu->freight
script adds to apt repo->apt installation on linux system. The deb script
creates a user/group after the artifact id, then installs a systemd unit to
control the process. We then just point systemd at an environment file with
all of the secret stuff:


[Unit]
Description=${project.artifactId} ${project.version}
After=network.target

[Service]
EnvironmentFile=/etc/default/${project.artifactId}
Type=simple
WorkingDirectory=/opt/${project.artifactId}
ExecStart=/usr/bin/java -jar
/opt/${project.artifactId}/${project.artifactId}-exec.jar
User=${project.artifactId}
Group=${project.artifactId}
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

Romain Manni-Bucau
side note: why tomee:exec and not tomee:build which was intended for that
case?

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 jeu. 22 nov. 2018 à 17:32, exabrial12 <[hidden email]> a écrit :

> Brilliant! I knew about setting system properties, but I didn't know ${var}
> would pull from the unix environment!
>
> What we're doing now is tomee-exec->deb package->sftp to ubuntu->freight
> script adds to apt repo->apt installation on linux system. The deb script
> creates a user/group after the artifact id, then installs a systemd unit to
> control the process. We then just point systemd at an environment file with
> all of the secret stuff:
>
>
> [Unit]
> Description=${project.artifactId} ${project.version}
> After=network.target
>
> [Service]
> EnvironmentFile=/etc/default/${project.artifactId}
> Type=simple
> WorkingDirectory=/opt/${project.artifactId}
> ExecStart=/usr/bin/java -jar
> /opt/${project.artifactId}/${project.artifactId}-exec.jar
> User=${project.artifactId}
> Group=${project.artifactId}
> RestartSec=10
> Restart=always
>
> [Install]
> WantedBy=multi-user.target
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

RE: TomEE Maven Plugin: Can conf/system.properties be externalized?

dimas
In reply to this post by Roberto Cortez
Hi guys,

I'm looking at the same thing but from perspective to run TomEE image in the K8's cluster.
The ${} replacement looks promising, especially when I found this thread http://tomee-openejb.979440.n4.nabble.com/how-con-figure-the-datasource-into-tomee-xml-using-docker-td4682533.html where Romain shared that it is possible to use env variables (not JVM properties) for substitution. From what I can see it is the most straightforward way to consume datasource configuration from K8's config map (by exposing config map values as env variables to the pod).

Unfortunately, I can't find any other documentation for this functionality and it makes me worry if it's not officially supported and may be removed in the future versions. Please clarify.

Also, if there is any other way to consume config map key/values in tomee.xml please let me know.

Cheers,
Dmitry  


-----Original Message-----
From: Roberto Cortez [mailto:[hidden email]]
Sent: Thursday, November 22, 2018 4:01 AM
To: [hidden email]
Subject: Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

I guess you want to hide user, password, connection, schema etc.

You could use variable replacement with ${} and pack the file in the jar and then just set the properties to replace like Romain mentioned. I think it should work,

Cheers,
Roberto

> On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]> wrote:
>
> Hello,
>
> You can always load system properties in setenv.sh before the server starts.
>
> If it is properties settable after tomee.xml is read you can set them
> in it and it supports <Import path=.... />
>
> Finally you can always plug a tomcat listener before tomee one and set
> the system properties the way you want peogrammatically.
>
> Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
>
>> We want to store the configuration for our datasources separate from
>> the distribution of the one-jar. If you haven't seen Jonathan
>> [Gallimore's] excellent blog post on configuration TomEE, see here:
>> https://www.tomitribe.com/blog/tomee-configuration-techniques/
>>
>> Looking at the TomEE plugin's options though, it allows you to
>> include a system.properties at build time, but I can't seem to find a
>> way to set it at runtime.
>>
>> Any ideas or alternatives?
>>
>>
>>
>> --
>> Sent from:
>> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>>

Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

Romain Manni-Bucau
You also have propertiesproviders and configurers for resources:
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
and
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
for an example of usage

Le jeu. 22 nov. 2018 19:25, Shultz, Dmitry <[hidden email]> a
écrit :

> Hi guys,
>
> I'm looking at the same thing but from perspective to run TomEE image in
> the K8's cluster.
> The ${} replacement looks promising, especially when I found this thread
> http://tomee-openejb.979440.n4.nabble.com/how-con-figure-the-datasource-into-tomee-xml-using-docker-td4682533.html
> where Romain shared that it is possible to use env variables (not JVM
> properties) for substitution. From what I can see it is the most
> straightforward way to consume datasource configuration from K8's config
> map (by exposing config map values as env variables to the pod).
>
> Unfortunately, I can't find any other documentation for this functionality
> and it makes me worry if it's not officially supported and may be removed
> in the future versions. Please clarify.
>
> Also, if there is any other way to consume config map key/values in
> tomee.xml please let me know.
>
> Cheers,
> Dmitry
>
>
> -----Original Message-----
> From: Roberto Cortez [mailto:[hidden email]]
> Sent: Thursday, November 22, 2018 4:01 AM
> To: [hidden email]
> Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
> externalized?
>
> I guess you want to hide user, password, connection, schema etc.
>
> You could use variable replacement with ${} and pack the file in the jar
> and then just set the properties to replace like Romain mentioned. I think
> it should work,
>
> Cheers,
> Roberto
>
> > On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]>
> wrote:
> >
> > Hello,
> >
> > You can always load system properties in setenv.sh before the server
> starts.
> >
> > If it is properties settable after tomee.xml is read you can set them
> > in it and it supports <Import path=.... />
> >
> > Finally you can always plug a tomcat listener before tomee one and set
> > the system properties the way you want peogrammatically.
> >
> > Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
> >
> >> We want to store the configuration for our datasources separate from
> >> the distribution of the one-jar. If you haven't seen Jonathan
> >> [Gallimore's] excellent blog post on configuration TomEE, see here:
> >> https://www.tomitribe.com/blog/tomee-configuration-techniques/
> >>
> >> Looking at the TomEE plugin's options though, it allows you to
> >> include a system.properties at build time, but I can't seem to find a
> >> way to set it at runtime.
> >>
> >> Any ideas or alternatives?
> >>
> >>
> >>
> >> --
> >> Sent from:
> >> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: TomEE Maven Plugin: Can conf/system.properties be externalized?

dimas
Thanks Romain, this is pretty cool functionality I can see the potential (for example ).

Just for the sake of completeness ('also' follows after 'yes':), is it still Ok to use env variables in ${}?

Cheers,
Dmitry  


-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: Thursday, November 22, 2018 11:01 AM
To: [hidden email]
Subject: Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

You also have propertiesproviders and configurers for resources:
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
and
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
for an example of usage

Le jeu. 22 nov. 2018 19:25, Shultz, Dmitry <[hidden email]> a écrit :

> Hi guys,
>
> I'm looking at the same thing but from perspective to run TomEE image
> in the K8's cluster.
> The ${} replacement looks promising, especially when I found this
> thread
> http://tomee-openejb.979440.n4.nabble.com/how-con-figure-the-datasourc
> e-into-tomee-xml-using-docker-td4682533.html
> where Romain shared that it is possible to use env variables (not JVM
> properties) for substitution. From what I can see it is the most
> straightforward way to consume datasource configuration from K8's
> config map (by exposing config map values as env variables to the pod).
>
> Unfortunately, I can't find any other documentation for this
> functionality and it makes me worry if it's not officially supported
> and may be removed in the future versions. Please clarify.
>
> Also, if there is any other way to consume config map key/values in
> tomee.xml please let me know.
>
> Cheers,
> Dmitry
>
>
> -----Original Message-----
> From: Roberto Cortez [mailto:[hidden email]]
> Sent: Thursday, November 22, 2018 4:01 AM
> To: [hidden email]
> Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
> externalized?
>
> I guess you want to hide user, password, connection, schema etc.
>
> You could use variable replacement with ${} and pack the file in the
> jar and then just set the properties to replace like Romain mentioned.
> I think it should work,
>
> Cheers,
> Roberto
>
> > On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]>
> wrote:
> >
> > Hello,
> >
> > You can always load system properties in setenv.sh before the server
> starts.
> >
> > If it is properties settable after tomee.xml is read you can set
> > them in it and it supports <Import path=.... />
> >
> > Finally you can always plug a tomcat listener before tomee one and
> > set the system properties the way you want peogrammatically.
> >
> > Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
> >
> >> We want to store the configuration for our datasources separate
> >> from the distribution of the one-jar. If you haven't seen Jonathan
> >> [Gallimore's] excellent blog post on configuration TomEE, see here:
> >> https://www.tomitribe.com/blog/tomee-configuration-techniques/
> >>
> >> Looking at the TomEE plugin's options though, it allows you to
> >> include a system.properties at build time, but I can't seem to find
> >> a way to set it at runtime.
> >>
> >> Any ideas or alternatives?
> >>
> >>
> >>
> >> --
> >> Sent from:
> >> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

dimas
To complete the for example (somehow typed it in my brain instead of the form:)

It looks like it will solve some problems by reading directly from the configmap (cdi custom config source would be awesome) instead of  relying on some yaml.

Cheers,
Dmitry
________________________________
From: Shultz, Dmitry <[hidden email]>
Sent: 22 November 2018 17:03:36
To: [hidden email]
Subject: RE: TomEE Maven Plugin: Can conf/system.properties be externalized?

Thanks Romain, this is pretty cool functionality I can see the potential (for example ).

Just for the sake of completeness ('also' follows after 'yes':), is it still Ok to use env variables in ${}?

Cheers,
Dmitry


-----Original Message-----
From: Romain Manni-Bucau [mailto:[hidden email]]
Sent: Thursday, November 22, 2018 11:01 AM
To: [hidden email]
Subject: Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

You also have propertiesproviders and configurers for resources:
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
and
https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
for an example of usage

Le jeu. 22 nov. 2018 19:25, Shultz, Dmitry <[hidden email]> a écrit :

> Hi guys,
>
> I'm looking at the same thing but from perspective to run TomEE image
> in the K8's cluster.
> The ${} replacement looks promising, especially when I found this
> thread
> http://tomee-openejb.979440.n4.nabble.com/how-con-figure-the-datasourc
> e-into-tomee-xml-using-docker-td4682533.html
> where Romain shared that it is possible to use env variables (not JVM
> properties) for substitution. From what I can see it is the most
> straightforward way to consume datasource configuration from K8's
> config map (by exposing config map values as env variables to the pod).
>
> Unfortunately, I can't find any other documentation for this
> functionality and it makes me worry if it's not officially supported
> and may be removed in the future versions. Please clarify.
>
> Also, if there is any other way to consume config map key/values in
> tomee.xml please let me know.
>
> Cheers,
> Dmitry
>
>
> -----Original Message-----
> From: Roberto Cortez [mailto:[hidden email]]
> Sent: Thursday, November 22, 2018 4:01 AM
> To: [hidden email]
> Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
> externalized?
>
> I guess you want to hide user, password, connection, schema etc.
>
> You could use variable replacement with ${} and pack the file in the
> jar and then just set the properties to replace like Romain mentioned.
> I think it should work,
>
> Cheers,
> Roberto
>
> > On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]>
> wrote:
> >
> > Hello,
> >
> > You can always load system properties in setenv.sh before the server
> starts.
> >
> > If it is properties settable after tomee.xml is read you can set
> > them in it and it supports <Import path=.... />
> >
> > Finally you can always plug a tomcat listener before tomee one and
> > set the system properties the way you want peogrammatically.
> >
> > Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
> >
> >> We want to store the configuration for our datasources separate
> >> from the distribution of the one-jar. If you haven't seen Jonathan
> >> [Gallimore's] excellent blog post on configuration TomEE, see here:
> >> https://www.tomitribe.com/blog/tomee-configuration-techniques/
> >>
> >> Looking at the TomEE plugin's options though, it allows you to
> >> include a system.properties at build time, but I can't seem to find
> >> a way to set it at runtime.
> >>
> >> Any ideas or alternatives?
> >>
> >>
> >>
> >> --
> >> Sent from:
> >> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: TomEE Maven Plugin: Can conf/system.properties be externalized?

Romain Manni-Bucau
Placeholders are a real feature so ko worry on them.
Not sure what you mean by cdi config source but microprofile is not tomee
mainstream (they still breaks api between each versions) and cdi hapoens
way too late for the container (tomee and cdi extension) but an app using
only injection you can do it using CDI utility class.

Le ven. 23 nov. 2018 03:23, Shultz, Dmitry <[hidden email]> a
écrit :

> To complete the for example (somehow typed it in my brain instead of the
> form:)
>
> It looks like it will solve some problems by reading directly from the
> configmap (cdi custom config source would be awesome) instead of  relying
> on some yaml.
>
> Cheers,
> Dmitry
> ________________________________
> From: Shultz, Dmitry <[hidden email]>
> Sent: 22 November 2018 17:03:36
> To: [hidden email]
> Subject: RE: TomEE Maven Plugin: Can conf/system.properties be
> externalized?
>
> Thanks Romain, this is pretty cool functionality I can see the potential
> (for example ).
>
> Just for the sake of completeness ('also' follows after 'yes':), is it
> still Ok to use env variables in ${}?
>
> Cheers,
> Dmitry
>
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[hidden email]]
> Sent: Thursday, November 22, 2018 11:01 AM
> To: [hidden email]
> Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
> externalized?
>
> You also have propertiesproviders and configurers for resources:
>
> https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/main/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProvider.java
> and
>
> https://github.com/apache/tomee/blob/8547f730b7c9fc085534a8f5d1f68340154d2cfe/container/openejb-core/src/test/java/org/apache/openejb/resource/heroku/HerokuDatabasePropertiesProviderResourceTest.java
> for an example of usage
>
> Le jeu. 22 nov. 2018 19:25, Shultz, Dmitry <[hidden email]> a
> écrit :
>
> > Hi guys,
> >
> > I'm looking at the same thing but from perspective to run TomEE image
> > in the K8's cluster.
> > The ${} replacement looks promising, especially when I found this
> > thread
> > http://tomee-openejb.979440.n4.nabble.com/how-con-figure-the-datasourc
> > e-into-tomee-xml-using-docker-td4682533.html
> > where Romain shared that it is possible to use env variables (not JVM
> > properties) for substitution. From what I can see it is the most
> > straightforward way to consume datasource configuration from K8's
> > config map (by exposing config map values as env variables to the pod).
> >
> > Unfortunately, I can't find any other documentation for this
> > functionality and it makes me worry if it's not officially supported
> > and may be removed in the future versions. Please clarify.
> >
> > Also, if there is any other way to consume config map key/values in
> > tomee.xml please let me know.
> >
> > Cheers,
> > Dmitry
> >
> >
> > -----Original Message-----
> > From: Roberto Cortez [mailto:[hidden email]]
> > Sent: Thursday, November 22, 2018 4:01 AM
> > To: [hidden email]
> > Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
> > externalized?
> >
> > I guess you want to hide user, password, connection, schema etc.
> >
> > You could use variable replacement with ${} and pack the file in the
> > jar and then just set the properties to replace like Romain mentioned.
> > I think it should work,
> >
> > Cheers,
> > Roberto
> >
> > > On 22 Nov 2018, at 05:42, Romain Manni-Bucau <[hidden email]>
> > wrote:
> > >
> > > Hello,
> > >
> > > You can always load system properties in setenv.sh before the server
> > starts.
> > >
> > > If it is properties settable after tomee.xml is read you can set
> > > them in it and it supports <Import path=.... />
> > >
> > > Finally you can always plug a tomcat listener before tomee one and
> > > set the system properties the way you want peogrammatically.
> > >
> > > Le mer. 21 nov. 2018 23:51, exabrial12 <[hidden email]> a écrit :
> > >
> > >> We want to store the configuration for our datasources separate
> > >> from the distribution of the one-jar. If you haven't seen Jonathan
> > >> [Gallimore's] excellent blog post on configuration TomEE, see here:
> > >> https://www.tomitribe.com/blog/tomee-configuration-techniques/
> > >>
> > >> Looking at the TomEE plugin's options though, it allows you to
> > >> include a system.properties at build time, but I can't seem to find
> > >> a way to set it at runtime.
> > >>
> > >> Any ideas or alternatives?
> > >>
> > >>
> > >>
> > >> --
> > >> Sent from:
> > >> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
> > >>
> >
> >
>