[rules-users] Drools With Spring Framework Problem

Edson Tirelli tirelli at post.com
Tue Feb 20 06:51:15 EST 2007


   
    Hi Niyas,

    This is something I faced yesterday but did not had the time to work 
on it yet. Basically, 2 problems:

1. Error message is crap... we need to improve that.

2. It should not be raising any error. The error means you have a String 
attribute you are trying to compare using operators like >, <, >=, <=. 
Example:

Person( name > 'Edson' )

    And I think the above should work but is not working. I will open a 
JIRA for that.
    Meanwhile, if you need to have such constraint, a workaround is to 
use a predicate:

Person( $n : name, ( $n.compareTo( 'Edson' ) > 0 ) )
 
    []s
    Edson


Niyas wrote:

> I have tried of using the sample coding given the link given by you:
> But i am getting the following error:
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'ruleBase' defined in ServletContext resource
> [/WEB-INF/insurance-servlet.xml]: Initialization of bean failed;
> nested exception is java.lang.RuntimeException: Operator '40' does not
> exist for StringEvaluator
>     org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:403) 
>
>     org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233) 
>
>     org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145) 
>
>     org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277) 
>
>     org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313) 
>
>     org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) 
>
>     org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306) 
>
>     org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251) 
>
>     org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220) 
>
>     org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112) 
>
>     javax.servlet.GenericServlet.init(GenericServlet.java:211)
>     org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
>
>     org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
>
>     org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) 
>
>     org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 
>
>     org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
>
>     org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 
>
>     org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) 
>
>     java.lang.Thread.run(Thread.java:595)
> ========================================================
> My insurance-servlet.xml:
> <beans>
>     <!-- default handlermapping -->
>     <bean id="beanNameUrlMapping"
> class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> 
>
>
>     <bean name="/home.htm" class="com.sample.InsuranceController"
> singleton="false">
>         <property name="ruleBase">
>             <ref bean="ruleBase"/>
>         </property>
>         <property name="insurBean">
>             <ref bean="insurance"/>
>         </property>
>     </bean>
>
>     <!-- View Resolver -->
>     <bean id="viewResolver"
> class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
>
>         <property name="prefix">
>             <value>/WEB-INF/jsp/</value>       
>         </property>
>         <property name="suffix">
>             <value>.jsp</value>
>         </property>       
>     </bean>
>     
>     <!-- Bean -->   
>     <bean id="insurance" class="com.sample.InsuranceBean"/>
>
>
>     <bean id="ruleBase" class="com.sample.RuleBaseBeanFactory">
>         <property name="drlResourceList">
>             <list>
>                 <value 
> type="org.springframework.core.io.Resource">classpath:/com/sample/Approval.drl</value> 
>
>             </list>
>         </property>
>
>         <property name="packageBuilderConfiguration">
>             <bean 
> class="org.drools.compiler.PackageBuilderConfiguration">
>                 <property name="javaLanguageLevel" value="1.5"/>
>             </bean>
>         </property>
>     </bean>   
> </beans>
>
>
>
> On 2/19/07, Olenin, Vladimir (MOH) <Vladimir.Olenin at moh.gov.on.ca> wrote:
>
>> Check out 'Spring Modules' subproject - it has a DROOLS integration 
>> module.
>> Haven't used it myself yet, so not sure whether it's 
>> mature/compatible with
>> most recent release.
>>
>> https://springmodules.dev.java.net/docs/reference/0.7/html/jsr94.html#d0e570 
>>
>> 9
>>
>> https://springmodules.dev.java.net/
>>
>> Vlad
>>
>>
>> -----Original Message-----
>> From: rules-users-bounces at lists.jboss.org
>> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Niyas
>> Sent: 19 February 2007 09:49
>> To: rules-users at lists.jboss.org
>> Subject: [rules-users] Drools With Spring Framework Problem
>>
>> Hi all,
>>
>> I am in need of integrating Drools JBoss Rule Engine with Spring 
>> Framework.
>> I have tried sample rule engine examples in the Drools in the
>> standalone with the help od drools IDE for eclipse 3.2.
>> And I also tried some example in the Spring Framework,to know how it
>> works. I have tried some examples in IOC, MVC and JDBC in the spring
>> framework.
>>
>> Now, I want to use both Drools and Spring Framework in such a way that
>> Spring will have the MVC application and it should validate the rules,
>> which written in the drools (.drl)
>>
>> I don't know how to begin with/what are he configuration files needed
>> to setup. PLease if anyone have the sample coding on Drools with
>> Spring or any other links willl be very useful.
>>
>> And also, guide me what are the things need to be know for Spring with
>> Drools. While I have searched in google, lots of things came up like:
>>
>> Use JSR94... (which is mentioning to configure RuleServiceProvider,
>> RuleRuntime, RuleSet..and others..which seeme to be confusing and not
>> clear)
>>
>> Whether there are any API for drools with spring that DROOLS is
>> supporting..like org.drools.spring.metadata.ArgumentMetadataSource. I
>> don't find these Drools API section
>> http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3 
>>
>> .0.5/apidocs/index.html
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com





More information about the rules-users mailing list