Re: [rules-users] Question about Drools Spring, StatelessKnowledgeSession and globals
by Patrick van Kann
Hello fellow Droolers,
A while ago I asked why the <drools:batch> element seemed to work
differently in the case of a StatelessKnowledgeSession and a
StatefulKnowedgeSession (see below).
I just wanted to update those interested with the answer and ask some
further questions, probably aimed at any developers who happen to be
reading.
I checked out the 5.1.1.34858 tag and had a look at how the Spring
integration works. I found that the reason that the global is not set in the
case of a StatelessKnowledgeSession is because the <spring:batch> element is
effectively ignored in the StatelessKnowledgeSessionBeanFactory, which lacks
the following code present in the StatefulKnowledgeSessionBeanFactory (in
the internalAfterPropertiesSet() method):
if ( getBatch() != null && !getBatch().isEmpty()) {
for ( Command<?> cmd : getBatch() ) {
ksession.execute( cmd );
}
}
So, either by accident or design the <spring:batch> element has no effect
when using a StatelessKnowledgeSession (but is perfectly allowable in the
XSD/Spring namespace).
So my questions are:
1) Is this the intended behaviour or a bug? On reflection, I am now not sure
the idea of a "batch/script" makes sense for a StatelessKnowledgeSession
since execute() is a one-shot method and any globals set this way would not
be available to later executions, which is what I was looking for.
2) If so, should the XSD be changed to disallow the batch element within a
stateless session (difficult, given that this is determined via the "type"
attribute) or should the documentation simply warn people that the
<spring:batch> element doesn't do anything if you set the type attribute to
stateless (somewhat confusing, I suppose)
3) If not, should the code above be added to the
StatelessKnowledgeSessionBeanFactory.internalAfterPropertiesSet() method?
4) Should there be another way to declare a global that isn't through the
batch element (one that would cause globals to be set via the
setGlobal(String, Object) method rather than using the SetGlobalCommand via
the execute() method.
I am happy to try and contribute something along these lines if I can get
some guidance as to what was actually intended.
Hope this helps and thanks again for Drools.
Patrick
=====================================
Hello,
I've been trying out the Spring integration package in Drools 5.1.1 and it
works really well, but I have run into one issue I can't figure out.
I've defined 2 knowledge sessions from the same knowledge base in the app
context - one stateless, one stateful but otherwise identical. They both
refer to a collaborator defined as a bean in the app context which is to be
used as a global in my rules. This is just an excerpt of my full Spring
context, the kbase definition itself is not an issue.
<bean id="applicantDao" class="com.acme.app.dao.impl.ApplicantDaoImpl" />
<drools:ksession id="statelessKSession" type="stateless"
name="statelessKSession" kbase="kbase">
<drools:batch>
<drools:set-global identifier="applicantDao" ref="applicantDao" />
</drools:batch>
</drools:ksession>
<drools:ksession id="statefulKSession" type="stateful"
name="statefulKSession" kbase="kbase">
<drools:batch>
<drools:set-global identifier="applicantDao" ref="applicantDao" />
</drools:batch>
</drools:ksession>
The issue is that this configuration works for the stateful but not the
stateless session, in the sense that the stateful session appears to have a
valid reference to the applicantDao object in the Globals object but the
stateless session doesn't.
<at> Test
public void testStatelessGlobal() {
Globals globals = statelessKSession.getGlobals();
Object global = globals.get("applicantDao");
Assert.assertNotNull(global);
}
<at> Test
public void testStatefulGlobal() {
Globals globals = statefulKSession.getGlobals();
Object global = globals.get("applicantDao");
Assert.assertNotNull(global);
}
The first test fails (the global variable is null) but the second passes. No
errors are thrown by Drools during the setup of the Spring container.
What am I doing wrong? Should I be able to define globals in this way for
stateless sessions? The XSD seems to indicate this is a valid configuration,
but it just doesn't work.
Is anyone else working with the Spring integration that can point out my
error here?
Many thanks,
Patrick
13 years, 1 month
Drools Guvnor Repository Reports
by Aseem Belsare
Hi,
I wish to obtain the version history from Guvnor repository. Stumbled upon
http://drools.46999.n3.nabble.com/Guvnor-Repository-Report-td3376667.html...
seems to be related to the same topic, but the link in there is not
working which points to the documentation for using REST API to get the
assets/package version history info.
Is there a way of doing it? I started working on Guvnor just recently and
I've setup a simple rule and making changes to it to be saved in the Guvnor
repo. I wish to pull the version history and generate a report using JAVA
based off of it.
Any help would be appreciated.
Thanks,
Aseem
13 years, 1 month
Planner: The entity ... was never added to this ScoreDirector
by Michiel Vermandel
Hi,
Since I am using my custom move implementation I get:
Exception in thread "main" java.lang.IllegalArgumentException: The entity ({T= Inspect B747-AX1.I#0 [2->2] Andy TL}) was never added to this ScoreDirector.
at org.drools.planner.core.score.director.drools.DroolsScoreDirector.afterVariableChanged(DroolsScoreDirector.java:125)
at my.planner.solver.ProjectMove.moveTask(ProjectMove.java:182)
at my.planner.solver.ProjectMove.doMove(ProjectMove.java:125)
at org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:143)
at org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:116)
at org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:62)
at org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:190)
at org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:155)
at my.planner.app.InspectionSchedule.solve(InspectionSchedule.java:188)
at my.planner.app.InspectionPlanning.main(InspectionPlanning.java:27)
It happens during LocalSearch Phase in my custom move implementation.
I caught this exception and printed the hashcode of the entity.
I also printed the hashcodes of all entities in my cloneSolution method and they match.
Furthermore when catching the exception I loop through the
((InspectionSchedule)scoreDirector.getWorkingSolution()).getTasks() array and again I find the task with that hashcode.
It is ((InspectionSchedule)scoreDirector.getWorkingSolution()).getTasks() that holds the tasks and that is populated when cloning the solution.
It does not happen in every test... only in some, but then it's consistently.
Are there any other things I can check to see where I'm going bad?
Thanks
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 1 month
Planner: duplicate moves within a single step?
by Michiel Vermandel
Hi,
I noticed something really strange in my trace logging: certain moves are made multiple times, even consecutive.
How is this possible?
I am using Planner 5.5.0.Final and no custom move factories (see config below).
TRACE: [2013-01-25 14:12:28,309] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (12), score (-515hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P4) ).
TRACE: [2013-01-25 14:12:28,309] main org.drools.planner.core.localsearch.decider.DefaultDecider - Ignoring not doable move ({T= Inspect A380-TR1.I#0 [5->6] Kristof IV} => IV).
TRACE: [2013-01-25 14:12:28,310] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (14), score (-2090hard/0soft), accepted (true) for move ({T= Inspect A380-TR1.I#1 [5->6] Gerald IV} => (P9) ).
TRACE: [2013-01-25 14:12:28,310] main org.drools.planner.core.localsearch.decider.DefaultDecider - Ignoring not doable move ({T= Inspect A320-CZ4.I#0 [7->9] Kristof IV} => IV).
TRACE: [2013-01-25 14:12:28,310] main org.drools.planner.core.localsearch.decider.DefaultDecider - Ignoring not doable move ({T= Inspect A380-TR1.I#1 [5->6] Gerald IV} => IV).
TRACE: [2013-01-25 14:12:28,311] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (17), score (-230hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => Andy).
TRACE: [2013-01-25 14:12:28,312] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (18), score (-120hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#0 [5->5] Andy IV} => (P7) ).
TRACE: [2013-01-25 14:12:28,313] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (19), score (-120hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#0 [5->5] Andy IV} => (P7) ).
TRACE: [2013-01-25 14:12:28,313] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (20), score (-30hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => TL).
TRACE: [2013-01-25 14:12:28,315] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (21), score (-2180hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#0 [5->5] Andy IV} => (P1) ).
TRACE: [2013-01-25 14:12:28,316] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (22), score (-515hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P4) ).
TRACE: [2013-01-25 14:12:28,317] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (23), score (-515hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P4) ).
TRACE: [2013-01-25 14:12:28,318] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (24), score (-3180hard/0soft), accepted (true) for move ({T= Inspect A320-CZ4.I#1 [7->8] Andy IV} => (P1) ).
TRACE: [2013-01-25 14:12:28,318] main org.drools.planner.core.localsearch.decider.DefaultDecider - Ignoring not doable move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => IV).
TRACE: [2013-01-25 14:12:28,320] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (26), score (-120hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P5) ).
TRACE: [2013-01-25 14:12:28,322] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (27), score (-45hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P8) ).
TRACE: [2013-01-25 14:12:28,323] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (28), score (-30hard/0soft), accepted (true) for move ({T= Inspect A380-TR1.I#0 [5->6] Kristof IV} => TL).
TRACE: [2013-01-25 14:12:28,324] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (29), score (-2635hard/0soft), accepted (true) for move ({T= Inspect A320-CZ4.I#1 [7->8] Andy IV} => (P2) ).
TRACE: [2013-01-25 14:12:28,325] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (30), score (-650hard/0soft), accepted (true) for move ({T= Inspect A320-CZ4.I#0 [7->9] Kristof IV} => (P6) ).
TRACE: [2013-01-25 14:12:28,334] main org.drools.planner.core.localsearch.decider.DefaultDecider - Ignoring not doable move ({T= Inspect A380-TR1.I#2 [5->6] Jesse IV} => Jesse).
TRACE: [2013-01-25 14:12:28,335] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (32), score (-230hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#0 [5->5] Andy IV} => Gerald).
TRACE: [2013-01-25 14:12:28,336] main org.drools.planner.core.localsearch.decider.DefaultDecider - Move index (33), score (-515hard/0soft), accepted (true) for move ({T= Inspect B747-AX1.I#1 [7->7] Jesse IV} => (P4) ).
Config:
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<environmentMode>DEBUG</environmentMode>
<!-- Domain model configuration -->
<solutionClass>be.axi.planner.app.InspectionSchedule</solutionClass>
<planningEntityClass>be.axi.planner.domain.Task</planningEntityClass>
<!-- Score configuration -->
<scoreDirectorFactory>
<scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType>
<scoreDrl>/inspectionRules.drl</scoreDrl>
</scoreDirectorFactory>
<constructionHeuristic>
<constructionHeuristicType>BEST_FIT_DECREASING</constructionHeuristicType>
<constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>
</constructionHeuristic>
<!--customSolverPhase>
<customSolverPhaseCommandClass>be.axi.planner.solution.SolutionInitializer</customSolverPhaseCommandClass>
</customSolverPhase-->
<localSearch>
<termination>
<terminationCompositionStyle>OR</terminationCompositionStyle>
<maximumSecondsSpend>3600</maximumSecondsSpend>
<scoreAttained>0hard/0soft</scoreAttained>
</termination>
<unionMoveSelector>
<changeMoveSelector>
<valueSelector>
<planningVariableName>type</planningVariableName>
</valueSelector>
</changeMoveSelector>
<changeMoveSelector>
<valueSelector>
<planningVariableName>spector</planningVariableName>
</valueSelector>
</changeMoveSelector>
<changeMoveSelector>
<valueSelector>
<planningVariableName>period</planningVariableName>
</valueSelector>
</changeMoveSelector>
</unionMoveSelector>
<acceptor>
<planningEntityTabuSize>7</planningEntityTabuSize>
</acceptor>
<forager>
<minimalAcceptedSelection>1000</minimalAcceptedSelection>
</forager>
</localSearch>
</solver>
Thanks,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 1 month
business guided rule editor
by neha.gupta19@wipro.com
Hi,
Business guided rule editor is not working in drools.i am not able to open the rule defined in business guided rule editor
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
13 years, 1 month
DSRL rule access in web editor
by riri
Hello everyone,
I need to provide a way to allow non technical users to modify and possibly
create rules by using a web based editor. I thought about using Guvnor
because it already has validation functionality for the dsrl rule files and
I wouldn't have to implement that from scratch. The problem is that the
interface seems very complex and I have to provide something very simple, in
the style of "drag and drop".
Would there be a way to achieve this without having to dig through the whole
Guvnor source code? Is there a way to recover rule objects from rule
packages and modify the conditions parameters? The idea is not to modify the
.dsrl file directly but having a tool to display the information in a way
that the user can interact with the rule in a safe way.
Thank you very much for any help you can give me.
--
View this message in context: http://drools.46999.n3.nabble.com/DSRL-rule-access-in-web-editor-tp402179...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Guvnor problems...
by des4900
I am working with Guvnor/Drools 5.5.0, jBPM 5.4.0 on Win7 64 bit, JBoss 7.1.1
First Problem:
1. I have a rule in the global area, e.g., Rule1
2. I create a new rule in a package by importing Rule1 from the global area
3. I realize that I imported the wrong rule.
4. How do I remove Rule1 from the package? If I archive it from the
package, it also archives it from global, which I don't want to do since it
has been imported into many other packages. If I archive it from the
package anyway and then restore it, it reappears in the global area, and
also in all of the other packages that it was a part of. The only thing I
have found that works is to copy the rule, archive it, delete it, and then
import the copied rule into all the packages where the original rule
actually belongs.
Second Problem (which I got into by trying to deal with the first one
above):
1. I have a rule in the global area, e.g., Rule2
2. I rename Rule2 to Rule3
3. I also have a different rule in a package named Rule2
4. I archive and delete Rule 2 from the package, and it no longer appears
in the archives, nor in the package. I save the package, close it, stop and
restart JBoss, and check again, and it is not in the archives nor in the
package.
5. I try to copy Rule3 from the global area to this package giving it the
name Rule2 (the same name as the rule I archived and deleted) and somehow
Guvnor thinks Rule2 is still there.
6. I get an error (apparently Guvnor thinks the rule is still there):
Error
500 The call failed on the server; see server log for details
The server log shows this:
14:22:39,840 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/drools-guvnor]]
(http--0.0.0.0-8080-22) Exception while dispatching incoming RPC call:
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public
abstract java.lang.String
org.drools.guvnor.client.rpc.AssetService.copyAsset(java.lang.String,java.lang.String,java.lang.String)'
threw an unexpected exception:
org.drools.repository.RulesRepositoryException:
javax.jcr.ItemExistsException: cannot add child node
'InitClinicalStatementConcepts' to
/drools:repository/drools:package_area/edu.utah.AHRQ_PSI_04_v4_3/assets:
colliding with same-named existing node
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
[gwt-servlet-2.4.0.jar:]
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
[gwt-servlet-2.4.0.jar:]
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
[gwt-servlet-2.4.0.jar:]
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
[gwt-servlet-2.4.0.jar:]
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[gwt-servlet-2.4.0.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
Caused by: org.drools.repository.RulesRepositoryException:
javax.jcr.ItemExistsException: cannot add child node
'InitClinicalStatementConcepts' to
/drools:repository/drools:package_area/edu.utah.AHRQ_PSI_04_v4_3/assets:
colliding with same-named existing node
at
org.drools.repository.RulesRepository.copyAsset(RulesRepository.java:421)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.repository.RulesRepository$Proxy$_$$_WeldClientProxy.copyAsset(RulesRepository$Proxy$_$$_WeldClientProxy.java)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.RepositoryAssetService.copyAsset(RepositoryAssetService.java:264)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.RepositoryAssetService$Proxy$_$$_WeldClientProxy.copyAsset(RepositoryAssetService$Proxy$_$$_WeldClientProxy.java)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.AssetServiceServlet.copyAsset(AssetServiceServlet.java:166)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
[:1.6.0_25]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rt.jar:1.6.0_25]
at java.lang.reflect.Method.invoke(Method.java:597)
[rt.jar:1.6.0_25]
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
[gwt-servlet-2.4.0.jar:]
... 27 more
Caused by: javax.jcr.ItemExistsException: cannot add child node
'InitClinicalStatementConcepts' to
/drools:repository/drools:package_area/edu.utah.AHRQ_PSI_04_v4_3/assets:
colliding with same-named existing node
at
org.apache.jackrabbit.core.BatchedItemOperations.checkAddNode(BatchedItemOperations.java:746)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.BatchedItemOperations.copy(BatchedItemOperations.java:401)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.WorkspaceImpl.internalCopy(WorkspaceImpl.java:420)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.WorkspaceImpl.copy(WorkspaceImpl.java:646)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.drools.repository.RulesRepository.copyAsset(RulesRepository.java:404)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
... 35 more
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-problems-tp4021809.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Drools as a Webservice
by abhinavgupta
Hi,
I am new to the Drools , i wanted to expose rules as a webservice using
Axis2.
what i have done is that
1. I have created a drools Project (working fine on eclispe) export all
files in jar
2. Placed the jar file in C:\Program Files\Apache Software Foundation\Tomcat
7.0\webapps\axis2\WEB-INF\lib directory
3. Created a new Dynamic java project with axis2 facet.created a class with
**
package in.abhi.ws;
import java.math.BigDecimal;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import com.sample.SaleItem;
public class Test {
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("KanasSalesTax.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public BigDecimal salesTax(String taxState, String typeItem) {
BigDecimal taxCal = null;
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase
.newStatefulKnowledgeSession();
// Non-prescription item
// Expect $1.89 for the tax
SaleItem item1 = new SaleItem();
item1.setPurchaseState(taxState);
item1.setItemType(typeItem);
item1.setSalesPrice(new BigDecimal(29.95));
ksession.insert(item1);
ksession.fireAllRules();
taxCal = item1.getSalesTax();
System.out.println(item1.getPurchaseState().toString() + " "
+ item1.getItemType().toString() + ": "
+ item1.getSalesTax().toString());
} catch (Throwable t) {
t.printStackTrace();
}
return taxCal;
}
}
**
4. Then created a bottom up java bean webservice of it using the same above
class.
5. Wsdl is generated
i am getting the error response on eclispe console while testing by soap-ui
**********
java.lang.NullPointerException
at
org.drools.util.CompositeClassLoader.getResourceAsStream(CompositeClassLoader.java:122)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:234)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:215)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPackage(LookupEnvironment.java:748)
at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:87)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:167)
at
org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:721)
at
org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:381)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:358)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:369)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:53)
at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:71)
at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:869)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:826)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:404)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at in.abhi.ws.Test.readKnowledgeBase(Test.java:31)
at in.abhi.ws.Test.salesTax(Test.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at
org.drools.util.CompositeClassLoader.getResourceAsStream(CompositeClassLoader.java:122)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:234)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:215)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPackage(LookupEnvironment.java:748)
at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:87)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:167)
at
org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:721)
at
org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:381)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:358)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:369)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:53)
at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:71)
at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:869)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:826)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:404)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at in.abhi.ws.Test.readKnowledgeBase(Test.java:31)
at in.abhi.ws.Test.salesTax(Test.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
****************
Please let me know how to make it work
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-as-a-Webservice-tp3950198.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month