How to access BRMS maven repository?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.0.0
- 6.4.0
- Red Hat JBoss BPM Suite (BRMS)
- 6.0.0
- 6.4.0
Issue
- I get the following WARNING when I press "Build&Deploy" in business-central
[WARNING] Failure to transfer com.example:my-facts:1.0.0-SNAPSHOT/maven-metadata.xml from https://localhost:8080/business-central/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of guvnor-m2-repo has elapsed or updates are forced. Original error: Could not transfer metadata com.example:my-facts:1.0.0-SNAPSHOT/maven-metadata.xml from/to guvnor-m2-repo (https://localhost:8080/business-central/maven2/): Unauthorized (401)
- I want to access a remote BRMS rule project from one of my local java maven project.I have added below tags in pom.xml of local java project
<repository>
<id>guvnor-m2-repo</id>
<name>Guvnor M2 Repo</name>
<url>http://10.10.10.10:8080/business-central/maven2/</url>
</repository>
...
<!-- rules project in Guvnor is required -->
<dependency>
<groupId>org.kie.example</groupId>
<artifactId>project1</artifactId>
<version>1.0.0</version>
</dependency>
Also having username/password in ~/.m2/settings.xml
<servers>
<server>
<id>guvnor-m2-repo</id>
<username>admin</username>
<password>password1!</password>
</server>
</servers>
When we try to build local maven project it fails with below exception:
[ERROR] Failed to execute goal on project TestApp: Could not resolve dependencies for project com.sample:TestApp:jar:1.0.0: Failed to collect dependencies at org.kie.example:project1:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for org.kie.example:project1:jar:1.0.0-SNAPSHOT: Could not transfer artifact org.kie.example:project1:pom:1.0.0-SNAPSHOT from/to guvnor-m2-repo (http://10.10.10.10:8080/business-central/maven2/): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project TestApp: Could not resolve dependencies for project com.sample:TestApp:jar:1.0.0: Failed to collect dependencies at org.kie.example:project1:jar:1.0.0-SNAPSHOT
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:220)
. . .
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.sample:TestApp:jar:1.0.0: Failed to collect dependencies at org.kie.example:project1:jar:1.0.0-SNAPSHOT
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:167)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
... 22 more
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at org.kie.example:project1:jar:1.0.0-SNAPSHOT
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:292)
...
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.kie.example:project1:jar:1.0.0-SNAPSHOT
...
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.kie.example:project1:pom:1.0.0-SNAPSHOT from/to guvnor-m2-repo (http://10.10.10.10:8080/business-central/maven2/): Not authorized , ReasonPhrase:Unauthorized.
...
. . .
- How to import jars from remote maven repository of BRMS 6 server to local maven project ?
Resolution
It is either needed to turn on pre-emptive authentication for the repository server by
<server>
<id>guvnor-m2-repo</id>
<username>admin</username>
<password>admin</password>
<configuration>
<wagonProvider>httpclient</wagonProvider>
<httpConfiguration>
<all>
<usePreemptive>true</usePreemptive>
</all>
</httpConfiguration>
</configuration>
</server>
or set Authorization HTTP header with Base64 encoded credentials
<server>
<id>guvnor-m2-repo</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<!-- Base64-encoded "admin:admin" -->
<value>Basic YWRtaW46YWRtaW4=</value>
</property>
</httpHeaders>
</configuration>
</server>
NOTE: "guvnor-m2-repo" is a fixed ID name which is automatically generated by business-central.
Root Cause
- When you create a new project in business-central, a pom.xml is created automatically.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>kjar</packaging>
<name>test</name>
...
<repositories>
<repository>
<id>guvnor-m2-repo</id>
<name>Guvnor M2 Repo</name>
<url>http://localhost:8080/business-central/maven2/</url>
</repository>
</repositories>
...
</project>
So you have to configure authentication for "guvnor-m2-repo" as written in Resolution.
- The authentication configuration details is reported to 2 BZs 1 2. This is not a bug but a configuration matter.
https://bugzilla.redhat.com/show_bug.cgi?id=1059584
2: https://bugzilla.redhat.com/show_bug.cgi?id=1066258
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.