How to best configure data source in a Payara Micro uber jar application?

136 views
Skip to first unread message

Guilherme Mussi

unread,
May 4, 2018, 3:30:05 AM5/4/18
to Payara Forum
Dear community,

I am relatively new to pure Java EE (having always worked with Embedded Jetty Uber Jar approach before), and I have a question:

I am packaging my application using the outputUberJar command.
This application will be deployed to a cloud (AWS EBS) and will have the database settings (url, username, password) as Environment Variables available at runtime.

How can I use these environment variables to configure a data source for my PersistenceUnit?
Also: would it be better to use the programmatic API instead of an uber jar in this scenario?

Thank you very much for your reply and guidance.

With kind regards,
Guilherme


Steve Millidge

unread,
May 4, 2018, 4:24:16 AM5/4/18
to Payara Forum
In your datasource annotation or deployment descriptor you can use the syntax ${ENV=variable} where variable is the environment variable to use. See https://docs.payara.fish/documentation/payara-server/server-configuration/var-substitution/types-of-variables.html in the 
documentation.

Martin Charlesworth

unread,
Sep 19, 2018, 6:46:10 AM9/19/18
to Payara Forum
Hi Steve, is there any way @DataSourceDefinition properties can be combined with microprofile config, so that instead of explicitly saying it must come from a system property or the environment, it can come from any config source? cheers,
Martin

Steve Millidge

unread,
Sep 20, 2018, 7:42:34 AM9/20/18
to Payara Forum
There is a PR for this capability now  https://github.com/payara/Payara/pull/3136 note though it is limited to ConfigSources specified at the server level. It is another order of magnitude more complex to deliver it for ConfigSources also packaged in the application in a general way although we are working on that as well.

Steve
Reply all
Reply to author
Forward
0 new messages