Is there any way to configure the order in which the OpenLiberty container launches deployed web apps (deployed WARs)? I need a particular web app to be ready before other web apps are fully loaded. Thanks.
Asked
Active
Viewed 175 times
0
-
1Out of the box, no. However, there are ways this can be accomplished by deployment scripting. Could you describe the use case a bit more? I suspect there is a better alternative design which won't require apps to come up in a certain order. – Andy Guibert Jan 15 '18 at 02:26
-
Ok, here is the use case: I want to take advantage of OrientDB as an embedded server in OL for my web app, according to this: http://orientdb.com/docs/3.0.x/internals/Embedded-Server.html . Basically I will wrap the server in a @ApplicationScoped bean and deploy it in OL as a separate web app. So, when I deploy my web app, I want the server to be up and running. I can, of course have some kind of polling, but in general I do not know which web app will OL bring online first, hence my question. – Hristo Stoyanov Jan 15 '18 at 03:14
-
And btw, I could bundle the server and my app in war, but then every re-deployment of my web app during development will lead to OrientDB server restart (slow) – Hristo Stoyanov Jan 15 '18 at 03:24
-
Ideally we could configure a custom resource in server.xml that gets registered in JNDI so that all applications could use it -- there is an RFE for that here: https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=42819 Besides that, does the app change frequently enough that re-deploys are an issue? If you have an app w/ nothing but the DB in it, seems fine. Also, every time the Liberty server restarts does the DB go away? – Andy Guibert Jan 15 '18 at 03:28
-
Actually, looking at the Liberty documentation more closely, I believe you could accomplish this with
and – Andy Guibert Jan 15 '18 at 03:41config elements. The configuration is documented here: https://www.ibm.com/support/knowledgecenter/SSD28V_9.0.0/com.ibm.websphere.liberty.autogen.core.doc/ae/rwlp_config_jndiReferenceEntry.html -
Thank Andy, I see that one can deploy an object factory, which can create and OriendDB server instance and bind it to a JNDI name. Since this is global, all web apps can reference it, correct? 3 issues though: 1/ How do I get notified when the OL server goes down, so I can close the server (very important!), 2/ When stopping the OL server, I want the web apps to shut down first, the OrientDB server - last, and 3/ The example uses the Resource annotation, does OL support Resorce or just Inject? – Hristo Stoyanov Jan 15 '18 at 07:09
-
Getting back to the original idea of not using OL proprietary JNDI factories.. How about a separate web app with a single ApplicationScoped CDI Producer with well defined PostConstruct PreDestroy lifecycles for managing the OrientDB embedded server ... Can I export the OriendDB into the global OL JNDI space somehow from that CDI bean, so that other web app can use it? – Hristo Stoyanov Jan 15 '18 at 07:13
-
Andy, after seelping over this, another, even more portable option seems to be available - using JCA: https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_jca_config_dep.html – Hristo Stoyanov Jan 15 '18 at 18:40
-
Not sure how JCA will solve this problem unless you have an RA for OrientDB. Or plan to write one. But if you had one, yes, the dependency of your apps on that RA would cause them to wait until the resource is available before completing start. – F Rowe Jan 15 '18 at 23:28
-
There are 2 OrientDB jca adaptors already, I just need to upgrade the code, here is the newer one: https://ops4j1.jira.com/wiki/spaces/ORIENT/pages/65241104/JCA+Resource+Adapter The question is can I use JCA and JNDI in OpenLiberty, since these are outside the MicroProfile specs? – Hristo Stoyanov Jan 16 '18 at 01:43
-
Yes, JCA is part of the Java EE spec and JDBC is part of Jave SE spec, both of which Liberty supports in addition to MicroProfile. – F Rowe Jan 16 '18 at 13:33