Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-754

KieScanner crash while erroneously trying to resolve non necessary dependencies

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Out of Date
    • Affects Version/s: 6.2.0.Final
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      As per issue description.

      Show
      As per issue description.

      Description

      Overview

      Given kie.maven.settings.custom to force KIE libraries to reference only an internal nexus repo without Maven-central proxy just for the kjar of the rules.
      Given a KieContainer created with ReleaseId, trying to create a KieScanner would fail if the kjar of the release ID contain parametrized versions in the POM, because the KiScanner does not substitute the parameter, and moreover it tries to resolve them anyway even if those dependencies are not actually needed because having scope=test.
      Even changing the internal nexus repo, althought may not be feasible, for Maven-central proxy (http://repo1.maven.org/maven2/) would fail in resolving other dependencies.

      keypoint: have a way to instruct KIE KieContainer AND KieScanner, to reference just-and-only an internal Nexus repo just and only for the KJar for the rules, without having to internally proxy or double-check Maven central, please?
      Could you kindly advise accordingly, please?

      Details

      Given a kjar artifact named kiescanner-testandversionissue-rules with the following pom (extract):

      <properties>
      	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      	<drools-version>6.2.0.Final</drools-version>
      	<slf4j-version>1.7.2</slf4j-version>
      	<junit-version>4.11</junit-version>
      </properties>
        
      <dependencyManagement>
      <dependencies>
      	<dependency>
      		<groupId>org.drools</groupId>
      		<artifactId>drools-bom</artifactId>
      		<type>pom</type>
      		<version>${drools-version}</version>
      		<scope>import</scope>
      	</dependency>
      </dependencies>
      </dependencyManagement>
      
      <dependencies>
      	
      <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-compiler</artifactId>
        <scope>test</scope>
      </dependency>
      <dependency>
      	<groupId>junit</groupId>
      	<artifactId>junit</artifactId>
      	<version>${junit-version}</version>
      	<scope>test</scope>
      </dependency>
      <dependency>
      	<groupId>org.slf4j</groupId>
      	<artifactId>slf4j-log4j12</artifactId>
      	<version>${slf4j-version}</version>
      	<scope>test</scope>
      </dependency>
      
      </dependencies>
      

      Please notice the dependencies are parametrized in the versions, and moreover are not really required for runtime because scope=test.

      Now assume this kjar is deployed to a maven repo, like a nexus repository.

      Now given a client application havign kie.maven.settings.custom to force KIE libraries to reference only an internal nexus repo:

      ReleaseId rId = kieServices.newReleaseId( "com.acme", "kiescanner-testandversionissue-rules", "RELEASE" );
      KieContainer kieContainer = kieServices.newKieContainer( rId );
      LOG.info("kieContainer exists. {}", kieContainer);
      LOG.info("Now about to create kieScanner...");
      KieScanner kScanner = kieServices.newKieScanner( kieContainer );
      kScanner.start( KIE_SCANNER_INTERVAL );
      

      This code will fail with the following in the log (extract):

      INFO  [com.acme.kiescanner_testandversionissue_client.App] (main) kieContainer exists. org.drools.compiler.kie.builder.impl.KieContainerImpl@1229a2b7
      INFO  [com.acme.kiescanner_testandversionissue_client.App] (main) Now about to create kieScanner...
      
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: GET /nexus/content/groups/public/org/slf4j/slf4j-log4j12/$%7Bslf4j-version%7D/slf4j-log4j12-$%7Bslf4j-version%7D.pom HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56971<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56971<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: GET /nexus/content/groups/public/junit/junit/$%7Bjunit-version%7D/junit-$%7Bjunit-version%7D.pom HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56972<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56972<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: GET /nexus/content/groups/public/org/drools/drools-bom/$%7Bdrools-version%7D/drools-bom-$%7Bdrools-version%7D.pom HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56973<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56973<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: GET /nexus/content/groups/public/org/slf4j/slf4j-log4j12/$%7Bslf4j-version%7D/slf4j-log4j12-$%7Bslf4j-version%7D.jar HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56974<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:56974<->127.0.0.1:8081 closed
      WARN  [org.kie.scanner.MavenRepository] (main) Unable to resolve artifact: org.slf4j:slf4j-log4j12:${slf4j-version}
      

      We can notice two issues:

      • the ${...-version} is not substitued while trying to resolve these artifacts on the nexus repo, the URL contains the ${...-version} literally
      • actually why the KieScanner try to resolve them given the dependencies are scope=test ?

      Also, even changing the internal nexus repo for Maven-central proxy (http://repo1.maven.org/maven2/) by:
      nexus connect with default user admin/admin123, add proxy repo http://repo1.maven.org/maven2/), go to group "public" and add the proxy, erase local-user .m2 drools-bom to force re-resolution,
      And re-running the client application again, would instead crash in resolving the following:

      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: HEAD /nexus/content/groups/public/org/jboss/dashboard-builder/dashboard-builder-bom/6.2.0.Final/dashboard-builder-bom-6.2.0.Final.pom HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:57598<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:57598<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Sending request: HEAD /nexus/content/groups/public/org/dashbuilder/dashbuilder-bom/0.2.1.Final/dashbuilder-bom-0.2.1.Final.pom HTTP/1.1
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Receiving response: HTTP/1.1 404 Not Found
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:57599<->127.0.0.1:8081 closed
      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] (main) Connection 0.0.0.0:57599<->127.0.0.1:8081 closed
      

      Could you kindly advise accordingly, please?

      Conclusion

      Have a way to instruct KIE KieContainer AND KieScanner, to reference just-and-only an internal Nexus repo just and only for the KJar for the rules, without having to proxy Maven central
      Please notice:
      IFF in the custom kie-settings.xml I do remove the mirror definition, the problem WILL be that KIE libraries will try to resolve the kiescanner-testandversionissue-rules kjar in both Maven central and the local repo, and this is not advisable as the rule package name should go straight and just to the internal maven repo.

      Steps to reproduce

      I will attach reproducer containing

      • kiescanner-testandversionissue-rules
      • kiescanner-testandversionissue-client
      • standalone nexus containing just and only repo for the kjar rules without any Maven-central proxy

      you can use the last for standalone test, otherwise you can deploy the rule and reference to another disposable internal Nexus repo by also updating the custom kie-settings.xml in the client app.

        Attachments

          Activity

            People

            Assignee:
            mfusco Mario Fusco
            Reporter:
            tari_manga Matteo Mortari
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: