property substitution in deployment descriptors - open-liberty

Wildfly replaces variables in deployment descriptors with System Properties
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>${Queue}</activation-config-property-value>
https://access.redhat.com/solutions/160093
Has Open Liberty a similar feature for deployment descriptors (web.xml, ejb-jar.xml)?

Related

What is the difference in setting a property in catalina.bat file than in setenv.bat file

I wanted to set application.properties file outside of the war file while deploying on the tomcat and here is my observation
1. When i was setting jvm property as
spring.config.location=C:/Users/user_name/Documents/Softwares/apache-tomcat-8.0.53-windows-x64/apache-tomcat-8.0.53/webapps/config/
in the catalina.properties file.. it was not understood by the tomcat and threw runtime error in reading one location property that is defined in the application.properties file (basically it couldn't resolve the location)
but when i set the profile as below
spring.profiles.active=dev
and the profile was picked up correctly.
so, what is the big difference in setting these two properties. also i believe these are these are jvm properties that spring boot take as environment properties in runtime. am i correct here?
2. when i set the same spring.config.location in a new file named setenv.sh as below
set JAVA_OPTS=-Dspring.config.location=C:/Users/user_name/Documents/Softwares/apache-tomcat-8.0.53-windows-x64/apache-tomcat-8.0.53/webapps/config/
meanind setting the property as the java system variable, this time spring boot application picked it up correctly.
so, what is the big difference in setting a property through catalina.properties file than to setenv.bat file.
Kindly enlighten.
A properties file is not a text file. It has its own syntax. See Javadoc of class java.util.Properties [1][2] for a reference.
E.g. ':' is escaped as ':', '\' is escaped as '\'.
(Escaping ':' is important in the key of a property. I am not sure that it is required in the value. Maybe you have some other errors in your value.)
You can configure org.apache.catalina.startup.VersionLoggerListener (in server.xml) to log the actual values of System properties, as seen by Tomcat and by your web applications. The attribute is logProps="true" [3].
setenv.sh or setenv.bat script generates options for the command line of java program.
The catalina.properties file is processed by Tomcat bootstrap process. It happens rather early (before Tomcat classloader hierarchy is built), but for some properties this timing difference is important.
For example, the properties that configure java.util.logging Logging API should be configured in setenv.sh and not in the catalina.properties file.

Disabling Gradle daemon in a specific project

I'd like to build certain projects without the use of of Gradle daemon. I've read that this can be done either by command-line argument --no-daemon or by changing Gradle properties under .gradle/. I need to disable it for just some of the projects I build under the root project though.
Is it possible via settings.gradle/build.gradle settings or am I better off making custom build script?
You can simply add org.gradle.daemon=false to a gradle.properties file in the project root folder.
The daemon documentation mainly talks about disabling the daemon altogether on a machine but the gradle properties documentation indicates that the location where a property / value pair is declared is irrelevant, they are sourced from different location, with overwrite rules.

How to specify JVM Parameters inside Spring Boot Project when executed with init.d

I have a Spring Boot project that I'm running as an executable jar started as an init.d service on Linux.
I understand I can create a .conf file with the same name as the jar file to specify JVM parameters. However, I would ideally like to "hard code" some parameters so there is no risk of the .conf file being missing. This is a real risk as each deployment will have a different jar name because of the version number.
Also I know I can set the environment variable JAVA_OPTS, but I'm not sure how to do this if I'm launching the Spring Boot as a init.d service using a symlink to the jar file.
Lastly I know I can replace the init.d script completely using the embeddedLaunchScript parameter, but I fell this overkill for what I want to accomplish and would want updates to the script in further releases.
Is there a way to specify JVM parameters in the Maven plugin or some other programmatic method?
Alternatively is there a way to hard code a static CONF file name? Looking at the embeddedLaunchScriptProperties it looks like confFolder can the folder, but not the name of the .conf file.
As of Spring boot 2.0, you can set the inlinedConfScript property of the build plugin. You can now reference a file that includes the appending or overwriting the JAVA_OPTS variable before the application starts. More details can be found in the Spring Documentation.

Websphere: Configuring shared library using deployment descriptors

I have a ear file and it references few jar files at runtime. We created a shared library using websphere admin console. But for referencing the shared library we are looking for a way to configure the shared library using deployment descriptors. Any help on how to do it, which deployment descriptor file to modify to specify the shared lib?
Thanks,
The short answer is by using the websphere-specific deployment.xml descriptor inside EARs META-INF.
You should put that file inside the following dir tree META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml, then locate the classloader section and set the shared library inside classloader tag as follows:
<classloader xmi:id="Classloader_1454339476980" mode="PARENT_FIRST">
<libraries libraryName="myshared lib" sharedClassloader="true"/>
</classloader>
In my opinion, the easiest is to use Installed Optional Packages.

how to set java class loader PARENT_LAST

i have a spring mvc web application that I need to change the class loader on. I need to change the class loader to be equal to PARENT_LAST. I am using WAS 6.1 and already have a jacl script from a previous web application I can copy to do the job.
In the last application Apache ant was used and what they did was to make the deploy dependent on running the jacl script.
In my new web application I am using maven install to create a war file and am deploying that war file to my application server.
How can I set the class loader to be PARENT_LAST using maven? I know how to do it in the console but if there was a way to do it using scripting that would be nice.
Also will this setting be placed somewhere in the war file so that on deploy of the application the setting will be picked up. This question comes from my lack of understanding of how jacl scripts work?
thanks
If you are only deploying the WAR file itself you can't control this, but if you have your WAR file in an EAR file you can use the deployment.xml solution. The deployment.xml file would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1347529484613">
<deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1347544766353" startingWeight="99" warClassLoaderPolicy="SINGLE">
<modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1347543866613" startingWeight="1" uri="YourWebApp.war" classloaderMode="PARENT_LAST"/>
<classloader xmi:id="Classloader_1347543866613" mode="PARENT_LAST"/>
</deployedObject>
</appdeployment:Deployment>
Once you are done all you need to do is to add the file in the correct location of your EAR project build assuming you are using src/main/application that would be src/main/application/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml and build the EAR using Maven as normal.
During server deployment this will be picked up by WAS.
AFAIK there is no way to preconfigure WAR for PARENT_LAST during assembly. Classloading policy is specified during deployment, thus the way of setting it depends on how application is deployed.
Changing the policy using the script is straightforward. Scripts are run using wsadmin tool. The Jython snippet below does the job. It can easily be converted to Jacl.
dep = AdminConfig.getid('/Deployment:app_name/')
depObject = AdminConfig.showAttribute(dep, 'deployedObject')
classldr = AdminConfig.showAttribute(depObject, 'classloader')
AdminConfig.modify(classldr, [['mode', 'PARENT_LAST']])
AdminConfig.save()
Websphere uses deployment.xml file to govern deployment setting of each module in an ear file. You can change the classloader setting in deployment.xml at the following path:
/MyTestEAR/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml
I do not know how you can configure that in Maven.

Resources