Exception Handling in Rules
by Christie, Blair
Is there a way to capture the rule name for any exceptions that occur in
a .drl file.
That is if there is a null pointer exception in an object is there an
exception handling mechanism to capture the rule name that the failure
occurred on?
Cheers,
Blair Christie
16 years, 7 months
Problems using shadow proxies and Hibernate lazy initialization
by Keith Bennett
I am currently using Drools to validate an extensive object graph.
When I validate a transient object graph (i.e., not persisted via
Hibernate) inside of a JUnit test method, validation occurs
successfully. However, when I retrieve the same object graph from
Hibernate and subsequently validate it, I get the stack trace that
I've included below, but only when I use shadow proxies. When I turn
shadow proxies off, validation runs successfully against the persisted
object graph again. Of course, I'm utilizing lazy association
fetching to improve performance and want to continue utilizing it.
Has anyone run into this same problem, and if so, were you able to
work around it without turning shadow proxies off? Before you ask, my
Hibernate session is open before and after I invoke Drools to perform
validation in the same unit of work (i.e., transaction), so it's not
an issue of not having an active Hibernate session available (I've
verified this through testing).
One more thing. The user guide says that if shadow proxies are turned
off that modifyRetract() should be called before an object is modified
and modifyAssert() should be called after it is modifed. First, what
is the method parameter to these two overloaded methods, Object or
FactHandle (both exist)? Second, I don't see modifyAssert() available
in the library, just modifyInsert(). Should the documentation change
to read modifyInsert() instead of modifyAssert()? If so, again with
which parameter?
I appreciate any insight you may have!
Here's the stack trace:
org.hibernate.LazyInitializationException: failed to lazily initialize
a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.PersistentSet.addAll(PersistentSet.java:244)
at org.drools.util.ShadowProxyUtils.cloneObject(ShadowProxyUtils.java:76)
at com.cbi.domain.loan.indirect.IndirectLoanShadowProxy.getCustomers(Unknown
Source)
at org.drools.base.com.cbi.domain.loan.indirect.IndirectLoan28409161$getCustomers.getValue(Unknown
Source)
at org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
at org.drools.rule.Declaration.getValue(Declaration.java:198)
at LoanValidationBusinessRules.Rule_A_Loan_must_have_at_least_one_Customer_0Eval0Invoker.evaluate(Rule_A_Loan_must_have_at_least_one_Customer_0Eval0Invoker.java:12)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:72)
at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:145)
at org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:682)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceHelper.executeRules(DroolsBusinessRulesServiceHelper.java:77)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceHelper.validate(DroolsBusinessRulesServiceHelper.java:66)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceImpl.validate(DroolsBusinessRulesServiceImpl.java:97)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy4.validate(Unknown Source)
at com.cbi.service.loan.indirect.impl.IndirectLoanManagementServiceImpl.submitForBooking(IndirectLoanManagementServiceImpl.java:680)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy6.submitForBooking(Unknown Source)
at com.cbi.service.loan.indirect.impl.LoanManagementServiceImplTestCase.testSubmitLoanForBooking(LoanManagementServiceImplTestCase.java:116)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
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.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
2008-04-02 16:48:32,691 ERROR
org.hibernate.LazyInitializationException - failed to lazily
initialize a collection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize
a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
at org.hibernate.collection.PersistentSet.isEmpty(PersistentSet.java:146)
at LoanValidationBusinessRules.Rule_A_Loan_must_have_at_least_one_Customer_0.eval0(Rule_A_Loan_must_have_at_least_one_Customer_0.java:38)
at LoanValidationBusinessRules.Rule_A_Loan_must_have_at_least_one_Customer_0Eval0Invoker.evaluate(Rule_A_Loan_must_have_at_least_one_Customer_0Eval0Invoker.java:16)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:72)
at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:145)
at org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:682)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceHelper.executeRules(DroolsBusinessRulesServiceHelper.java:77)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceHelper.validate(DroolsBusinessRulesServiceHelper.java:66)
at com.cbi.service.loan.indirect.impl.DroolsBusinessRulesServiceImpl.validate(DroolsBusinessRulesServiceImpl.java:97)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy4.validate(Unknown Source)
at com.cbi.service.loan.indirect.impl.IndirectLoanManagementServiceImpl.submitForBooking(IndirectLoanManagementServiceImpl.java:680)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy6.submitForBooking(Unknown Source)
at com.cbi.service.loan.indirect.impl.LoanManagementServiceImplTestCase.testSubmitLoanForBooking(LoanManagementServiceImplTestCase.java:116)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
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.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
16 years, 7 months
Drools Eclipse Plugin Problem
by Seema Richard
Hi all,
I have added the Drools 4.0.6 plugin in my Eclipse v 3.2.2.
I have the plugin jar containing all the required classes in the
org.drools.eclipse_4.0.6.jar which is added to the plugins folder of
Eclipse. But I'm getting this error when I attempt to open a .drl file.
java.lang.ClassNotFoundException:
org.drools.eclipse.editors.DRLRuleEditor2
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLo
ader.java:402)
If I click on the 'Drools Preferences' page in Eclipse preferences, I
get
this error.
Plug-in org.drools.eclipse was unable to load class
org.drools.eclipse.preferences.DroolsPreferencePage.
I looked at the console log of Eclipse and saw the following errors when
Eclipse started loading.
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
parsedRules cannot be resolved
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
parsedRules cannot be resolved
The type java.lang.Class cannot be resolved. It is indirectly
referenced
from required .class files
The method getContent() is undefined for the type
AbstractRuleEditor
The method getContent() is undefined for the type
AbstractRuleEditor
String cannot be resolved to a type
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
String cannot be resolved to a type
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
compiledRules cannot be resolved
ruleInfoByClassNameMap cannot be resolved
The method getClassName() is undefined for the type
DRLInfo.RuleInfo
functionInfoByClassNameMap cannot be resolved
The method getClassName() is undefined for the type
DRLInfo.FunctionInfo
parsedRules cannot be resolved
Cannot throw the type DroolsParserException
String cannot be resolved to a type
Cannot throw the type DroolsParserException
The type java.lang.Thread cannot be resolved. It is indirectly
reference
d from required .class files
The type java.io.File cannot be resolved. It is indirectly
referenced fr
om required .class files
The type java.net.URL cannot be resolved. It is indirectly
referenced fr
om required .class files
String cannot be resolved to a type
String cannot be resolved to a type
The hierarchy of the type MyResourceVisitor is inconsistent
Implicit super constructor Object() is undefined for default
constructor
. Must define an explicit constructor
Cannot throw the type CoreException
at org.drools.eclipse.DroolsEclipsePlugin.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:136)
... 72 more
Root exception:
java.lang.Error: Unresolved compilation problems:
The type java.io.InputStream cannot be resolved. It is
indirectly
refere
nced from required .class files
The type java.lang.ClassLoader cannot be resolved. It is
indirectly
refe
renced from required .class files
The type java.io.IOException cannot be resolved. It is
indirectly
refere
nced from required .class files
The type java.io.Reader cannot be resolved. It is indirectly
referenced
from required .class files
The type java.lang.Exception cannot be resolved. It is
indirectly
refere
nced from required .class files
The import java.io.Reader cannot be resolved
The import java.util.HashMap cannot be resolved
The import java.util.Iterator cannot be resolved
The import java.util.List cannot be resolved
The import java.util.Map cannot be resolved
The import java.util.MissingResourceException cannot be resolved
The import java.util.ResourceBundle cannot be resolved
The hierarchy of the type DroolsEclipsePlugin is inconsistent
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
ResourceBundle cannot be resolved to a type
Map cannot be resolved to a type
HashMap cannot be resolved to a type
Map cannot be resolved to a type
HashMap cannot be resolved to a type
Map cannot be resolved to a type
HashMap cannot be resolved to a type
Map cannot be resolved to a type
HashMap cannot be resolved to a type
Map cannot be resolved to a type
HashMap cannot be resolved to a type
Exception cannot be resolved to a type
IDroolsConstants.CACHE_PARSED_RULES cannot be resolved
The constructor Object() is undefined
IDroolsConstants.CACHE_PARSED_RULES cannot be resolved
The type java.lang.Boolean cannot be resolved. It is indirectly
referenc
ed from required .class files
java.lang.Boolean cannot be resolved
parsedRules cannot be resolved
compiledRules cannot be resolved
ruleInfoByClassNameMap cannot be resolved
functionInfoByClassNameMap cannot be resolved
Exception cannot be resolved to a type
resourceBundle cannot be resolved
parsedRules cannot be resolved
compiledRules cannot be resolved
Iterator cannot be resolved to a type
colors cannot be resolved
String cannot be resolved to a type
String cannot be resolved to a type
ResourceBundle cannot be resolved to a type
The method getResourceBundle() is undefined for the type
DroolsEclipsePl
ugin
MissingResourceException cannot be resolved to a type
ResourceBundle cannot be resolved to a type
resourceBundle cannot be resolved
resourceBundle cannot be resolved
ResourceBundle cannot be resolved
MissingResourceException cannot be resolved to a type
resourceBundle cannot be resolved
resourceBundle cannot be resolved
String cannot be resolved to a type
String cannot be resolved to a type
PLUGIN_ID cannot be resolved
Throwable cannot be resolved to a type
Throwable cannot be resolved to a type
The method getUniqueIdentifier() is undefined for the type
DroolsEclipse
Plugin
String cannot be resolved to a type
colors cannot be resolved
String cannot be resolved to a type
colors cannot be resolved
IDroolsConstants.BUILD_ALL cannot be resolved
IDroolsConstants.EDITOR_FOLDING cannot be resolved
IDroolsConstants.CACHE_PARSED_RULES cannot be resolved
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
parsedRules cannot be resolved
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
parsedRules cannot be resolved
The type java.lang.Class cannot be resolved. It is indirectly
referenced
from required .class files
The method getContent() is undefined for the type
AbstractRuleEditor
The method getContent() is undefined for the type
AbstractRuleEditor
String cannot be resolved to a type
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
String cannot be resolved to a type
Cannot throw the type DroolsParserException
compiledRules cannot be resolved
compiledRules cannot be resolved
ruleInfoByClassNameMap cannot be resolved
The method getClassName() is undefined for the type
DRLInfo.RuleInfo
functionInfoByClassNameMap cannot be resolved
The method getClassName() is undefined for the type
DRLInfo.FunctionInfo
parsedRules cannot be resolved
Cannot throw the type DroolsParserException
String cannot be resolved to a type
Cannot throw the type DroolsParserException
The type java.lang.Thread cannot be resolved. It is indirectly
reference
d from required .class files
The type java.io.File cannot be resolved. It is indirectly
referenced fr
om required .class files
The type java.net.URL cannot be resolved. It is indirectly
referenced fr
om required .class files
String cannot be resolved to a type
String cannot be resolved to a type
The hierarchy of the type MyResourceVisitor is inconsistent
Implicit super constructor Object() is undefined for default
constructor
. Must define an explicit constructor
Cannot throw the type CoreException
at org.drools.eclipse.DroolsEclipsePlugin.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:136)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:962)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:317)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:256)
at
org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:
342)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.preFindL
ocalClass(EclipseLazyStarter.java:88)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(C
lasspathManager.java:412)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalCla
ss(DefaultClassLoader.java:189)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(
BundleLoader.java:334)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(Bundl
eLoader.java:386)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(Bundl
eLoader.java:347)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(De
faultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(Bundl
eLoader.java:278)
at
org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleH
ost.java:227)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(Abs
tractBundle.java:1245)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createEx
ecutableExtension(RegistryStrategyOSGI.java:147)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createExecutable
Extension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.createExecuta
bleExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandle.createE
xecutableExtension(ConfigurationElementHandle.java:51)
at
org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:24
2)
at
org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at
org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlug
in.java:238)
at
org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode.createPage(Wo
rkbenchPreferenceNode.java:46)
at
org.eclipse.jface.preference.PreferenceDialog.createPage(PreferenceDi
alog.java:1241)
at
org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.createPage(F
ilteredPreferenceDialog.java:315)
at
org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDial
og.java:1134)
at
org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(Fil
teredPreferenceDialog.java:438)
at
org.eclipse.jface.preference.PreferenceDialog$8.selectionChanged(Pref
erenceDialog.java:661)
at
org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.jav
a:839)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at
org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
at
org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(S
tructuredViewer.java:837)
at
org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(Structure
dViewer.java:1143)
at
org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(Structure
dViewer.java:1163)
at
org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrate
gy.java:236)
at
org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:230)
at
org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:404)
at
org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.ja
va:123)
at
org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at
org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesActi
on.java:65)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:539)
at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContri
butionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionC
ontributionItem.java:400)
at
org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.jav
a:422)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95
)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformAct
ivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runAppli
cation(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ec
lipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
--
View this message in context:
http://www.nabble.com/Drools-Eclipse-Plugin-Problem-tp16446887p16446887.
html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
RuleAgent is not retrieving updated rule?
by Andres Bonifacio
Here's how I did it:
1. I successfully deployed jbrms and insurance webapp (both using
Drools v 4.0.6) successfully to JBoss 4.0.5.
2. From the jbrms webapp, I modified the "Night Vehicle Place"
technical rule, just change the sysout statement.
3. Rebuild the binary package. Recreate the snapshot deployment -
InsuranceDemo.
4. Retest using the insurance url and see if the new version (Remember
the sysout stmt change in #2.) of the rule will be picked up by the
RuleAgent. Alas it did NOT.
Now this is of course inside a container environment. What is strange
though is if you tried to run the InsuranceCalculateTest which is a
JUnit test it recognize the rule change immediately. Which I think
should be the behavior exhibited on a container environment as well.
Right?
16 years, 7 months
and/or connectives using DSL
by mpturkia
Hey everyone,
I've been trying to figure out a way to use the OR connective in a similar
manner as the AND connective using the DSL definition, but can't quite
figure out how this could be done. Currently I can do the following:
rule "Rule1"
when
MyObject
- value1 equals 5
- value2 equals 10
- value3 equals 15
then
System.out.println("Value1 is 5 and value2 is 10 and value3 is
15.");
end
DSL file looks like:
[when][]{obj}=$obj : {obj}()
[when][]- {var} equals {value}={var} == {value}
This results in the rule as:
rule "Rule1"
when
$obj : MyObject(value1 == 5, value2 == 10, value3 == 15)
then
System.out.println("Value1 is 5 and value2 is 10 and value3 is
15.");
end
What I would like to do is use OR as well instead of just and. So I would
like the rule to look like:
rule "Rule1"
when
MyObject
- value1 equals 5
- value2 equals 10
OR value3 equals 15
then
System.out.println("Value1 is 5 and value2 is 10 or value3 is 15.");
end
This I'd like to result in a rule like:
rule "Rule1"
when
$obj : MyObject(value1 == 5, value2 == 10 || value3 == 15)
then
System.out.println("Value1 is 5 and value2 is 10 or value3 is 15.");
end
I don't want to use the 'or' command since that splits the rule into two
rules. I'd like to use the connective or '||' with the DSL syntax. Does
anybody know a work-around to get this working?
I've tried using sentence fragments to get it done, but the parser doesn't
match the patterns quite like I need them to match.
And of course, if there's a syntax already available (',' = '-', '||' = ??)
I'd be thrilled if someone pointed it out to me :)
Thanks!
Markus
--
View this message in context: http://www.nabble.com/and-or-connectives-using-DSL-tp16448654p16448654.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Problem with mvel trying to coerce a String to a number
by Brett M. Bergquist
I have a fact that a Map of Strings:
private Map<String,String> property = new HashMap<String,String>();
/**
* Gets the property map
* @return The property map
*/
public Map<String, String> getProperty() {
return property;
}
/**
* Sets the property map
* @param property The new property map
*/
public void setProperty(Map<String, String> property) {
this.property = property;
}
Inside a rule, I am trying to use this map and the rule looks like:
rule "3-new Notificationcp9145Authentication"
when
notification : Notificationcp9145Authentication($againstId :
targetID,
$badHostString : badHostString,
$applicationName : applicationName)
not AlarmEventFact(type == AlarmType.ACTIVE,
alarmName == "cp9145Authentication",
againstId == $againstId,
property['badHostString'] == $badHostString,
property['applicationName'] ==
$applicationName
)
then
alarmEventKnowledge.create(drools, notification,
"cp9145Authentication",
new Pair("badHostString",
$badHostString),
new Pair("applicationName",
$applicationName));
end
The problem that I am having is that the result of the lookup of
"property['badHostString']" is a string that looks like "192.168.1.19"
(an IP address). The "badHostString" property of the
Notificationcp9145Authentication fact is a String. I am getting an
error when the rule is fired. It appears that the
"property['badHostString']" is trying to be interpreted as a number.
Here is some of the stack traceback:
Caused by: java.lang.NumberFormatException
at java.math.BigDecimal.<init>(BigDecimal.java:362)
at java.math.BigDecimal.<init>(BigDecimal.java:647)
at
org.mvel.math.IEEEFloatingPointMath.getBigDecimalFromType(IEEEFloatingPointMath.java:373)
at
org.mvel.math.IEEEFloatingPointMath._doOperations(IEEEFloatingPointMath.java:83)
at
org.mvel.math.IEEEFloatingPointMath.doOperation(IEEEFloatingPointMath.java:40)
at org.mvel.util.ParseTools.doOperations(ParseTools.java:753)
at
org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at
org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
at org.mvel.MVEL.executeExpression(MVEL.java:202)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:36)
at
org.drools.rule.PredicateConstraint.isAllowedCachedLeft(PredicateConstraint.java:206)
If I change the property value to be something like "abc" then this does
not occur, so I am pretty user that it is trying to convert
"192.168.1.19" to a number even though it is already a string and the
$badHostString is a String as well.
How can I force this to not try to convert?
Any help will be greatly appreciated.
16 years, 7 months
Firing Rules from DB (Dynamic Rules)
by hanumesh.m
Hi,
As rules may keep on changing, I am using database to store the datails of
a rule. Say in table Transaction (ruleName, fileMask, fromQ, ToQ,transType).
An admin application may keep on adding/editing these rules as and when
required.
I have a mule application, where in a mule Component will poll a specific
directory for a file. The file name will follow certain guidelines so that,
I can check the fileName against the fileMask in the database(Transaction
table. Assume there are rows as follows:
'Rule ABC', 'ABC-834','ABC-834-edi','ABC-834.xml','834' (indicates when
fileName has mask 'ABC-834' then the fromQueue for it is 'ABC-834.edi' and
toQueue is 'ABC-834.xml'
'Rule XYZ', 'XYZ-834','XYZ-834.edi','XYZ-834.xml','834'
'Rule JIM', 'JIM-850','JIM-850.edi','JIM-850.xml','850' so fileMask's r
('ABC-834','XYZ-834','JIM-850')
The rules check will be in the .drl file, which will check the fileName
against each row(a bean repr. of eachrow) of the database and when ever
finds the match, obtains the fromQ and toQ of that matching row and updates
the fact object Message.
Further activities of the Mule Component makes use of updated values(by
rules Engine) of Message object to decide on the target queues for the
content of the file.
I have issues in implementing this and unable to fire the rules
successfully. Here I am facing issues of using the two objects in
WorkingMemory (Message and RuleVO-representing a rows information of DB)
If anyone has worked in similar areas please help me out in solving this
problem. I am uploading the files Bean(Message,TransactionVO), Business
object(commonBO) (using applyRule() method), drl(Test.drl, and hardcoded
working version of Test_old.drl file )
In Mule UMO Component I will call commonBo's applyRule();
/// here is the code in Mule Component
cbo = new CommonBO();
LoadContextPath.setEdiFileName((String)msg.getProperty("originalFilename"));
cbo.applyRule();
Thanks in advance,
Hanumesh M
http://www.nabble.com/file/p16443580/DynRules.zip DynRules.zip
--
View this message in context: http://www.nabble.com/Firing-Rules-from-DB-%28Dynamic-Rules%29-tp16443580...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Drools Pattern Matching
by hanumesh.m
Hi,
I am writing a rule which checks for the presence of substring in a
string. Hard coding rule works fine but if I am using variables which may
have dynamic values giving problems. How to write code equivalent of
hardcoding version.
HardCode verson :
-------------------
rule "Process 834"
no-loop
when
m: Message( fileName matches "^.*ABC-834.*$")
then
System.out.println( "Reading Rule for 834 ..." );
m.setFromQ("ABC.834.EDI");
m.setToQ("ABC.834.XML");
m.setProcess("834");
update( m );
end
Dynamic Version:
//fileName has data 'ABC-834-test-100.edi'
// p.FILEMASK has data 'ABC-834'
----------------
rule "Process ALL"
no-loop
when
p: TransactionVO()
m: Message( fileName matches p.FILEMASK) // I can't say as (matches
"^.*"+p.FILEMASK+".*$")
//the above st should be like if fileName has FILEMASK in it
then
System.out.println( "Reading Rule for ..." + p.NAME );
m.setFromQ(p.FROM_Q);
m.setToQ(p.TO_Q);
m.setProcess(p.TRANS_TYPE);
update( m );
end
--
View this message in context: http://www.nabble.com/Drools-Pattern-Matching-tp16442998p16442998.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Problem deploying BRMS 4.0.6
by Robert Morse
Hello,
I'm running JBoss AS 4.2.2.GA and have downloaded and built the drools-
jbrms.war from the 4.0.6 source distribution under Mac OS X 10.5.2.
When I deploy drools-jbrms.war, I get the following error:
11:52:10,028 WARN [config] Unable to process deployment descriptor
for context 'JBoss Rules BRMS'
11:52:10,191 ERROR [[/drools-jbrms]] Exception sending context
initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
java.lang.LinkageError: Class javax/el/ELResolver violates loader
constraints
followed by the rest of the stack trace.
If I download the pre-built drools-jbrms.war (also version 4.0.6) from
the JBoss website it deploys and works just fine.
I exploded the generated war file and discovered some extra jars not
in the pre-built version. They are:
jaxme-api-0.3.jar
pull-parser-2.jar
relaxngDatatype-20030807.jar
stax-api-1.0.jar
xpp3-1.1.3.4.O.jar
xsdlib-20030807.jar
Not sure why these are included, or how the pre-built version is
actually built. My steps were: mvn clean ; mvn install
Any suggestions?
16 years, 7 months
Upgrading to 4.0.4
by Narendra Valada
Hi,
I am upgrading to Drools 4.0.4 and I am getting this exception when
executing this rule:
rule "insert iterator"
when
somecondition
then
insert(Arrays.asList(some array).iterator());
end
Here is the exception. Is this a bug? Disabling shadow copy is not really an
option for this application.
Exception in thread "pool-1-thread-1" java.lang.IllegalAccessError: class
org.drools.shadow.java.util.AbstractList$ItrShadowProxy cannot access its
superclass java.util.AbstractList$Itr
at java.lang.ClassLoader.defineClass1(*Native Method*)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.drools.rule.MapBackedClassLoader.fastFindClass(*
MapBackedClassLoader.java:60*)
at org.drools.rule.MapBackedClassLoader.loadClass(*MapBackedClassLoader.java
:79*)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.drools.reteoo.Rete$ClassObjectTypeConf.loadOrGenerateProxy(*Rete.java
:547*)
at org.drools.reteoo.Rete$ClassObjectTypeConf.defineShadowProxyData(*
Rete.java:494*)
at org.drools.reteoo.Rete$ClassObjectTypeConf.<init>(*Rete.java:461*)
at org.drools.reteoo.Rete.assertObject(*Rete.java:152*)
at org.drools.reteoo.ReteooRuleBase.assertObject(*ReteooRuleBase.java:192*)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(*ReteooWorkingMemory.java
:71*)
at org.drools.common.AbstractWorkingMemory.insert(*
AbstractWorkingMemory.java:909*)
at org.drools.common.AbstractWorkingMemory.insert(*
AbstractWorkingMemory.java:881*)
at org.drools.base.DefaultKnowledgeHelper.insert(*
DefaultKnowledgeHelper.java:67*)
at org.drools.base.DefaultKnowledgeHelper.insert(*
DefaultKnowledgeHelper.java:61*)
Thanks,
Narendra Valada
16 years, 7 months