Spring 4.0 & Drools 6.0.1 Integration issue
by kmansoor
Hi All- I'm trying to use Drools in a Spring 4 applications. Trying to inject
a StatelessSession in a Spring bean:
@Service
public class RulesServiceImpl implements RulesService {
@Inject()
private StatelessKieSession kStatelessSession;
...
}
This results in:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [org.kie.api.runtime.StatelessKieSession] found
for dependency: expected at least 1 bean which qualifies as autowire
candidate for this dependency. Dependency annotations:
{(a)javax.inject.Inject()}
pom.xml is as follows:
<kie.version>6.0.1.Final</kie.version>
<drools.version>6.0.1.Final</drools.version>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>${kie.version}</version>
</dependency>
and applicationContext.xml:
<kie:kmodule id="kmodule1">
<kie:kbase name="kbase1" packages="rules">
<kie:ksession name="ksession1" type="stateless" />
</kie:kbase>
</kie:kmodule>
<bean id="kiePostProcessor"
class="org.kie.spring.KModuleBeanFactoryPostProcessor" />
I also tried the other route:
@PostConstruct
public void setUp() {
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
kStatelessSession = kContainer.newStatelessKieSession("ksession1");
}
This results in NullPointerException:
Caused by: java.lang.NullPointerException
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:444)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:435)
at
ca.utoronto.med.dc.webcv.service.RulesServiceImpl.setUp(RulesServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 23 more
I do see the following in the console:
2014-02-10 20:05:06,263 DEBUG
org.drools.compiler.kie.builder.impl.ClasspathKieProject.getPomProperties(210):
- Found and used pom.properties
\work\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\dcwebcv\META-INF\maven\ca.utoronto.med.dc\dcwebcv\pom.properties
releaseId == ca.utoronto.med.dc:dcwebcv:1.0-SNAPSHOT
2014-02-10 20:05:06,407 INFO
org.drools.compiler.kie.builder.impl.KieRepositoryImpl.addKieModule(72): -
KieModule was added:FileKieModule[
ReleaseId=ca.utoronto.med.dc:dcwebcv:1.0-SNAPSHOTfile=\work\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\dcwebcv\WEB-INF\classes]
Any pointer will be highly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Spring-4-0-Drools-6-0-1-Integration-iss...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
NullPointerException with kie-spring 6.0.1 and Spring 4.0
by Andrew Berman
Hello,
I'm trying to play around with Drool 6.0.1 integration with Spring (I'm
using spring-boot which includes spring 4.0). I've looked at the unit
tests written and have copied them pretty much exactly. When I start the
app, I consistently receive:
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [org.kie.spring.KModuleBeanFactoryPostProcessor]:
Constructor threw exception; nested exception is
java.lang.NullPointerException
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069)
... 22 more
Caused by: java.lang.NullPointerException
at
org.kie.spring.KModuleBeanFactoryPostProcessor.initConfigFilePath(KModuleBeanFactoryPostProcessor.java:79)
at
org.kie.spring.KModuleBeanFactoryPostProcessor.<init>(KModuleBeanFactoryPostProcessor.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
When debugging the NPE comes from line 79,
getClass().getResource("/").getPath(), because getResource yields null.
Here is my spring context file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:kie="http://drools.org/schema/kie-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://drools.org/schema/kie-spring http://drools.org/schema/kie-spring.xsd
">
<kie:kmodule id="kmodule">
<kie:kbase name="kbase1" packages="rules.drools">
<kie:ksession name="ksession">
<kie:consoleLogger/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>
<bean id="kiePostProcessor"
class="org.kie.spring.KModuleBeanFactoryPostProcessor"/>
</beans>
Can someone help out?
Thanks!!
11 years, 9 months
DSL: Unable to Expand Error - Even things that shouldn't be expanded.
by SrjTx
I've done a couple DSL/RDSLR rules in the past with success. Been trying to
create one today but get "Unable to expand" errors on validation on every
line, even with not substitutions.
What am i missing?
Here is a NON-DSL/RDRL file that works just fine.
5. | rule "AAA"
6. | dialect "mvel"
7. | when
8. | $sep : DroolsSepBean( )
9. | then
10. | System.out.println("HI");
11. | end
Here is a DSL/RDSLR file that generates the errors below (note this is the
same code as above and nothing should substitute) I even took out the $sep
assignment to make it more simple (it gives same errors if it's in there)
5. | rule "dsltest"
6. | dialect "mvel"
7. | when
8. | DroolsSepBean( )
9. | then
10. | System.out.println("HI");
11. | end
18:42:57,396 ERROR [org.drools.compiler.kie.builder.impl.AbstractKieModule]
(http-/127.0.0.1:8080-2) Unable to build KieBaseModel:defaultKieBase
[8] Unable to expand: DroolsSepBean( )
[10] Unable to expand: System.out.println("HI");
--
View this message in context: http://drools.46999.n3.nabble.com/DSL-Unable-to-Expand-Error-Even-things-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
sliding window question
by lin.lin
Hi,
I tried to create a rule that gives an alert when a machine reading is high
for 30 seconds. I modeled the machine reading input as events. The
following is the rule:
rule "rule1"
dialect "mvel"
when
$rd1 : mReading( reading >90 ) from entry-point ReadingStream
not ($rd2 : mReading (reading<=90 , this before [0s, 30s] $rd1 )
from entry-point ReadingStream )
then
System.out.print ("alert: Reading high for 30 seconds \n");
end
This does not detect detect the bad reading. However, If I changed the rule
to be following (change second condition from "not" to "exists"), it detects
all readings that are good.
rule "rule1"
dialect "mvel"
when
$rd1 : mReading( reading >90 ) from entry-point ReadingStream
exists ($rd2 : mReading (reading<=90 , this before [0s, 30s] $rd1 )
from entry-point ReadingStream )
then
System.out.print ("alert: Reading high for 30 seconds \n");
End
Is this an issue in CEP or did I do something wrong?
Thanks a lot!
Lily
--
View this message in context: http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
ArrayIndexOutOfBoundsException under high events load in drools CEP
by ters
Hi, drools users/developers. As mentioned in subject, I often faced
ArrayIndexOutOfBoundsException under high events load in drools during
marshaling.
Conditions: drools CEP (5.4.0.Final), Stream mode, fireUntilHalt mode,
during very active marshaling process (in several threads) I often have such
trace:
java.lang.ArrayIndexOutOfBoundsException: 2773
at
org.drools.marshalling.impl.ProtobufOutputMarshaller.orderFacts(ProtobufOutputMarshaller.java:592)
at
org.drools.marshalling.impl.ProtobufOutputMarshaller.writeFactHandles(ProtobufOutputMarshaller.java:533)
at
org.drools.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:139)
at
org.drools.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:100)
at
org.drools.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:169)
at
org.drools.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:151)
at
com.blablabla.cep.CEPEventProcessor.marshalWorkingMemory(CEPEventProcessor.java:332)
This exception occurs really often.
I googled fresh tracked bug
https://bugzilla.redhat.com/show_bug.cgi?id=1044577. As I understand, this
bug is fixed in drool 5.3.x branch, but we using drools-core 5.4.0.Final.
So could you please help me what to do with this exeption?
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/ArrayIndexOutOfBoundsException-under-hi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months