Discussion:
TomEE Maven Plugin: Can conf/system.properties be externalized?
exabrial12
2018-11-21 22:50:56 UTC
Permalink
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
Romain Manni-Bucau
2018-11-22 05:42:17 UTC
Permalink
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.
Post by 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]
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Roberto Cortez
2018-11-22 12:00:52 UTC
Permalink
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
Post by 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.
Post by 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]
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
exabrial12
2018-11-22 16:31:56 UTC
Permalink
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
Romain Manni-Bucau
2018-11-22 16:33:42 UTC
Permalink
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>
Post by 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
[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
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Shultz, Dmitry
2018-11-22 18:24:52 UTC
Permalink
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:***@yahoo.com.INVALID]
Sent: Thursday, November 22, 2018 4:01 AM
To: ***@tomee.apache.org
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
Post by 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.
Post by exabrial12
We want to store the configuration for our datasources separate from
the distribution of the one-jar. If you haven't seen Jonathan
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-11-22 19:01:10 UTC
Permalink
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
Post by Shultz, Dmitry
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-----
Sent: Thursday, November 22, 2018 4:01 AM
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
Post by Romain Manni-Bucau
Hello,
You can always load system properties in setenv.sh before the server
starts.
Post by Romain Manni-Bucau
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.
Post by exabrial12
We want to store the configuration for our datasources separate from
the distribution of the one-jar. If you haven't seen Jonathan
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Shultz, Dmitry
2018-11-23 01:03:36 UTC
Permalink
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:***@gmail.com]
Sent: Thursday, November 22, 2018 11:01 AM
To: ***@tomee.apache.org
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
Post by Shultz, Dmitry
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-----
Sent: Thursday, November 22, 2018 4:01 AM
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
Post by Romain Manni-Bucau
Hello,
You can always load system properties in setenv.sh before the server
starts.
Post by Romain Manni-Bucau
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.
Post by exabrial12
We want to store the configuration for our datasources separate
from the distribution of the one-jar. If you haven't seen Jonathan
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?
--
http://tomee-openejb.979440.
Shultz, Dmitry
2018-11-23 02:16:28 UTC
Permalink
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 <***@kaltire.com>
Sent: 22 November 2018 17:03:36
To: ***@tomee.apache.org
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:***@gmail.com]
Sent: Thursday, November 22, 2018 11:01 AM
To: ***@tomee.apache.org
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
Post by Shultz, Dmitry
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-----
Sent: Thursday, November 22, 2018 4:01 AM
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
Post by Romain Manni-Bucau
Hello,
You can always load system properties in setenv.sh before the server
starts.
Post by Romain Manni-Bucau
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.
Post by exabrial12
We want to store the configuration for our datasources separate
from the distribution of the one-jar. If you haven't seen Jonathan
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-11-23 05:40:17 UTC
Permalink
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.
Post by Shultz, Dmitry
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
________________________________
Sent: 22 November 2018 17:03:36
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-----
Sent: Thursday, November 22, 2018 11:01 AM
Subject: Re: TomEE Maven Plugin: Can conf/system.properties be
externalized?
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
Post by Shultz, Dmitry
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-----
Sent: Thursday, November 22, 2018 4:01 AM
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
Post by Romain Manni-Bucau
Hello,
You can always load system properties in setenv.sh before the server
starts.
Post by Romain Manni-Bucau
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.
Post by exabrial12
We want to store the configuration for our datasources separate
from the distribution of the one-jar. If you haven't seen Jonathan
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?
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Loading...