Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1072601

Summary: Deploy the artifact and then have it retrieve by another application.
Product: [Retired] JBoss BRMS Platform 6 Reporter: David Tse <dtse>
Component: Business CentralAssignee: Mario Fusco <mfusco>
Status: CLOSED CURRENTRELEASE QA Contact: Marek Baluch <mbaluch>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.0CC: kverlaen, mbaluch, rrajasek
Target Milestone: ER2   
Target Release: 6.0.1   
Hardware: i586   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 19:57:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Program to simulate loading artifact by an application during start up none

Description David Tse 2014-03-04 21:17:06 UTC
Created attachment 870647 [details]
Program to simulate loading artifact by an application during start up

Description of problem:
Client has a requirement to deploy the artifact and then have it retrieve by another application to reduce start up time associated with rule compilation.  The sample code from kie-ci modulde only work if you deploy the artifact and retrieve it from the same java program.  


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

How reproducible:
Reproduce every time


Steps to Reproduce:
1. Make change to KieModuleMavenTest using information provided in "Additional info"
2. Build and run KieModuleMavenTest.  One will see expected output and artifact deployed to local maven repository.
3. Run program, ReloadTest, to simulate loading artifact by an application during start up.  Error display in actual result is seen.

Actual results:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.RuntimeException: Cannot find KieModule: org.kie:maven-test:1.0.1-Final
	at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:108)
	at org.kie.scanner.ReloadTest.main(ReloadTest.java:19)


Expected results:
KBase1
 wagon http use multi threaded http connection manager maxPerRoute 20, max total 40

Additional info:
OOTB code has issues.  Need to perform the following changes:
    	/*
        final KieServices ks = new KieServicesImpl() {

            @Override
            public KieRepository getRepository() {
                return new KieRepositoryImpl(); // override repository to not store the artifact on deploy to trigger load from maven repo
            }
        };
        */
        KieServices ks = KieServices.Factory.get();

Comment 3 Mario Fusco 2014-03-05 14:58:39 UTC
I think there's a problem in the provided ReloadTest class: it looks for a version "1.0.1-Final" while KieModuleMavenTest creates a "1.0-SNAPSHOT". Using the right version number in the ReloadTest fixes the problem.

Comment 4 David Tse 2014-03-05 15:53:05 UTC
The code that I attached use 1.0.1-Final.
If you comment out the deploy part and try to load jar already in the repository, junit test fail.

    @Test
    public void testKieModuleFromMavenNoDependencies() throws Exception {
    	/*
        final KieServices ks = new KieServicesImpl() {

            @Override
            public KieRepository getRepository() {
                return new KieRepositoryImpl(); // override repository to not store the artifact on deploy to trigger load from maven repo
            }
        };
        */
        KieServices ks = KieServices.Factory.get();
        ReleaseId releaseId = ks.newReleaseId("org.kie", "maven-test", "1.0.1-Final");
        /*
        InternalKieModule kJar1 = createKieJar(ks, releaseId, true, "rule1", "rule2");
        String pomText = getPom(releaseId, null);

        File pomFile = new File(System.getProperty("java.io.tmpdir"), MavenRepository.toFileName(releaseId, null) + ".pom");
        try {
            FileOutputStream fos = new FileOutputStream(pomFile);
            fos.write(pomText.getBytes());
            fos.flush();
            fos.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        MavenRepository.getMavenRepository().deployArtifact(releaseId, kJar1, pomFile);
        */
        
        KieContainer kieContainer = ks.newKieContainer(releaseId);
        KieBaseModel kbaseModel = ((KieContainerImpl) kieContainer).getKieProject().getDefaultKieBaseModel();
        assertNotNull("Default kbase was not found", kbaseModel);
        String kbaseName = kbaseModel.getName();
        System.out.println(kbaseName);
        assertEquals("KBase1", kbaseName);
    }

Comment 5 Mario Fusco 2014-03-05 17:22:43 UTC
It works for me both on master and 6.0.x branch. 
I believe this problem has been already fixed.

Comment 8 Marek Baluch 2014-03-13 19:11:22 UTC
Verified on 6.0.1.ER2.

All of the test cases passed OK after I updated them based on the instructions in this BZ.