ClassCast Exception loading Packages built using BRMS 4.0.4
by pavi de alwis
I have a scenario where I'm building the rules packages using the BRMS and
using a standalone drools-core deployment to load these binaries. However,
with the 4.0.4 release the following exception is generated by the
Package.readExternal(…) method during de-serialization.
It's using the BRMS 4.0.4 distribution war and the drools-core.jar
4.0.4available via Maven.
------------------------------------------------------------------------------------------------------------------------------------------------------
java.lang.ClassCastException: org.drools.rule.Package
at org.drools.rule.Package.readExternal(Package.java:176)
at com.gbv.platform.rules.drools.impl.RuleRuntimeImpl.init(
RuleRuntimeImpl.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod
(AbstractAutowireCapableBeanFactory.java
:1214)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods
(AbstractAutowireCapableBeanFactory.java:1179
)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
(AbstractAutowireCapableBeanFactory.java:1145)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(
AbstractBeanFactory.java:251)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:144)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:248)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
at
org.springframework.osgi.service.exporter.OsgiServiceFactoryBean.afterPropertiesSet
(OsgiServiceFactoryBean.java:271)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods
(AbstractAutowireCapableBeanFactory.java:1175
)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
(AbstractAutowireCapableBeanFactory.java:1145)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(
AbstractBeanFactory.java:251)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:144)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:248)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:276)
at
org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:360)
at
org.springframework.osgi.context.support.AbstractRefreshableOsgiBundleApplicationContext.refresh
(AbstractRefreshableOsgiBundleApplicationCo
ntext.java:170)
at
org.springframework.osgi.extender.support.ServiceDependentOsgiBundleXmlApplicationContext.refresh
(ServiceDependentOsgiBundleXmlApplicationC
ontext.java:76)
at
org.springframework.osgi.extender.support.ApplicationContextCreator.run(
ApplicationContextCreator.java:155)
at java.lang.Thread.run(Thread.java:595)
Error Loading DROOLS Package : org.drools.rule.Package
------------------------------------------------------------------------------------------------------------------------------------------------------
BTW, Running the debugger through it I was able to get the stack trace
below. This occurs on the first call to Package.readExternal(ObjectInput)
line: 176 after returning from ObjectInputStream.readObject() line: 348
------------------------------------------------------------------------------------------------------------------------------------------------------
Package.readExternal(ObjectInput) line: 176
ObjectInputStream.readExternalData(Externalizable,
ObjectStreamClass) line: 1755
ObjectInputStream.readOrdinaryObject(boolean) line:
1717
ObjectInputStream.readObject0(boolean) line: 1305
ObjectInputStream.readObject() line: 348
Package.readExternal(ObjectInput) line: 176
RuleRuntimeImpl.init() line: 61
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line:
39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeCustomInitMethod(String,
Object, String, boolean) line: 1214
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeInitMethods(String,
Object, RootBeanDefinition) line: 1179
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initializeBean(String,
Object, RootBeanDefinition) line: 1145
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String,
RootBeanDefinition, Object[]) line: 427
AbstractBeanFactory$1.getObject() line: 251
DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String,
ObjectFactory) line: 144
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String,
Class, Object[]) line: 248
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String)
line: 160
OsgiServiceFactoryBean.afterPropertiesSet() line: 271
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeInitMethods(String,
Object, RootBeanDefinition) line: 1175
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initializeBean(String,
Object, RootBeanDefinition) line: 1145
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String,
RootBeanDefinition, Object[]) line: 427
AbstractBeanFactory$1.getObject() line: 251
DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String,
ObjectFactory) line: 144
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String,
Class, Object[]) line: 248
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String)
line: 160
DefaultListableBeanFactory.preInstantiateSingletons() line:
276
ServiceDependentOsgiBundleXmlApplicationContext(AbstractApplicationContext).refresh()
line: 360
ServiceDependentOsgiBundleXmlApplicationContext(AbstractRefreshableOsgiBundleApplicationContext).refresh()
line: 170
ServiceDependentOsgiBundleXmlApplicationContext.refresh() line:
76
ApplicationContextCreator.run() line: 155
Thread.run() line: 595
------------------------------------------------------------------------------------------------------------------------------------------------------
Cheers,
Pavi
17 years, 11 months
Bug with removePackage/removeRule
by Dirk Bergstrom
I believe this is a bug. After I remove a rule or package from the ruleBase,
newly added rules fail to "see" objects in the working memory. Attached is a
test case, and below is the output from it.
Drools 4.0.4
Java 1.5.0.13
Start
RuleBase created
Adding rules about 'tom':
package tom;
import test.Tester.Record;
rule "Find tom"
when
$rec : Record( field1 == "tom" )
then
System.out.println("Find 'tom' " + $rec.dump());
end
inserting record 1:"tom",
inserting record 2:"fred",
inserting record 3:"harry",
inserting record 4:"fred",
inserting record 5:"ed",
inserting record 6:"tom",
inserting record 7:"sreeni",
inserting record 8:"jill",
inserting record 9:"ed",
inserting record 10:"tom",
fireAllRules()
Find 'tom' 10:"tom",
Find 'tom' 6:"tom",
Find 'tom' 1:"tom",
adding rules about 'fred':
package fred;
import test.Tester.Record;
rule "Find fred"
when
$rec : Record( field1 == "fred" )
then
System.out.println("Find 'fred' " + $rec.dump());
end
Find 'fred' 4:"fred",
Find 'fred' 2:"fred",
As expected, 'fred' is found.
Removing package tom (same bug if you use "ruleBase.removeRule").
ruleBase.removePackage("tom");
adding rules about 'ed':
package ed;
import test.Tester.Record;
rule "Find ed"
when
$rec : Record( field1 == "ed" )
then
System.out.println("Find 'ed' " + $rec.dump());
end
No 'ed' is found!
Changing record 3 to 'ed'
fireAllRules()
Find 'ed' 3:"ed",
Only the newly updated 'ed' is found.
--
Dirk Bergstrom dirk(a)juniper.net
_____________________________________________
Juniper Networks Inc., Computer Geek
Tel: 408.745.3182 Fax: 408.745.8905
17 years, 11 months
Re: [rules-users] Re: Date problem
by Xiandong Su
I just played with it and it works fine for my 4.0.3 version.
----- Original Message ----
From: jack wu <jackxwu(a)yahoo.com>
To: rules-users(a)lists.jboss.org
Sent: Wednesday, January 23, 2008 10:54:39 PM
Subject: [rules-users] Re: Date problem
i copy the following from the Documentation. i thought it means that drools is going to auto convert the string "27-Oct-2007" into a java Date object.
+++++++++
DateThe date format "dd-mmm-yyyy" is supported by default. You can customize this by providing an alternative date format mask as a System property ("drools.dateformat" is the name of the property). If more control is required, use the inline-eval constraint.
Example 6.20. Date Literal Restriction
Cheese( bestBefore < "27-Oct-2007" )
+++++++++++++++++++++++++
Newsgroups: gmane.comp.java.drools.user
Date: 2008-01-23 23:32:42 GMT (4 hours and 13 minutes ago)
Were you compairing Date agaist string here, as your double quotes indicate?
Xiandong
Sent from my iPhone
On Jan 23, 2008, at 17:33, jack wu <jackxwu <at> yahoo.com> wrote:
if i have several levels of java beans, the Date is not working. example:
m:Message( first.second.date > "01-jan-2007" )
Never miss a thing. Make Yahoo your homepage.
17 years, 11 months
BRMS & Remoting API
by safi
Hi,
Accordingly to my last post
(http://www.nabble.com/BRMS-locks-jackrabbit-td15018752.html) I would like
to ask somebody how I can control BRMS via Seam Remoting API.
There is a small example in the Seam documentation which says something
about how to configure the remoting. Documentation says that it is necessary
to insert this piece of code into the web.xml:
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
After I’ve done this I recompiled BRMS and deployed. Now when I point my
browser to the URL where JavaScript files should reside
(http://...../seam/resource/remoting/resource/remote.js
) I get HTTP 404.
Any idea? Thx
Safi
--
View this message in context: http://www.nabble.com/BRMS---Remoting-API-tp15063314p15063314.html
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 11 months
Re: [rules-users] Date problem
by Xiandong Su
Were you compairing Date agaist string here, as your double quotes indicate?
Xiandong
Sent from my iPhone
On Jan 23, 2008, at 17:33, jack wu <jackxwu(a)yahoo.com> wrote:
if i have several levels of java beans, the Date is not working. example:
m:Message( first.second.date > "01-jan-2007" )
receive exceptions such as:
Caused by: java.lang.ClassCastException: java.lang.String
at java.util.Date.compareTo(Date.java:112)
at org.mvel.math.IEEEFloatingPointMath.doOperationNonNumeric(IEEEFloatingPointMath.java:111)
at org.mvel.math.IEEEFloatingPointMath._doOperations(IEEEFloatingPointMath.java:90)
at org.mvel.math.IEEEFloatingPointMath.doOperation(IEEEFloatingPointMath.java:41)
at org.mvel.util.ParseTools.doOperations(ParseTools.java:798)
at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:108)
at org.mvel.MVEL.executeExpression(MVEL.java:230)
at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:36)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:210)
Looking for last minute shopping deals? Find them fast with Yahoo! Search.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
17 years, 11 months
Date problem
by jack wu
if i have several levels of java beans, the Date is not working. example:
m:Message( first.second.date > "01-jan-2007" )
receive exceptions such as:
Caused by: java.lang.ClassCastException: java.lang.String
at java.util.Date.compareTo(Date.java:112)
at org.mvel.math.IEEEFloatingPointMath.doOperationNonNumeric(IEEEFloatingPointMath.java:111)
at org.mvel.math.IEEEFloatingPointMath._doOperations(IEEEFloatingPointMath.java:90)
at org.mvel.math.IEEEFloatingPointMath.doOperation(IEEEFloatingPointMath.java:41)
at org.mvel.util.ParseTools.doOperations(ParseTools.java:798)
at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:108)
at org.mvel.MVEL.executeExpression(MVEL.java:230)
at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:36)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:210)
---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.
17 years, 11 months
Re: [rules-users] Drools and event based decisions, i.e. streaming market quotes
by Mark Proctor
Henry Canterburry wrote:
> Mark,
>
> Thanks for the reply. My timeframe matches the one you mentioned
> although I would naturally be looking for working and production ready
> functionality. In the meantime, did any of the approaches I mentioned
> make any sense or would you say that drools is not the right tool at
> this point? I do have helper classes and other intermediary data
> caching approaches at this time that permit me to query past data and
> an entire streaming architecture to feed data.
>
> Thanks
> HC
>
>
> Mark Proctor wrote:
>> What's your time scale for this? We are currently implementing CEP
>> extendions to the language and engine which will do all of this for
>> you, we'll have a milestone release out in february when you can
>> first play with this and aiming to get a full release end of Q1 start
>> of Q2.
>>
>> Mark
>> Henry Canterburry wrote:
>>> What would be the best approach using drools to handle event driven
>>> decisions based on streaming data? In my case I am looking for a
>>> typical stock market scenario. Ticker quotes usually come in at
>>> second increments and depending on how many ticker symbols you
>>> subscribe to at any one time, there can be a lot of data coming and
>>> and changing every second. However, there probably isn't a need to
>>> keep large quantities of historic data in memory...maybe the last
>>> 200-500 ticks. The outputs are if a stock should be sold or bought,
>>> at what quantity and what price. Once the decision has been made, we
>>> need to make sure it does not persist past the point of being valid
>>> given the state of that data.
>>>
>>> If I have rules that are meant to derive/calculate info and
>>> decisions from the streaming data, what is the best integration
>>> architecture for the rule engine with the rest of the application?
>>>
>>> Stateful session which constantly updates the ticks in working
>>> memory and queries the memory for results on an ongoing basis? In
>>> this case, the session would be kept alive for as long as the data
>>> stream is going (i.e. hours)? This approach would require very
>>> rigorous working memory management and all the objects in it.
>>>
>>> Or...loop constantly over a stateless session for each tick? This
>>> would reduce the need to manage the number of objects in working
>>> memory since only the amount needed would be inserted in the first
>>> place and read back the results? Sounds inefficient and with lots of
>>> overhead.
really don't know. Try the stateful approach first and see how that pans
out.
>>>
>>> Also, what about multi-threaded environments? Any potential for
>>> conflicts between concurrent session instances?
events are normally stateless, so you should have no problem there.
Mutable objects in different threads being updated is of course a
problem, shadow proxies can help a little there - but you still need to
be careful.
>>>
>>> Thanks
>>> HC
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>>
>
>
17 years, 11 months