Bug 1323310 - Integration of KJAR Artifact Resolution with Profiles and Fabric Maven Proxy
Summary: Integration of KJAR Artifact Resolution with Profiles and Fabric Maven Proxy
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Fuse Integration
Version: 6.2.0
Hardware: All
OS: All
urgent
high
Target Milestone: CR1
: ---
Assignee: Mario Fusco
QA Contact: Jiri Petrlik
Petr Penicka
URL:
Whiteboard:
Depends On:
Blocks: 1325016
TreeView+ depends on / blocked
 
Reported: 2016-04-01 20:34 UTC by Matthew Robson
Modified: 2020-03-27 20:06 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
: 1325016 (view as bug list)
Environment:
Last Closed: 2020-03-27 20:06:33 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Matthew Robson 2016-04-01 20:34:37 UTC
Description of problem:

This issue relates to BRMS Integration with Fabric and more specifically to how Drools is loading KJARs from Maven.

In this case, drools does not use the fabric maven proxy or any of the configured maven repo's in fabric to load a KJAR.  It uses 3 potential methods;

1) a drools CUSTOM_SETTINGS_PROPERTY pointing to a settings.xml
2) the 'userHome + "/.m2/settings.xml"'
3) the artifact is in 'userHome + "/.m2/repository"'

This is because the KJAR is loaded by KIE specific logic and not as bundle loaded through a feature or profile.  Because fabric customers manage resources and configurations through the fabric, this represents additional configuration that is hard to track and maintain.

A KJAR is current loaded as follows;

1) InternalKieModule kieModule = (InternalKieModule) getRepository().getKieModule(releaseId);
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieServicesImpl.java#L114

2) return getKieModule(releaseId, null);
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieRepositoryImpl.java#L92

3) kieModule = loadKieModuleFromMavenRepo(releaseId, pomModel);
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieRepositoryImpl.java#L105

4) return getInternalKieScanner().loadArtifact(releaseId, pomModel);
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieRepositoryImpl.java#L129

5) return internalKieScanner; -> InternalKieScanner 
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieRepositoryImpl.java#L133

6) KieRepositoryScannerImpl implements InternalKieScanner
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/KieRepositoryScannerImpl.java

7) getArtifactResolver();
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/KieRepositoryScannerImpl.java#L118

8) mavenRepository = MavenRepository.getMavenRepository();
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/ArtifactResolver.java#L52

9) defaultMavenRepository = new MavenRepository( defaultAether );
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/MavenRepository.java#L78

10) remoteRepositoriesForRequest = initRemoteRepositoriesForRequest();
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/MavenRepository.java#L67

11) final MavenRepositoryConfiguration repositoryUtils = getMavenRepositoryConfiguration();
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/MavenRepository.java#L87

12) return MavenSettings.getMavenRepositoryConfiguration();
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/MavenRepository.java#L70

13) return SettingsHolder.mavenConf;
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/embedder/MavenSettings.java#L49

14) private static final MavenRepositoryConfiguration mavenConf = new MavenRepositoryConfiguration(settings);
https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/embedder/MavenSettings.java#L35


In terms of artifact resolution, everything happens based on the configured maven settings above in step 14.

For USER settings, it's looking for: private static File initUserSettingsFile()

1) CUSTOM_SETTINGS_PROPERTY
or 
2) File userSettingsFile = new File( userHome + "/.m2/settings.xml" );

Otherwise it returns null.

Then it initializes settings: private static Settings initSettings(File userSettingsFile)

1) Is user settings wasn't null;
request.setUserSettingsFile( userSettingsFile ); 

2) Look for M2_HOME - set global settings
File globalSettingsFile = new File( mavenHome + "/conf/settings.xml" );

3) If user.home is set, sets the local repository:
settings.setLocalRepository( userHome + "/.m2/repository" );


Finlly;

15) All of the repos from the found settings are initialized:

this.extraRepositories = initExtraRepositories();
this.remoteRepositoriesForRequest = initRemoteRepositoriesForRequest();
this.artifactRepositoriesForRequest = initArtifactRepositories();

https://github.com/droolsjbpm/drools/blob/6.3.x/kie-ci/src/main/java/org/kie/scanner/MavenRepositoryConfiguration.java#L43


Version-Release number of selected component (if applicable):

BRMS 6.2.x
BRMS 6.3

How reproducible:

100%

Steps to Reproduce:
1. Deploy an application which loads a KJAR and only configure the maven repository or settings.xml in fabric.

Actual results:

KJAR artifact is unable to be found.


Expected results:

Should resolve and download the correct artifact.

Additional info:

In the customers eyes, in a fabric environment, drools should plug into fabric and leverage the already configured remote / local repositories configured within the environment.

Comment 17 David Virgil 2016-04-18 12:48:15 UTC
Talked with Mario.

On newer version of drools, this should be fixed. 

It is required to export a property kie.maven.settings.custom that contains the url of the settings.xml

Comment 18 Jiri Petrlik 2016-04-20 13:42:48 UTC
Fixing commit [1] is not present on 6.4.x branch of droolsjbpm/drools repository.

[1] https://github.com/droolsjbpm/drools/pull/719/commits/449b5d2de838c8de29868706c982e4865c2fce47

Comment 19 Edson Tirelli 2016-04-20 16:00:27 UTC
Discussed this with Lazarotti and the expectation is to have this fix for 6.3.1, not 6.3.0.

Comment 20 Alessandro Lazarotti 2016-04-20 16:04:45 UTC
6.3.1 and 6.2.3 (by Bug 1325016)

Comment 21 Edson Tirelli 2016-04-20 16:18:05 UTC
After further discussion with Alessandro on IRC, it will be complicated if we have the fix in 6.2.3 but not in 6.3.0. So we will include the fix in 6.3.0. 

Resetting the flags.

Comment 22 Mario Fusco 2016-04-20 16:33:44 UTC
Cherry-picked to branch 6.4.x with https://github.com/droolsjbpm/drools/commit/d04eb3b97

Comment 25 Mario Fusco 2016-05-02 15:11:54 UTC
Fixed on master by https://github.com/droolsjbpm/drools/commit/88fe6fa70

Comment 26 Mario Fusco 2016-05-02 15:14:26 UTC
Cherry-picked to 6.4.x branch with https://github.com/droolsjbpm/drools/commit/b79b4efb8


Note You need to log in before you can comment on or make changes to this bug.