How to integrate Keycloak 7 with Spring Boot 2 - java

I want to setup the Keycloak adapter (v7.0.0) for a Spring Boot 2.1.x backend. Somehow this doesn't work as expected and mvn clean spring:boot-run shows errors.
To get a playground i cloned this working repo. After a successful build with the old versions of Keycloak and Spring Boot i changed the dependencies (and versions).
For the POM i included:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>7.0.0</version>
</dependency>
and
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>7.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
and provide properties via the application.yml file:
keycloak:
auth-server-url: http://127.0.0.1:8081/auth/
resource: persons-app
realm: PersonRealm
public-client: true
principal-attribute: preferred_username
This follows Keycloaks docs.
The result is an error showing:
Description:
Parameter 1 of method setKeycloakSpringBootProperties in org.keycloak.adapters.springboot.KeycloakBaseSpringBootConfiguration required a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' that could not be found.
Action:
Consider defining a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' in your configuration.
This is already defined. So thats the problem. I don't know if there are certain restriction of what versions of Keycloak and Spring Boot work together. Maybe someone could explain what i missed here or what versions to set. Thanks!

The same question has been asked here: Issues running example keycloak spring-boot app I'll point you to the other one for more information about the issue and a temporary workaround.
At the moment there is no ultimate solution, it's an issue with the Keycloak Spring Boot Adapter 7.0.0. If you use the previous version of the adapter (6.0.1) then it will work fine, even if the Keycloak server is running version 7.0.0 (you just don't get the new features introduced in the new adapter).

Related

Springboot application start up fails and missing logs when using azure.keyvault.secret.property-sources

I am trying to migrate my springboot application written in kotlin to azure.
I added spring-cloud-azure-starter-keyvault-secrets:4.5.0 dependency in my app, and added below configurations to application.properties.
my.secret=${my-azure-secret}
spring.cloud.azure.keyvault.secret.property-source-enabled=true
spring.cloud.azure.keyvault.secret.property-sources[0].endpoint=<my-vault>.vault.azure.net/
After I add this, the spring boot initialization doesn't work any more and i can't find any logs.
log.info { "Log before springboot initialize" }
SpringApplication(MyApplication::class.java).run(*args)
log.info { "Log after springboot initialize" }
So, Log before springboot initialize is logged, and after that nothing happens (or I can't find any logs afterwards)
I already verified it is not related to any logback settings because if I remove the property spring.cloud.azure.keyvault.secret.property-sources[0].endpoint from application.properties, it boots up properly.
(I also tried to add the additional dependency spring-cloud-azure-dependencies:4.5.0 )
Any clues/hints what is happening and how to resolve it ?
Thanks.
Here I was able to boot the spring application using the same dependencies.
But here I used the latest version of spring-cloud-azure-starter-keyvault-secrets i.e. 5.0.0 also my spring boot version is 3.0.2
my dependencies:
<dependencies>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/com.azure.spring/spring-cloud-azure-starter-keyvault-secrets -->
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-starter-keyvault-secrets</artifactId>
<version>5.0.0</version>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency></dependencies>
Also I use windows so instead of my_azure_secret instead of the my-azure-secret
output:

Getting error while using Jira rest java client

I am trying to use jira-rest-java-client-api in my Jira server plugin.
I am using following versions,
Jira - 7.13.0
jira-rest-client. Version - 5.2.0
In my pom I have added jira-rest-java-client-api and jira-rest-java-client-core dependency like,
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
I have added scope as provided so when I am building project using maven (atlas-mvn clean package) there is no error, but when I am trying to start the Jira server, my plugin is not added to Jira.
Getting following error
Unable to resolve 185.0: missing requirement [185.0]
osgi.wiring.package;
(osgi.wiring.package=com.atlassian.jira.rest.client.api)
Also, If I have not added the scope as provided then getting an error for banned dependencies while building using atlas-mvn clean package.
Any help would be appreciated, Thanks.

Connect SMB endpoint with Camel v3 and the camel-jcifs from camel-extra

I have the following maven versions in my pom.xml (among others):
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-jcifs</artifactId>
<version>2.25.2</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
Camel spring-boot version = 3.7.0 and I want to connect to a SMB endpoint like this:
smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=ThePassWorD&filter=#csvFileFilter
I read the Camel 3 Migration Guide and found nothing regarding this camel-extras.
When trying to connect, I get an error like the password option is not supported anymore:
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=xxxxxx&filter=#csvFileFilter due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{password=ThePassWorD}]
The actual documentation link google found many times, seems dead.
From Maven central, there is no version 3.x of the lib camel-jcifs and I am wondering if the lib is still compatible with Camel 3.x.x, otherwise is there another alternative with Camel 3?
I also tried to downgrade the camel-jcifs to 2.24.3 with the same error.
Camel-extras is a separated project from the Apache Camel. There is some work in place in the camel-extra repository to support camel 3[1], but it is still to be completed and there is no release in sight.
[1] https://github.com/camel-extra/camel-extra/commit/f028dfdfaa467958c58abea0d604f8fe2f17be04
There is now a pull request to add camel-jcifs to the 3.x version:
https://github.com/camel-extra/camel-extra/pull/39
You might also get my fork and build it yourself:
https://github.com/bebbo/camel-extra *
It got merged and is in the official repository:
https://github.com/camel-extra/camel-extra
To use it with quarkus, you have to convert some List types to arrays.

How to use JIRA REST client library?

I need to use JIRA REST client version 5.2.0 or higher. Cloud JIRA does not work with an earlier version of the client.
In my pom.xml file I have the following dependencies:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-app</artifactId>
<version>5.2.1</version>
</dependency>
When I building the project, I get an exception like this:
Failed to execute goal on project XXXXXXXXX: Could not resolve dependencies for project XXXXXXXXXX:jar:XXXX: Failed to collect dependencies at com.atlassian.jira:jira-rest-java-client-core:jar:5.2.1: Failed to read artifact descriptor for com.atlassian.jira:jira-rest-java-client-core:jar:5.2.1: Could not find artifact com.atlassian.platform:platform:pom:3.1.7 in MY_REPO (http://XXXXXXXXXX/repository/maven-public) -
com.atlassian.platform:platform:pom:3.1.7 is not listd at mvnrepository. There are versions 3.1.12 and 3.1.17, but not 3.1.7. Someone told me that version 3.1.7 might have had a security-related bug and was therefore removed by Atlassian.
Both jira-rest-java-client-app and jira-rest-java-client-core are children of jira-rest-java-client-parent, which uses version 3.1.7 of the platform:
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-parent</artifactId>
<version>5.2.1</version>
<packaging>pom</packaging>
[...]
<properties>
<platform.version>3.1.7</platform.version>
[...]
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atlassian.platform</groupId>
<artifactId>platform</artifactId>
<version>${platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
5.2.1 seems to be the latest version of both jira-rest-java-client-core and jira-rest-java-client-app.
How can I use the JIRA REST client (for programmatically creating issues in Cloud JIRA) when it uses a version of the library that is not available any more?
I tried to exclude the platform in the dependencies and to specify another version in depencency management sections. This did not help.
The accepted answer is absolutely correct. A concrete example on how to be able to get the artifacts from https://packages.atlassian.com, for anyone coming here looking for answers, would be to include a repository element for it in your pom, like so:
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://packages.atlassian.com/maven/repository/public</url>
</repository>
</repositories>
A WORD OF CAUTION, THOUGH: The jira-rest-java-client was created for use with Jira Server, not Jira Cloud
Some months ago, Atlassian made changes to Jira Cloud which made it impossible to use the jira-rest-java-client (JRJC) for things such as searches in Jira Cloud. As far as I can tell they don't intend to make the JRJC library compatible with Jira Cloud anymore. Atlassian has provided an article on how to generate a REST client for Jira Cloud, but as far as I know, they haven't created any Jira Cloud libraries similar to the JRJC.
If you have a look at the repository
https://packages.atlassian.com/mvn/maven-external
from atlassian, you find the desired artifact com.atlassian.platform:platform:pom:3.1.7there. Since this repository seems to be from atlassian, I see no reason to believe that they recommend not to use the version.
This is also discussed in https://community.atlassian.com/t5/Jira-questions/Jira-rest-java-client-core-5-1-and-fugue-2-7-0-breaks-build/qaq-p/1151091

Forcing maven spring boot project to use older version of a dependency instead of a new version from another dependency

I'm running in to a problem where I cannot start a spring boot server due to the same problem listed in this question:
How to set up Spring Boot and log4j2 properly?
I am encountering this scenario because the spring boot project has a dependency on a jar that includes elasticsearch, which includes a new version of slf4j that isn't compatible with spring boot
I tried the recommended solution by implementing every exclusion in the elasticsearch project dependency definition possible, but for some reason the new version keeps being picked up. I cannot seem to force the spring boot project to ignore the logging packages used by the elasticsearch project.
Here is my pom for the spring-boot project, see the dependency for problematic.project.import : http://pastebin.com/Yeq2qk9Y
Here is the pom for the project that is being imported into the spring boot project: http://pastebin.com/gknmf6Tt
The error I am getting is:
Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(Lorg/apache/logging/log4j/core/config/ConfigurationSource;)Lorg/apache/logging/log4j/core/config/Configuration;
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadConfiguration(Log4J2LoggingSystem.java:165)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadDefaults(Log4J2LoggingSystem.java:148)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:75)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
Any tips on how to get this issue cleared? Is this possible for two versions of this set of libraries to be loaded, each module ignorant to the version they don't need?
You can exclude the cyclic dependencies by using the <exclusions> tag in your pom.xml like this:
<dependency>
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>sample.ProjectE</groupId> <!-- Exclude Project-E from Project-B -->
<artifactId>Project-E</artifactId>
</exclusion>
</exclusions>
</dependency>
You should exclude the cyclic dependency of the newer version from the dependency which is having it and that way only the older version will be loaded and not both.
Here is the link for more information:
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

Categories

Resources