Bug 1217295 - [ENG] (6.1.z) KieScanner not scanning custom maven repository from web app (Cool Store)
Summary: [ENG] (6.1.z) KieScanner not scanning custom maven repository from web app (C...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.1.0
Hardware: x86_64
OS: Mac OS
high
high
Target Milestone: CR1
: ---
Assignee: Mario Fusco
QA Contact: Marek Winkler
URL:
Whiteboard:
Depends On: 1208442
Blocks: 1220521 1220522
TreeView+ depends on / blocked
 
Reported: 2015-04-30 03:54 UTC by Alessandro Lazarotti
Modified: 2020-03-27 18:34 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1208442
Environment:
Last Closed: 2020-03-27 18:34:15 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Alessandro Lazarotti 2015-04-30 03:54:18 UTC
Description of problem:
Project setup with full configuration of external maven repo (/tmp/maven-repo) here:

https://github.com/jbossdemocentral/brms-coolstore-demo/tree/v2.7

In project/brms-cool-store/* is web app with BRMSUtils class setting up KieScanner for watching maven repo for dynamic rule updates.

In support/* you will find standalone.xml with system property for customer maven configuration. This settings.xml file is found also in support/* and copied to installation, it points to /tmp/maven-repo and has profile to be able to set this repo to 'updatePolicy' as 'always'.

The web app is built during installation on developers .m2 repo and settings, deployed into brms server.

Start brms server, login (erics / jbossbrms1!), build & deploy project to see version 2.0.0 appear in /tmp/maven-repo/com/redhat/coolstore/2.0.0/*

Start web app at http://localhost:8080/brms-cool-store, note starting KieScanner in logs.

Add item less than $25 to cart and should see shipping cost $2.99.

Back in business-central, update decision table pricing tier 1 from 2.99 to 1.99, save, build and deploy project (either as version 2.0.0 again, or as  2.1.0 or as 3.0.0, does not matter), watch logs as KieScanner is set to scan after 10 seconds. 

Check web app, tier 1 pricing stays 2.99.

Note: if not using custom maven settings with repo in /tmp/maven-repo, will see the scanner appear for .m2 repository, but no updates done in the web app. tier 1 pricing remains 2.99.

PS. With 6.1.CR2 updates I will test this project and report finding here too.


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

How reproducible:
Install project as above, add brms 6.0.3 installer jar to installs directory and run init.sh. Follow steps to reproduce above.

Steps to Reproduce:
1.see above.
2.
3.

Actual results:
KieScanner not scanning custom maven repo. Also not updating dynamic rule changes when deployed to web app using scanner.

Expected results:
KieScanner showing in log 10s after deployment a scan and picking up the rule changes in next run of the web app without re-deployment of web app.


Additional info:
This is a business use case, thus the complete project setup instead of a unit test reproducer. Mario requested assignment of this task.

--- Additional comment from JBoss Product and Program Management on 2015-04-02 05:40:17 EDT ---

Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

--- Additional comment from Eric D. Schabell on 2015-04-02 08:22:03 EDT ---

Follow up testing on this, tried two cases:

1. setup as project is currently, custom maven configuration with repo in /tmp/maven-repo

2. remove custom maven settings from standalone.xml (single system property), run with .m2 settings and default local maven repsository.


Results:
1. scanner does not show in logs beyond starting up, never scans the custom repository.

2. scanner works for initial 2.0.0 artifact, so changing rules and re-deploy as 2.0.0 new artifact, scanner picks this up in the log file and the web app works with the new rule settings. Bump the project artifact to any higher number (example, 2.1.0 or 3.0.0) then scanner show picking up the new number in the log, but web app not picking up rule changes in new artifact.

--- Additional comment from Marek Winkler on 2015-04-03 03:50:23 EDT ---

Eric,

I see that you have the following repository declaration in settings.xml:

<id>jboss-bpm-suite-repo</id>
<name>JBoss BPM Suite Maven Repository</name>
<url>file://tmp/maven-repo</url>
...

Could you please try with the url pointing to business-central Maven repo servlet, such as:

<url>http://localhost:8080/business-central/maven2</url>

Your original approach is using business-central's local maven repository (i.e. a place where business-central does something like 'mvn install'), but you should be downloading artifacts from the "remote" repository provided by business-central (i.e. where business-central does 'mvn deploy').

You might also need to setup credentials for that server in settings.xml, such as:

  <servers>
    <server>
      <id>kie-wb-m2-repo</id>
      <username>someUser</username>
      <password>somePassword123</password>
      <!-- the configuration below might not be required -->
      <configuration>
        <wagonProvider>httpclient</wagonProvider>
        <httpConfiguration>
          <all>
            <usePreemptive>true</usePreemptive>
          </all>
        </httpConfiguration>
      </configuration>
    </server>
  </servers>

I am not completely sure if this can cause the problems that you reported, but we can at least eliminate possible cause.

Moreover, a few KieScanner bugs have been fixed in 6.1, so if you could try with 6.1, it would be great. I;ll try to verify your scenario as well, but I might not be able to get to it until Monday.

Thanks!

--- Additional comment from Marek Winkler on 2015-04-03 03:55:50 EDT ---

Eric,

just a quick note about [1]. I think that you should not start KieScanner in the bean constructor, as the bean lifecycle is managed by the container (and the constructor might be actually called multiple times). 

I'd recommend using a @PostConstruct method for doing the initialization, and also not to forget stopping KieScanner in a @PreDestroy method to avoid KieScanner starting a background thread which is not properly disposed.


[1] https://github.com/jbossdemocentral/brms-coolstore-demo/blob/v2.7/projects/brms-coolstore-demo/src/main/java/com/redhat/coolstore/util/BRMSUtil.java

--- Additional comment from Eric D. Schabell on 2015-04-08 09:59:16 EDT ---

(In reply to Marek Winkler from comment #4)
> Eric,
> 
> just a quick note about [1]. I think that you should not start KieScanner in
> the bean constructor, as the bean lifecycle is managed by the container (and
> the constructor might be actually called multiple times). 
> 
> I'd recommend using a @PostConstruct method for doing the initialization,
> and also not to forget stopping KieScanner in a @PreDestroy method to avoid
> KieScanner starting a background thread which is not properly disposed.
> 
> 
> [1]
> https://github.com/jbossdemocentral/brms-coolstore-demo/blob/v2.7/projects/
> brms-coolstore-demo/src/main/java/com/redhat/coolstore/util/BRMSUtil.java
>
Giving this a try... thanks!

--- Additional comment from Mario Fusco on 2015-04-10 14:29:41 EDT ---

I have reproduced this issue and found what is causing it. The problem is not in the KieScanner, it is working as expected and indeed when a new version of the kjar is deployed it correctly finds and installs it and prints something like:

16:26:05,129 INFO  [org.kie.api.builder.KieScanner] (Timer-1) The following artifacts have been updated: {com.redhat:coolstore:2.2.0=com.redhat:coolstore:jar:2.3.0}

The problem is that (at least in the reproducer provided by Eric) when a file is changed inside business-central (I tried with a decision table, but suspect it happens the same also for other types of file) it is written directly in the MemoryFileSystem of the KieModule stored in the KieContainer.

On 6.0.3 this is done by the org.guvnor.common.services.builder.Builder.visitPaths() method on line 557.

That implies that when the new jar is downloaded from the maven repo and compared with what is stored in the FileSystem of the running KieProject it finds them identical since they've been changed in the same way in both places and then the incremental compilation just doesn't do anything.

Michael, at the moment I don't know how limited this issue is, but I think that this is happening in Eric's example because business-central and his webapp are running inside the same application server. Also I didn't try with more recent version but I suspect that we have the same problem also on master. Finally it is not clear to me if the bug is in guvnor or in drools (or more probably in how they interact). Could you please give a try to Eric's use case and then ping me so we could figure out together how to fix this?

Thanks,
Mario

--- Additional comment from  on 2015-04-13 06:55:03 EDT ---

Mario and I had a chat and the issue is suspected to relate to KieContainer's use of KieRepo.getKieModule( currentReleaseId ). Mario proposed changing KieContainer to hold a reference to it's active KieModule(s) rather than look it up.

--- Additional comment from Mario Fusco on 2015-04-13 08:40:46 EDT ---

I was wrong when I wrote that when a file is changed inside business-central it is written directly in the same MemoryFileSystem used by the project installed into the KieContainer.

Conversely the problem was caused by the fact that every time a file is saved inside business-central it performs an incremental compilation of the project to notify the user if the modified file eventually caused some compilation failure. This incremental compilation also installs the modified project inside the KieRepository that is a singleton inside the running JVM and then shared by business-central and the webapp. 

When the KieScanner triggered a project update, the kmodule considered as the current one (and then compared to the other newly installed in the maven repository) is taken from the KieRepository, but for what said before the incremental compilation made by business-central already changed it in the meanwhile. For this reason the comparison between the 2 kmodules didn't find any difference and then terminated without doing anything.

Fixed on master by https://github.com/droolsjbpm/drools/commit/ee7dd7c91

Comment 3 Mario Fusco 2015-05-04 12:10:18 UTC
Cherry-picked to 6.2.x branch with https://github.com/droolsjbpm/drools/commit/7ea681432

Comment 4 Marek Winkler 2015-05-25 13:42:29 UTC
Verified with BRMS 6.1.1.CR1.

I have tried Eric's use case and it now works: 

- I have started BRMS business-central and brms-coolstore application, 

- added an item less than $25 to the cart,

- updated the rule in Guided Decision Table in Business-central, increased project version to 2.0.1, and built the project

- added an item less than $25 to the cart, the shipping cost has been updated according to the rule change,

- repeated once again (updated to version 2.0.2) to verify KieScanner won't stop scanning.

Eric, I must say that brms-coolstore-demo app looks really good! I am adding just a couple of things I came across when making it work with BRMS 6.1.1.CR1 and EAP 6.4:

- it seems that property placeholders (${jboss.home.dir}, in particular) does not work anymore in EAP 6.4 - I had to replace the placeholder with the actual absolute path in standalone.xml (when defining org.uberfire.nio.git.dir and other system properties). We ran into the same problem a while ago and it seems that this is an expected EAP behaviour.

- please be aware that the Arquillian version you are using in brms-coolstore-demo app is not compatible with BRMS 6.1 (the imported BOM overwrites some aether versions which results in weird linkage errors). I have worked around the problem by removing Arquillian tests from your app, but an Arquillian/Shrinkwrap upgrade should help.

- another required update is to remove dependencies on Drools/jBPM EAP modules from jboss-deployment-structure.xml, since they are no longer used in the product.

- I would also suggest using a product BOM, such as [1] (link to internal productization repo will follow, 6.1.1 not released yet).

Comment 6 Eric D. Schabell 2015-05-26 07:17:51 UTC
(In reply to Marek Winkler from comment #4)

See some inline comments below:


> Verified with BRMS 6.1.1.CR1.
> 
> I have tried Eric's use case and it now works: 
> 
> - I have started BRMS business-central and brms-coolstore application, 
> 
> - added an item less than $25 to the cart,
> 
> - updated the rule in Guided Decision Table in Business-central, increased
> project version to 2.0.1, and built the project
> 
> - added an item less than $25 to the cart, the shipping cost has been
> updated according to the rule change,
> 
> - repeated once again (updated to version 2.0.2) to verify KieScanner won't
> stop scanning.
> 
> Eric, I must say that brms-coolstore-demo app looks really good! I am adding
> just a couple of things I came across when making it work with BRMS
> 6.1.1.CR1 and EAP 6.4:
>
> - it seems that property placeholders (${jboss.home.dir}, in particular)
> does not work anymore in EAP 6.4 - I had to replace the placeholder with the
> actual absolute path in standalone.xml (when defining
> org.uberfire.nio.git.dir and other system properties). We ran into the same
> problem a while ago and it seems that this is an expected EAP behaviour.
>
This is odd as I have yet to see this behavior on any of my demo projects (they all use this) on products 6.1 and EAP 6.4. Will keep an eye out on this, but for osX have yet to encounter it.

 
> - please be aware that the Arquillian version you are using in
> brms-coolstore-demo app is not compatible with BRMS 6.1 (the imported BOM
> overwrites some aether versions which results in weird linkage errors). I
> have worked around the problem by removing Arquillian tests from your app,
> but an Arquillian/Shrinkwrap upgrade should help.
>
I am not sure which version you were working with, but the current master has been updated some time ago: https://github.com/jbossdemocentral/brms-coolstore-demo/pull/27, tagged v2.6 and above have this fix.

 
> - another required update is to remove dependencies on Drools/jBPM EAP
> modules from jboss-deployment-structure.xml, since they are no longer used
> in the product.
>
This was also corrected after 6.1 release, modules are gone in EAP 6.4, see master branch and tagged v2.8 release.
 
> - I would also suggest using a product BOM, such as [1] (link to internal
> productization repo will follow, 6.1.1 not released yet).
>
This will happen when it hits production, I do test the link you provide me internally before it goes public, but that is not in the repo until we publicly make it avail.

Thanks much for the testing and work on this, big feature for the field to showcase!


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