Drools In Real Life: Drools/jBPM5 Server (first steps)

This post is targeted to people that wants to build real life applications and solutions using Drools. Most of the times that we create applications that use Drools  we need about how to create applications that require multiple Knowledge Sessions to host different knowledge resources that solves different problems at different points in time. This post introduces the very first steps to use Drools Server that can host multiple knowledge sessions to run Rules and jBPM5 business processes.

Introduction

Drools Server (drools-camel-server) allow us to decouple from our application the responsibility of creating and hosting Knowledge Sessions required to interact with our business knowledge (rules, processes, events).  Most of the time we don’t want to embed drools inside our applications and we want to have an external service that will host our processes and rules runtime. When we have stateless session we can create a homebrew service that creates a new stateless session per request and we solve the problem, but when we have stateful scenarios we need more advanced mechanism to interact and define the knowledge that will be related with each session.

This post will include a very basic description about the configuration that are required to work with drools server, because the examples uses the default configuration. Future post will dive deep in more advanced configurations.

During this post we will follow these steps:

  • Building the Server. This is a web application that must be deployed inside a servlet container.
  • Deploying on Tomcat 6/7 and/or Jetty 6
  • Create a client project using SOAP UI to test that everything is working properly

The main idea of this post is to reduce the discovery phase that each user needs to do in order to get everything working. This post will be referenced by future posts that will introduce drools-grid.

Building the server

UPDATE: now you can download the latest build from here: https://hudson.jboss.org/hudson/view/Drools%20jBPM/job/droolsjbpm-integration/lastSuccessfulBuild/artifact/droolsjbpm-integration-distribution/target/ -> Inside the target directory you will find a zip file called: droolsjbpm-integration-distribution-5.XXX-SNAPSHOT.zip . Download that file unzip it and you will find a directory called binary and inside it drools-camel-server-5.2.0-SNAPSHOT.war

As soon as the master branch of the project became stable I will add the link for download the latest snapshot. In the meantime you need to build the sources that you can get cloning the repository from:

https://github.com/droolsjbpm/droolsjbpm-integration

For downloading the source you need to do in your terminal or with your IDE:

git clone git://github.com/droolsjbpm/droolsjbpm-integration.git

After that you can run:

mvn clean install -DskipTests

to build it.

Drools Server WAR file will be located at:

droolsjbpm-integration/drools-camel-server/target

Deploying  Drools Server on Tomcat 6/7 & Jetty 6

Now that we have the WAR file we can deploy it to a servlet container like Tomcat. I’m using apache-tomcat-6.0.32 and jetty 6.1.3, I strongly recommend you to work with a newly downloaded container to avoid clashing applications and libraries. Obviously that you can use the same container to host multiple applications, but this tutorial only shows the things that needs to be modifed to work with drools server.

Once we download and uncompress Apache Tomcat or/and Jetty we can place a copy of the drools-server.war file inside the webapps directory inside the servlet container that we choose.

After that we just need to start the server in order to check that drools-server is being deployed correctly:

Tomcat:

cd bin/
./startup.sh

Jetty:

java -jar start.jar

After that you can check if everything is ok using your browser. Pointing it to:

http://localhost:8080/drools-server/

Accessing to this url must show you in the browser something like this:

Creating a Simple Client

The final step is to create a simple client in order to interact with the server. We will use SOAPUI to interact with the exposed services using the SOAP interfaces. Drools Server comes with a very simple rule that let us test that everything is working. The simple configuration files create a knowledge session that will contain the following rule:


package  org.test

declare Message
  text : String
end

rule "echo" dialect "mvel"
  when
    $m : Message()
  then
    $m.text = "echo:" + $m.text;
end

As you can see, this very simple drl file defines a new entity called Message and a rule that per each Message it will change the value of the text field.

You can review the configurations files that creates a new stateless session, the knowledge base and the inclusion of the test.drl file using spring here:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel-server/src/main/resources/knowledge-services.xml

Obviously this is just a sample configuration to get you started quickly with something working. You should change/adapt the configuration files, the knowledge resources files and everything that you need to solve your situation or design your service.

Now that we know what we have inside Drools Server, we will create a simple project using SOAPUI to interact with the rule previously introduced.

First of all you must download SOAPUI (here). After that you can create a simple project using the WSDL exposed by drools server in the following URL:

http://localhost:8080/drools-server/kservice/soap?WSDL

After creating the project you can see that SOAPUI will create a sample request to the service that you can run against the service. For this test I’ve just add to the default request some parameters in order to insert a new Message Object inside the knowledge session and then fire all the rules. This will change the value of the text inside the message and return the content of the new message to SOAP UI.

Take a look at the following screenshot:

I’m calling the service with the following XML content inside the common SOAP envelope:

 <batch-execution lookup="ksession1">
   <insert out-identifier="person1">
      <org.test.Message>
        <text>salaboy</text>
      </org.test.Message>
    </insert>
   <fire-all-rules max="-1"/>
 </batch-execution>

You can see in the screenshot that I’m getting from the server echo:salaboy inside the server answer:


 <execution-results>
   <result identifier="person1">
     <org.test.Message>
       <text>echo:salaboy</text>
     </org.test.Message>
   </result>
   <fact-handle identifier="person1" external-form="0:2:232003191:1:2:DEFAULT"/>
 </execution-results>

Notice that we are getting this results because we are setting the out-identifier=”person1″ inside the insert command that we are sending.

Sum up

Now that we know how to download, build and check that a very simple example is working with drools server we can jump to more advanced configurations and usages. We will see in following posts how to create stateful sessions, configure some knowledge agents to get remotely hosted knowledge resources and plays a little bit with drools-grid.

Stay tuned for more posts about this, because I’m doing heavy work around these topics to make them easy to use. Please feel free to write me some comments here with feedback about these topics or feature requests. If you find some troubles with Drools Server or Drools Grid don’t hesitate to write me back!

Advertisements

41 thoughts on “Drools In Real Life: Drools/jBPM5 Server (first steps)”

  1. Hi,

    Thanks for your posts. I have been using them as tutorials to get my project up. I am using drools-server and there could be multiple users simultaneously accessing the server via different instances of the client. The client is in python.

    I have a predefined stateful session ‘ksession1’ and I want it to be reset (all facts retracted) after every transaction from a client, as there are multiple users working with same rules but different facts, so if one client modifies the rule temporarily (say to have a what-if sort of analysis), the other clients get affected. Is there any way I can introduce some form of locking to overcome such conflicts?

    Ideally, as the rules are loaded from a database so the temporary what-ifs wouldn’t affect the other users if they had separate sessions. It would be really nice if there could be dynamic sessions, so every time a user logs in he gets a different session. I found a similar query on [1]. Are there any plans to introduce such a feature?

    We need a de-coupled rules engine as in the future (if this attempt succeeds) there would be multiple clients that have different applications but which would all need drools.

    [1] http://drools.46999.n3.nabble.com/Drools-server-multiple-knowledge-sessions-td1730444.html

    Like

  2. Hi Satya,
    Thanks for writing back. If you want to avoid multiple users over the same knowledge session have two options:
    1) if your session has rules that are evaluated and after that you get a result, you can change the session to be stateless, that will keep you safe against multiple users.
    2) Create one ksession per user. To be able to do this dynamically you need to use Drools Grid, that will let you connect and create knowledge sessions remotely using the drools-grid APIs.

    I’m writing a blog about the second option (I have a few old ones about this topic as well).

    Hope it helps!
    Greetings!

    Like

  3. So I deploy the war to tomcat and that seems to be working… However, if I go to the test.jsp page (http://localhost:8080/drools-camel-server-5.2.0-SNAPSHOT/test.jsp)…. I get the following error…

    Not sure what this means… Is there a way to learn how you are setting up the project and deploying the project to tomcat?

    org.apache.jasper.JasperException: An exception occurred processing JSP page /test.jsp at line 19

    16:
    17: Sending Message: “”
    18:
    21: Response: “”
    22:

    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message:

    Hello World

    ]
    org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1142)
    org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:452)
    org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:441)
    org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:119)
    org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:135)
    org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:283)
    org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:313)
    org.drools.server.Test.execute(Test.java:66)
    org.drools.server.Test.send(Test.java:58)
    org.apache.jsp.test_jsp._jspService(test_jsp.java:76)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    org.apache.camel.CamelExchangeException: No consumers available on endpoint: Endpoint[direct://kservice/rest]. Exchange[Message:

    Hello World

    ]
    org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:56)
    org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:99)
    org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)
    org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
    org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
    org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:333)
    org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:304)
    org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:208)
    org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:303)
    org.apache.camel.impl.ProducerCache.send(ProducerCache.java:171)
    org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:114)
    org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:118)
    org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:135)
    org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:283)
    org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:313)
    org.drools.server.Test.execute(Test.java:66)
    org.drools.server.Test.send(Test.java:58)
    org.apache.jsp.test_jsp._jspService(test_jsp.java:76)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    Like

  4. Thanks a lot for the reply, looking forward to the drools-grid post.

    Also, while I’m at it, a rather stupid question. Are drools-camel and drools-camel-server the same? I head that drools-server was renamed to drools-camel-server but while searching for a solution to the same problem, I came across a third camel-drools as well.

    Like

  5. Yes, don’t look at test.jsp.. is an old test that I will delete now.
    The best way to test that it’s working is looking at the out put or using SOAPUI to interact.
    Greetings.

    Like

  6. Hi,

    Can you explain the difference between tools like bizagi or IntalioBPMS And jBPM5? Maybe in a future blog post or right here in the comments?

    Thanks.

    Like

    1. Hi there, sorry for my late reply, but I’m not sure about what kind of comparision do you want between those projects and products. As you may know jBPM5 is an open source project and Bizagi and IntalioBPMS are both closed source products. You can buy those two products and use for free jBPM5. As far as I know the latest Intalio BPMS version is using jBPM5 and Drools in the back.
      I think that this topic can be explained in multiples posts, but I’m interested to know what kind of comparison are you looking for.

      Cheers

      Like

  7. Why do I need to use Drools Grid for creating separate knowledge session for each user ?
    wouldn’t following code generate separate session for each user ?

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(“rule-file-name.drl”), ResourceType.DRL);
    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    StatefulKnowledgeSession kbsession = kbase.newStatefulKnowledgeSession();

    Like

    1. Hi I didn’t notice your message, probably the alert was lost in my inbox.
      Yes that lines of codes will allow you to create different sessions. If you have multiple users and you want to create all the sessions locally to that thread you don’t need grid. But if you want to abstract the way where the knowledge sessions will run (for example in a remote server) you should use grid to be able to scale your application to more than one JVM.
      I wrote a couple of blog posts about it.
      I hope that this clarify your doubts if not, please write me back. Sorry for the delay!
      Cheers

      Like

  8. Hi salaboy,

    First of all, thank you for your great tutorial.

    I have followed your tutorial, and successfully deployed the war file to tomcat, the server returned “Execution server is running” when I request it through browser.

    I also downloaded and installed soapUI and successfully launched it. However when I send the test soap request as instructed in the tutorial, I got the below message:

    soap:Server
    org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String

    What might be the problem? Thank you.

    Like

  9. Hi Salaboy,

    even i am getting the same error “org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String”

    can you please help!!

    Like

  10. Salaboy,

    Thanks for your post… is there a way to execute a query via the rest interface?

    Also, if I insert an object use the rest interface, what would the response contain exactly? I have one rule in my rule file:

    rule “match”
    when
    $m1 : Message(text=”xx”)
    $m2 : Message(text=”yy”)
    then
    Message m = new Message();
    m.setText(“matched!”);
    insert(m)
    end

    When I inserted Message(“xx”), I got a response with that object. When I inserted Message(“yy”), I got a response with that object. But I never got the “matched!” object…

    Curious what’s should be happening.

    Thanks.
    -SC

    Like

  11. Hi Salaboy,
    I’m still figuring out how to use the issue tracker, so I apologize for posting this here, but I figure u’d want to know. I went a bit outside the bounds of your tutorial, but I was trying to get the test to work using REST commands instead of soap. I’m using the Drools Server 5.5.0 download and in it, the knowledge-services.xml has the marshaller for REST using xstream. I update it to be json, and my test written in JSON started to work. Just FYI. Thanks for all of the useful walk-throughs!

    Like

      1. Hi Salaboy,
        Sorry for the delayed response – I would love to share an example with you. Could you please tell me how you would like me to present it? Do you want my pkg file from guvnor and my drools-server war, or just the text of the relevant files? Shall I email them somewhere or just post the text here?
        Thank you for your help!

        Like

  12. Hi Mauricio !

    I have tried with Drools 5.5.0 final on Tomcat 6.0.32 and 6.0.35 and sending a soap message with soapUI as in this blog post and i can not get successfully.

    The message:

    <![CDATA[

    salaboy

    ]]>

    Tomcat shows this error:

    Caused by: java.lang.ClassCastException: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String
    at org.drools.jax.soap.PreCxfTransportSoapProcessor.process(PreCxfTransportSoapProcessor.java:37)
    at org.drools.camel.component.DroolsPolicy$DroolsProcess.process(DroolsPolicy.java:326)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

    Any help?

    Thanks.

    Like

      1. Hi Mauricio,

        Link to Tomcat 6.0.36 log:
        http://pastebin.com/K37Whmk1

        Tested on Mac OS X with Java/JRE (build 1.6.0_37-b06-434-11M3909)

        I have reviewed the drools 5.5.0 Final documentation and I can see that those files (drools-server/WEB-INF/classes/camel-client.xml and model.xsd) does not exist and drools-server/WEB-INF/classes/test.drl differs to file that is mentioned in the documentation.

        Thanks for your help.

        Like

  13. Hi,
    Thanks for putting this together. Similar setup/issues to those mentioned by Chilcano. I just ran through the steps above on Tomcat 7 and JBoss AS 7.1 and Drools Server 5.5.0. In both cases I’m getting some errors. Instead of the expected output, I get an HTML message. On JBoss AS 7.1 the text of this message says “The requested resource (/drools-service/kservice/soap) is not available.” I am able to confirm that the server is running, I’m able to see the WSDL if I access through a browser, etc, and I can get the test.jsp to run successfully if I grab the test files from git and add those to the war. I did not change anything about the default configuration provided with Drools Server. Any help appreciated.

    Thanks,
    Matt

    Like

    1. Hi there!
      finally, I get to run successfully Drools 5.5.0.Final on Tomcat 6.0.32 or 6.0.35 but just with REST services.
      I continued to have errors as indicated in my last message when I invoke SOAP services.

      Regards.

      Like

      1. Hello,

        I have the same error with Drools server 5.5.0 in a Tomcat 6.0.36. When I do the same test with drools-camel-server-5.2.0-SNAPSHOT.war it works fine.

        Do you find why we have this error with version 5.5.0?

        Thanks!

        Like

  14. Hi Salaboy,
    I’m sorry I caused some confusion – I registered for the drools community with the same email address as the forum, and when I saw a reply from you, I mistakenly thought it was for my forum post, so I apologize for the litter on your blog 🙂

    Regarding my original comment on your blog, I think that it came from my mental association which it was time for me to break: I had for a long time associated xml with soap, and JSON w/ REST (obviously, a newby error, but the reason I’m posting is because someone else may have made the same dumb mistake). So when I tried to pass a JSON formatted message to the server, the xstream unmarshaller did not work. I had to change xstream to JSON to make it interpret JSON commands.
    So the original Camel-server.xml looked like this:

    To make it work for JSON, I just changed xstream to json in the marshal and unmarshal elements.

    This is probably not worth a blog post by you, but in case people are at a similarly low level of knowledge as myself, I thought it would be nice to clarify my original post.
    Thanks!

    Like

    1. Hi Yuri,
      Thanks for your comment. There are no newbie questions here, and thanks for the clarification. I think that it will help a lot of people.
      Most of the time wordpress is not the best place to ask questions due the lack of support for xml snippets. But anything that we can do to help people is OK in this blog.

      Cheers

      Like

  15. Hi Mauricio,

    Is it possible to configure the server to create a separate stateful knowledge session for each HTTP session?

    I’m finally getting around to updating Tohu (including the UI part) to a modern version of Drools. Tohu needs each user to have their own independent stateful knowledge session. This was the behaviour in drools-execution-server 0.0.4 that Tohu was using previously. However with drools-camel the knowledge sessions are defined in xml in advance and the one session is shared by all users.

    Am I able to configure it to do this? If not then can you please point me to the code that finds the sessions so I can extend it somehow to create them on the fly?

    Thanks, Damon

    Like

  16. I just read some of the other comments above and your other page about drools-grid. My understanding of this is that code at the client end creates new sessions remotely. My client is Javascript though instead of Java. If the communication is XML then I guess I could generate the necessary messages from Javascript.

    Or is there a way to create sessions dynamically on the server though instead? Or a hook where I can add something to do this? I always want one knowledge session.per HTTP session.

    Thanks, Damon

    Like

    1. Hi Damon,
      thanks for sharing.. but tohu is still based on drools 5 right?
      It will be nice to see something like this but in 6. I know that there is some effort going on towards this direction.
      Regards

      Like

      1. Hi Mauricio,

        I have now finally upgraded it. Yesterday I released two new versions of Tohu. One that uses Drools 5.6.0 and one using Drools 6.0.1. So far I’ve only made the minimum changes necessary to get everything to run so it is currently using some deprecated APIs in Drools 6. But the priority was just to get it running first as I have a client using Tohu that wants to use some new features of Drools 6.

        Details at https://issues.jboss.org/browse/TOHU-46

        Regards, Damon

        Like

  17. Hi ,
    I have tested drools camel server 6. it works fine for 40 request per second but after that it starts failing and giving following exception. How we can configure the server to create new stateless session for each request.

    sorry for printing stack trace here…

    Thanks,
    -Vinayak

    Jul 04, 2014 4:18:41 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
    WARNING: javax.ws.rs.WebApplicationException: java.lang.NullPointerException
    at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.returnResponse(CxfRsInvoker.java:149)
    at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.syncInvoke(CxfRsInvoker.java:126)
    at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:60)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:168)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:237)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:214)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:194)
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:130)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:225)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:145)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:201)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
    at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:381)
    at org.kie.camel.component.KieExecuteProducer.process(KieExecuteProducer.java:96)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)
    at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:60)
    at org.kie.camel.component.KiePolicy$KieProcess.process(KiePolicy.java:326)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
    at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
    at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
    at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.syncInvoke(CxfRsInvoker.java:122)
    … 35 more

    Like

    1. I would recommend to use the new stuff that is being developed for the execution server. I’m not entirely updated about the new stuff but you can ask about the progress in the drools mailing list.
      Regards

      Like

  18. Hi Vinayak,

    Another option that might work for you is to just write your own simple servlet and don’t use the camel server at all. Depending on what you actually need, you may find that it’s only a few lines code.

    Have a look at http://anonsvn.jboss.org/repos/tohu/trunk/tohu/tohu-xml/src/main/java/org/tohu/server/ as a working example. It’s not exactly what you want but it should give you an idea of how to do it.

    The crux of it is these 3 lines in TohuExecutionServer:

    Command command = (Command) xstream.fromXML(request.getInputStream());
    Object results = knowledgeSession.execute(command);
    String xml = xstream.toXML(results);

    That’s what allows it to process a command specified as XML. If you’re using JSON instead of XML then the 1st and 3rd line would be different. Plus of course you have to create your stateless knowledge session but that can be done in just a few lines of Java code too (similar to ExecutionServerHelper.newKnowledgeSession).

    Regards, Damon

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s