Java.lang.ClassNotFoundException: org.kie.api.KieServices$Factory

1.2k views Asked by At

I have this exception when I try to start spring boot Exception in threat java.lang.ClassNotFoundException: org.kie.api.KieServices$Factory at java.net.URLClassLoader.findClass
This is how my pom looks like. I think i'm missing some dependency in the pom file but i'm not sure which ones i'm missing. Any ideas how I can fix this

    <?xml version="1.0" encoding="UTF-8"?>
            <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"`enter code here` xmlns="http://maven.apache.org/POM/4.0.0"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <modelVersion>4.0.0</modelVersion>
            
              <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.2.2.RELEASE</version>
                <relativePath/> <!-- lookup parent from repository -->
              </parent>
            
              <groupId>com.myspace</groupId>
              <artifactId>Onboarding</artifactId>
              <version>1.0.2-SNAPSHOT</version>
              <packaging>kjar</packaging>
              <name>Onboarding</name>
              <description>onboarding</description>
            
              <properties>
                <java.version>1.8</java.version>
              </properties>
            
              <dependencies>
            
                <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-web</artifactId>
                </dependency>
            
                <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
                  <scope>test</scope>
                </dependency>
                <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-autoconfigure</artifactId>
                  <version>2.2.2.RELEASE</version>
                </dependency>
            
                <dependency>
                  <groupId>com.thoughtworks.xstream</groupId>
                  <artifactId>xstream</artifactId>
                  <version>1.4.10</version>
                  <scope>test</scope>
                </dependency>
                <dependency>
                  <groupId>org.kie</groupId>
                  <artifactId>kie-internal</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                  <scope>provided</scope>
                </dependency>
                <dependency>
                  <groupId>org.optaplanner</groupId>
                  <artifactId>optaplanner-core</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                  <scope>provided</scope>
                </dependency>
                <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.12</version>
                  <scope>test</scope>
                </dependency>
                <dependency>
                  <groupId>org.optaplanner</groupId>
                  <artifactId>optaplanner-persistence-jaxb</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                  <scope>provided</scope>
                </dependency>
                <dependency>
                  <groupId>org.kie</groupId>
                  <artifactId>kie-api</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                  <scope>provided</scope>
                </dependency>
            
                <dependency>
                  <groupId>org.kie</groupId>
                  <artifactId>kie-dmn-core</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                </dependency>
            
                <!-- Required if not using classpath kie container -->
                <dependency>
                  <groupId>org.kie</groupId>
                  <artifactId>kie-ci</artifactId>
                  <version>7.26.0.Final-redhat-00005</version>
                </dependency>
            
                <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter</artifactId>
                </dependency>
            
                <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-jersey</artifactId>
                </dependency>
                <dependency>
                  <groupId>org.projectlombok</groupId>
                  <artifactId>lombok</artifactId>
                  <optional>true</optional>
                </dependency>
            
                <dependency>
                  <groupId>org.drools</groupId>
                  <artifactId>drools-decisiontables</artifactId>
                  <version>7.1.0.Beta2</version>
                </dependency>
            
            
                <dependency>
                  <groupId>org.apache.cxf</groupId>
                  <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
                  <version>3.2.6</version>
                </dependency>
                <dependency>
                  <groupId>io.swagger</groupId>
                  <artifactId>swagger-jaxrs</artifactId>
                  <version>1.5.15</version>
                  <exclusions>
                    <exclusion>
                      <groupId>javax.ws.rs</groupId>
                      <artifactId>jsr311-api</artifactId>
                    </exclusion>
                  </exclusions>
                </dependency>
            
                <dependency>
                  <groupId>org.webjars</groupId>
                  <artifactId>swagger-ui</artifactId>
                  <version>2.2.10</version>
                </dependency>
            
              </dependencies>
              <build>
                <plugins>
                  <plugin>
                    <groupId>org.kie</groupId>
                    <artifactId>kie-maven-plugin</artifactId>
                    <version>7.26.0.Final-redhat-00005</version>
                    <extensions>true</extensions>
                  </plugin>
            
                    <plugin>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                </plugins>
              </build>
            </project>
    
    ```
1

There are 1 answers

0
Thilakar Raj On

@mrobi is any specific reason to use redhat versions dependency.? You can try the following

<groupId>com.drools</groupId>
  <artifactId>sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>drools sample</name>
  <description>Microservices for the drools sample</description>
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <drools.version>7.36.1.Final</drools.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
      
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        
        
        
         <!-- Swagger -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-bean-validators</artifactId>
            <version>2.9.2</version>
        </dependency>
         <!-- Swagger -->
         
            <!-- Logback -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.janino</groupId>
            <artifactId>janino</artifactId>
        </dependency>
         <!-- Logback -->
         
         
         <!-- Drools dependcy -->
         
         <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-spring</artifactId>
            <version>${drools.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-compiler</artifactId>
            <version>${drools.version}</version>
        </dependency>
           <!-- Drools dependcy -->
         
         
         
                <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
         
    </dependencies>