0

I have the code below to load my KieContainer

String url = "http://X.X.X.X:8081/repository/maven-releases/com/some/company/rules-config/0.0.2/rules-config-0.0.2.jar";
    KieServices kieServices = KieServices.Factory.get();
    kieServices.getResources().newUrlResource(url);
    ReleaseId releaseId = kieServices.newReleaseId(GROUP_ID, "rules-config", "0.0.2-SNAPSHOT");
    KieContainer kContainer = kieServices.newKieContainer(releaseId);
    KieScanner kScanner = kieServices.newKieScanner(kContainer);
    kScanner.start(2000L);

Currently the application loads the jar file at the system startup. But when i push a new jar of the same version the scanner is not loading the jar based on timestamp.

The same code as below

    KieServices kieServices = KieServices.Factory.get();
    ReleaseId releaseId = kieServices.newReleaseId(GROUP_ID, "rules-config", "0.0.2-SNAPSHOT");
    KieContainer kContainer = kieServices.newKieContainer(releaseId);
    KieScanner kScanner = kieServices.newKieScanner(kContainer);
    kScanner.start(2000L);

update: settings.xml (in the local machines m2 directory)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<!--<localRepository>path to some directory.eg d:\repository</localRepository> -->
<mirrors>
    <mirror>
        <id>nexus</id>
        <name>somecompany</name>
        <url>http://X.X.X.X:8081/repository/maven-public</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>
<servers>
    <server>
        <id>nexus</id>
        <username>XXXXXX</username>
        <password>XXXXXX</password>
    </server>
</servers>
<profiles>
    <profile>
        <id>development</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>snapshots-repo</id>
                <url>http://X.X.X.X:8081/repository/maven-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>interval:1</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

Works fine when i do a local build and install. The rules are getting refreshed based on the timestamp though the jars are of same version.

Is there anything missing in my understanding ? How exactly does the KieScanner work ?

Does the KieScanner work only when the jar is installed in to the local maven repository on the same system as the server ?

Praveen Kumar
  • 1,515
  • 1
  • 21
  • 39

1 Answers1

0

Make sure you have added kie-ci artifact in classpath your application. KieScanner is maven based so it will always lookup for artifacts in local maven repository and in remote maven repository. If you want to specify location of remote maven repository then you can configure repository in setting.xml and pass this setting.xml while deploying your application using below application: -Dkie.maven.settings.custom=/path/to/settings.xml.

Abhijit Humbe
  • 1,563
  • 1
  • 12
  • 13
  • yes i have the kie-ci artifact in classpath. Will try deploying the application. Will update the question with my local settings.xml let me know if there are any discrepancies in that – Praveen Kumar Apr 14 '17 at 05:12
  • @PraveenKumar Did you find the answer, I am also looking for the answer, we are deploying it in a docker container, so inside a docker container, we have made the default settings.xml as the one of JFrog in order to pull kjars from remote, but we are not able to fetch. – Yogesh Sharma Mar 31 '23 at 10:57