helloworld on Kie Server version 6.4.0

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 21:10:55

问题


I am currently evaluating KIE Server without using KIE Workbench. The scenario am evaluating is,

1) A third party will give me a drl file its value object (VO which will be used inside drl). I need to create a kjar or jar programmatically through a standard maven project structure and also create a container for that artifact and store it in maven repo.
2) When i receive a request for execution along with the input data, against that artifact, through REST call, i need to execute the above created container with that input data.

I followed the examples this and this

to do a simple "HelloWorld" project.

POM.XML

<modelVersion>4.0.0</modelVersion>
<groupId>demo</groupId>
<artifactId>Hello</artifactId>
<version>1</version>
<packaging>kjar</packaging>

<dependencies>
    <dependency>
        <groupId>org.kie</groupId>
        <artifactId>kie-maven-plugin</artifactId>
        <version>6.4.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-archiver</artifactId>
        <version>3.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-archiver</artifactId>
        <version>3.4</version>
    </dependency>
</dependencies>


<build>
    <plugins>
        <plugin>
            <groupId>org.kie</groupId>
            <artifactId>kie-maven-plugin</artifactId>
            <version>6.4.0.Final</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

HelloWorld.java

package demo;

public class HelloWorld implements java.io.Serializable {

static final long serialVersionUID = 1L;

private java.lang.String message;

public HelloWorld()
{
}

public java.lang.String getMessage()
{
    return this.message;
}

public void setMessage(java.lang.String message)
{
    this.message = message;
}

public HelloWorld(java.lang.String message)
{
    this.message = message;
}

} 

HelloWorld.drl

package demo;

import demo.HelloWorld;

rule "hello"

when 
    HelloWorld(message == "Joe");
then
    System.out.println("Hello Joe!");
end

kmodule.xml

<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">

    <kbase name="demo" packages="demo">
        <ksession name="demo.session"/>
    </kbase>

</kmodule>

Used simple maven project structure:

Hello
 |
 |
 |--src
 |  |--- main
 |          |--java
 |          |   |---demo
 |          |         |
 |          |         |-- HelloWorld.java
 |          |
 |          |--resources
 |                  |
 |                  |--demo
 |                  |   |
 |                  |   |-- HelloWorld.drl
 |                  |
 |                  |--META-INF
 |                          |
 |                          |--kmodule.xml
 |
 |-- pom.xml

I am able to create a container 'HelloworldContainer' for that above maven proj structure with the GroupId: demo, Artifact: Hello, version: 1

But when i try to execute it as below, getting internal server error URI: http://localhost:8080/kie-server/services/rest/server/containers/instances/HelloworldContainer

Headers:

 Content-Type: application/xml,
    Authorization: Basic UWRtaWLkuTW5hZG1pbg==,
    X-KIE-ContentType: XSTREAM

Body:

<batch-execution>
    <insert out-identifier="helloworld" return-object="true">
        <demo.HelloWorld>
            <message>Joe</message>
        </demo.HelloWorld> 
    </insert>
    <fire-all-rules/>
    </batch-execution>

Error Stack trace:

java.lang.IncompatibleClassChangeError: com.google.common.collect.Maps and com.google.common.collect.Maps$TransformedValuesMap disagree on InnerClasses attribute
java.lang.Class.getDeclaringClass0(Native Method)
java.lang.Class.getDeclaringClass(Class.java:1101)
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.&lt;init&gt;(ParameterizedTypeImpl.java:52)
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:85)
java.lang.reflect.Field.getGenericType(Field.java:237)
com.thoughtworks.xstream.mapper.AnnotationMapper.processTypes(AnnotationMapper.java:212)
com.thoughtworks.xstream.mapper.AnnotationMapper.processAnnotations(AnnotationMapper.java:164)
com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:1971)
com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:1982)
org.kie.server.api.marshalling.xstream.XStreamMarshaller.&lt;init&gt;(XStreamMarshaller.java:86)
org.kie.server.api.marshalling.MarshallerFactory.getMarshaller(MarshallerFactory.java:37)
org.kie.server.services.impl.KieContainerInstanceImpl.getMarshaller(KieContainerInstanceImpl.java:111)
org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl.callContainer(DroolsKieContainerCommandServiceImpl.java:59)
org.kie.server.remote.rest.drools.CommandResource.manageContainer(CommandResource.java:72)

I am able to successfully deploy Kie Server 6.4.0 using the link http://mswiderski.blogspot.in/2015/10/installing-kie-server-and-workbench-on.html

Server is starting fine except this one 'SEVERE' issue.

org.kie.server.services.impl.KieServerImpl.<init> Error when initializing server extension of type jBPM KIE Server extension
java.lang.RuntimeException: Unable to create EntityManagerFactory due to [PersistenceUnit: org.jbpm.domain] Unable to build EntityManagerFactory
at       org.kie.server.services.jbpm.JbpmKieServerExtension.build(JbpmKieServerExtension.java:524)
at org.kie.server.services.jbpm.JbpmKieServerExtension.init(JbpmKieServerExtension.java:155)
at org.kie.server.services.impl.KieServerImpl.<init>(KieServerImpl.java:108)
at org.kie.server.services.impl.KieServerLocator.<clinit>(KieServerLocator.java:20)
at org.kie.server.services.Bootstrap.contextInitialized(Bootstrap.java:50)
at 
...
Caused by: javax.naming.NameNotFoundException: Name     [jboss/datasources/ExampleDS] is not bound in this Context. Unable to find     [jboss].
at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:140)
at javax.naming.InitialContext.lookup(InitialContext.java:415)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
... 33 more

and other series of WARNINGS even though org.sonatype.guice is available in my m2 repo

26-Sep-2016 11:37:21.346 WARNING [localhost-startStop-1]     org.kie.server.services.drools.DroolsKieServerExtension.createContainer Unable     to create instance of type org.sonatype.guice.asm.MethodVisitor due to     org.sonatype.guice.asm.MethodVisitor
26-Sep-2016 11:37:21.352 WARNING [localhost-startStop-1]     org.kie.server.services.drools.DroolsKieServerExtension.createContainer Unable     to create instance of type org.sonatype.guice.asm.FieldVisitor due to     org.sonatype.guice.asm.FieldVisitor
26-Sep-2016 11:37:21.357 WARNING [localhost-startStop-1]     org.kie.server.services.drools.DroolsKieServerExtension.createContainer Unable     to create instance of type org.sonatype.guice.asm.Type due to     org.sonatype.guice.asm.Type
26-Sep-2016 11:37:21.363 WARNING [localhost-startStop-1]     org.kie.server.services.drools.DroolsKieServerExtension.createContainer Unable     to create instance of type org.sonatype.guice.asm.ClassWriter due to     org.sonatype.guice.asm.ClassWriter
26-Sep-2016 11:37:21.368 WARNING [localhost-startStop-1]     org.kie.server.services.drools.DroolsKieServerExtension.createContainer Unable     to create instance of type org.sonatype.guice.asm.Edge due to     org.sonatype.guice.asm.Edge

来源:https://stackoverflow.com/questions/39701792/helloworld-on-kie-server-version-6-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!