Setting Microprofile active profile using mp.config.profile not working in Liberty - open-liberty

Im currently trying to run a microprofile open liberty project as a jar.
java -jar myapp.jar -Dmp.config.profile=test
The app runs but is not picking the configuration values from microprofile-config-test.properties
instead is using values from microprofile-config.properties
Thank you in advance

Enabling MicroProfile Config 2.0 Feature
First, you enable in your server.xml via:
<featureManager>
<feature>mpConfig-2.0</feature>
<!--
Or enable all MicroProfile 4.0 features via:
<feature>microProfile-4.0</feature>
-->
</featureManager>
Installing GA version of Open Liberty
Default version
By default, liberty-maven-plugin will install the latest version of Open Liberty.
Installing a specific GA version
You can install a specific version of Open Liberty (e.g. version 21.0.0.3 which contains the GA support for MicroProfile 4.0 features such as MicroProfile Config 2.0) via liberty-maven-plugin config:
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.3.4</version>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>21.0.0.3</version>
</assemblyArtifact>
</configuration>
</plugin>
Installing a beta version of Open Liberty with liberty-maven-plugin
UPDATE: (I originally posted this answer when the MicroProfile Config 2.0 feature was still in beta, but for reference I'll move this to a new section below.)
Here is how to install a specific version of the Open Liberty runtime beta, using the liberty-maven-plugin:
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.3.4</version>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty.beta</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>21.0.0.3-beta</version>
<type>zip</type>
</assemblyArtifact>
</configuration>
</plugin>

Related

Missing dependency while upgrading AEM 6.5.1 to 6.5.10

I am upgrading AEM 6.5.1 (Service pack 1) to AEM 6.5.10 (Service pack 10). For this I installed SP10 in AEM as well updated the uber-jar version to 6.5.10 in my source code POM.xml file.
I see that in the OSGI console, my bundle is in Installed and not Active state. This is because certain dependencies (which before the update were not present) are missing. I have been able to get those dependencies, except one.
com.microsoft.schemas.office.powerpoint -- Cannot be resolved
I am unable to find any JARs online that fixes this issue. I tried Apache POI but no success. Does anyone know what this dependency is and where I can get it?
Thanks!
If you are not using it at all, you can exclude it.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>
javax.inject;version=0.0.0,
!sun.misc;resolution=optional,!javax.persistence,!com.sun.jdi.*,
!com.microsoft.schemas.office.powerpoint,*
</Import-Packages>

Spring cloud Contract verifier baseClassMapping no longer working in 3.0.0

The below config works fine perfectly in spring-cloud-starter-contract-verifier 2.2.4.RELEASE. But with 3.0.0 it throws the error below, it is not deprecated in the docs. Does anyone know if the behavior is changed ?
.pom file
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<baseClassForTests>com.mycompany.selectservice.integrationtest.</baseClassForTests>
<baseClassMappings>
<baseClassMapping>
<contractPackageRegex>.*select.*</contractPackageRegex>
<baseClassFQN>com.mycompany.selectservice.integrationtest.SelectBaseTest</baseClassFQN>
</baseClassMapping>
</baseClassMappings>
</configuration>
</plugin>
SelectTest.validate_contract_0:33 » IllegalState You haven't configured a MockMvc.
My spring boot version is 2.2.4.RELEASE, So it means that spring-cloud-starter-contract-verifier 3.0.0 cannot be used with spring boot 2.2.4.release?
As described in our project page (https://spring.io/projects/spring-cloud) you have to use Boot 2.4 to use Spring Cloud Contract. Also, that functionality does work - most likely you're using some old imports or you're using JUnit4 (the default now is JUnit5).

I want maven to use JRE system Library [JavaSE 1.8] always while creating new maven quickstart project

I have jdk/jre 1.8 installed on my windows system. In Eclipse whenever I create a quick-start maven project, the project gets created with JRE System Library[J2SE 1.5]. I am fed up of this problem tried to change the execution environment by doing right click on above JRE library-properties and changing the execution environment to 1.8 but again if I update this maven project, the JRE system library goes back again to J2SE 1.5, I also tried changing the compiler compliance to 1.8 which was earlier set to java 10 and also did adding the source and target tag with version 1.8 inside plugin tag of pom.xml but this was also a temporary solution. As when I create a new maven project it sets the default JRE system Library[J2SE 1.5]. Please Provide me with a permanent fix where whenever i create a new maven project, it should be created with JRE System Library[JavaSE 1.8].
Add the following to pom.xml to configure which JDK version you would want to use:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
or the followings:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
It is because when you do Maven --> Update Project in Eclipse , Eclipse 's maven plugin will use what you define in pom.xml to update the setting of the eclipse project. If you don't specify above settings , the default is to use JDK 1.5 (before maven-compiler-plugin version 3.8.0) or JDK 1.6 (3.8.0+)
Basically I want maven to use JDK 1.8 by default. So that i wont need
to change pom.xml contents again and again while making a new project
If you do not want to change any settings related JDK version in pom.xml after creating a project , you may consider to create your own archetype to fully customize what pom.xml looks like after creating an project. Or a more simple way is to search some Java8 archetype created by others and simply use it such as this.
Refer this for how to create a Maven project with an specific archetype using Eclipse. You may probably need to click "Add Archetype" to configure the require information when you use that archetype for the first time. For example , for this archetype, you have to configure the following for the 1st time:
archetypeGroupId=pl.org.miki
archetypeArtifactId=java8-quickstart-archetype
archetypeVersion=1.0.0

How to fix AEM 6.3 - Maven Archetype 12 "No DS descriptor found" errors?

We have created an AEM 6.3 project using Maven Archetype 12. We have not yet written any code and are just trying to build the empty project imported into Eclipse.
We are getting the error which is mentioned in the documentation:
https://sling.apache.org/documentation/development/ide-tooling.html#why-do-i-get-an-error-about-no-ds-descriptor-found-at
No DS descriptor found at path target/classes/OSGI-INF/com.xxxxxxx.core.filters.LoggingFilter.xml
The documentation states, "One often-occuring situation is that a Maven project using the maven-scr-plugin generates the descriptors outside of target/classes, typically in target/scr-plugin-generated. To fix this, make sure that you're using the maven-scr-plugin 1.15.0 or newer and that you have not set a custom outputDirectory."
Unfortunately, this does not appear to be the case with our out-of-the-box generated project. The descriptors are not being generated at all. Upgrading maven-scr-plugin to 1.15.0 or even 1.26.0 does not change the symptoms.
What is the proper fix for this issue?
Environment Version Info
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T12:39:06-07:00)
Maven home: C:\usr\apache-maven-3.5.0\bin\..
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_131\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I can reproduce the error consistently. All steps are captured in this 2-minute video
You see this error when there is no implementation of Declarative Services in OSGI framework. Make sure you see Apache Felix Declarative Services (org.apache.felix.scr) bundle active and running in your felix console.
Alternatively (recommended), you can use the official annotations from OSGI R6. According to felix docs, development of the Apache Felix SCR Plugin is in maintenance mode. You don't require mvn-scr-plugin if you are using the official osgi annotation.
This article should give you a jumpstart in using official annotations.
Adding an empty <Export-Package></Export-Package> worked initially, but then broke when I started writing code. Long-term fix is some combination of the following:
Don't use the newer OSGI #Component annotations, continue to use #SlingServlet instead.
Add this dependency
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.12.0</version>
</dependency>
Add this plug-in
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.26.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<phase>compile</phase>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
Not sure if this made a difference, but also upgrade to Sling IDE Tools 1.2.0
The problem goes away if these two empty entries are added to the core/pom.xml:
<Export-Package></Export-Package>
<Private-Package></Private-Package>

TypeNotPresentExceptionProxy error at integration-test with maven-failsafe-plugin spring-boot 1.4

I'm getting ArrayStoreException: TypeNotPresentExceptionProxy when running integration-test with maven-failsafe-plugin and spring-boot 1.4.
You can see this error if you run joinfaces-example with
mvn -Pattach-integration-test clean install
I realized that the error does not occur if I change spring-boot-maven-plugin to run at pre-integration-test phase instead of package one.
More, this error started when I upgraded spring boot to 1.4. No error occurs if I change jsf-spring-boot-parent version to 2.0.0 which uses spring boot 1.3 version.
I actually found the answer in Spring Boot 1.4 release notes, short answer is that maven-failsafe-plugin is not compatible with Spring Boot 1.4's new executable layout. Full explanation below :
As of Failsafe 2.19, target/classes is no longer on the classpath and
the project’s built jar is used instead. The plugin won’t be able to
find your classes due to the change in the executable jar layout.
There are two ways to work around this issue:
Downgrade to 2.18.1 so that you use target/classes instead
Configure the spring-boot-maven-plugin to use a classifier for the
repackage goal. That way, the original jar will be available and used
by the plugin. For example :
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
An alternative is documented here: https://github.com/spring-projects/spring-boot/issues/6254
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<!--
Make failsafe and spring-boot repackage play nice together,
see https://github.com/spring-projects/spring-boot/issues/6254
-->
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
</configuration>
</plugin>
This worked better for me, because when I used the "exec" solution, Spring failed to find my configuration files when starting the container. Which could probably be fixed by adding some further configuration parameters, I suppose, but this solution works "out of the box" for me.

Resources