When I use the API KnowledgeBaseImpl.removeRule() in Drools 7.56.0.Final, NPE was thrown.
We use template to create rule, the content is like:
package drools.template;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\n\nrule "651657095963213824-651657096034516992"\n when\n $p: com.seewo.ucp.hub.domain.strategy.aggregation.StrategyRule((deviceDto.lamp == com.seewo.ucp.hub.domain.device.enums.DeviceEventTypeEnum.ONLINE) && (date ==1628645220445))\n then\n $p.setResult(Boolean.TRUE);\nend\n\n\n
The add rule code:
KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeBuilder.add(ResourceFactory.newByteArrayResource(drlContent.getBytes(StandardCharsets.UTF_8)), ResourceType.DRL);
if (knowledgeBuilder.hasErrors()) {
return;
}
((KnowledgeBaseImpl) kieBase).addPackages(knowledgeBuilder.getKnowledgePackages());
The remove rule code:
if (isRuleExist(ruleName)) {
kieBase.removeRule(packageName, ruleName);
}
Here, isRuleExist() is a function to check if the rule exists or not: kieBase.getRule(packageName, ruleName) != null.
When I removed the rule, NPE thrown:
java.lang.NullPointerException: null
at org.drools.core.phreak.AddRemoveRule.iterateLeftTuple(AddRemoveRule.java:1081) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.phreak.AddRemoveRule.visitChild(AddRemoveRule.java:996) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.phreak.AddRemoveRule.lambda$processLeftTuplesOnLian$1(AddRemoveRule.java:954) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.common.DefaultFactHandle$SingleLinkedTuples.forEachLeftTuple(DefaultFactHandle.java:739) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.common.DefaultFactHandle.forEachLeftTuple(DefaultFactHandle.java:935) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.phreak.AddRemoveRule.processLeftTuplesOnLian(AddRemoveRule.java:949) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.phreak.AddRemoveRule.processLeftTuples(AddRemoveRule.java:870) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.phreak.AddRemoveRule.removeRule(AddRemoveRule.java:179) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.reteoo.ReteooBuilder.removeTerminalNode(ReteooBuilder.java:191) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.reteoo.ReteooBuilder.removeRules(ReteooBuilder.java:177) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.impl.KnowledgeBaseImpl.lambda$removeRule$6(KnowledgeBaseImpl.java:1559) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.impl.KnowledgeBaseImpl.enqueueModification(KnowledgeBaseImpl.java:748) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
at org.drools.core.impl.KnowledgeBaseImpl.removeRule(KnowledgeBaseImpl.java:1543) ~[drools-core-7.56.0.Final.jar:7.56.0.Final]
any help is appreciated
Related
I'm creating an integration test to my flutter app but I get this error when finding an TextInput and trying to type inside.
The error: 'package:flutter_test/src/binding.dart': Failed assertion: line 1649 pos 12: '_pendingFrame == null': is not true.
The code:
final Finder email = find.byWidgetPredicate(
(widget) => widget is FutXTextField && widget.title == 'EMAIL',
);
expect(email, findsOneWidget,
reason: " Só pode haver um botão de escrever email");
await tester.enterText(email, "teste#teste.teste");
I didn`t find it anywhere on the internet what this error is.
Does anyone had this exception before and has any idea of how to solve it?
I had the same error when the app that I was running the test on threw an exception, if you check the logs do you see any errors occurring before your test failed?
I'd like to execute a "SELECT" command with only one parameter: createBy (actually I don't know how does the dao.xml manage the first generics parameter, so in my opinion, there is only one parameter), why does Mybatis throw the exception: parameter 'updateBy' not found? with the if condition: <if test="updateBy != null and updateBy.id != null and updateBy.id != ''">
The dao.java is:
public List<T> findList(T entity, #Param("createBy") User createBy);
And the select sql in dao.xml is:
<select id="findList" resultType="ChenminIndicator">
SELECT
<include refid="chenminIndicatorColumns"/>
FROM chenmin_indicator a
<include refid="chenminIndicatorJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
<if test="createBy != null and createBy.id != null and createBy.id != ''">
AND a.create_by = #{createBy.id}
</if>
<if test="updateBy != null and updateBy.id != null and updateBy.id != ''">
AND a.update_by = #{updateBy.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
I have a issues as below while comparing date in MyBatis as below
Caused by: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
Both of java 'applyDate' and Postgres 'org_info.apply_date' type are Date
Here is my configuration:
<sql id="searchCriteriaSql">
<where>enter code here
<if test="applyDate != null && applyDate != '' ">
<![CDATA[org_info.apply_date <= #{applyDate}]]>
</if>
<if test="ogrNm != null && ogrNm != '' ">
<bind name="ogrNmKey"
value="'%' + ogrNm + '%'" />
AND ( upper(org_info.org_nm) LIKE upper(#{ogrNmKey}))
</if>
</where>
</sql>
The root cause comes from
<![CDATA[org_info.apply_date <= #{applyDate}]]>
Please help to give answer
I am using drools with optaplanner but when i start project sometimes it returns this exception and sometimes didn't return any exception with same code.
THE RULE:
rule "groupedSteps"
when
$Act : Action(this !=null,Step != null,$step : getStepType().getId(),isCanItBeGrouped(),period !=null)
accumulate(
Action(this != null,Step != null,period != null,isCanItBeGrouped(),getStepType().getId() == $step,$startTime : getStartTime(),getStartTime() >= 0);
$firstStart : min(checkStartTimeIsBigOrEqualToZero($startTime))
)
Action($firstStart == getStartTime(),$step == getStepType().getId(),isCanItBeGrouped() == true,$xMachine : Machine, $employee : Employee,period != null)
Action(this != null,isCanItBeGrouped() == true,getStepType().getId() == $step,$xStartTime : getStartTime(),$xMach : Machine,$xEmployee : Employee,period != null,Employee !=null)
eval($xStartTime < (int)$firstStart || $xEmployee != $employee || $xMachine != $xMach)
then
scoreHolder.addHardConstraintMatch(kcontext, -5);
end
THE checkStartTimeIsBigOrEqualToZero METHOD:
function int checkStartTimeIsBigOrEqualToZero(int startTime)
{
try{
if (startTime >= 0)
return startTime;
else
return 99999;
}
catch (Exception ex)
{
return 99999;
}
}
FULL ERROR:
Exception in thread "AWT-EventQueue-0" Exception executing consequence
for rule "groupedSteps" in org.optaplanner.examples.opnext.solver:
java.lang.UnsupportedOperationException: Accumulate function (min)
used in rule(s) [groupedSteps] does not have reverseSupport at
org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1247)
at
org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:438)
at
org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:379)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:135)
at
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
at
org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34)
at
org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
at
org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1067)
at
org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1014)
at
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1006)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1318)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1309)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1293)
at
org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.calculateScore(DroolsScoreDirector.java:117)
at
org.optaplanner.examples.common.business.SolutionBusiness.getScore(SolutionBusiness.java:218)
at
org.optaplanner.examples.opnext.business.CalculatorClass.bestSolutionChanged(CalculatorClass.java:149)
at
org.optaplanner.examples.common.business.SolutionBusiness.lambda$null$0(SolutionBusiness.java:247)
at
java.awt.event.InvocationEvent.dispatch$$$capture(InvocationEvent.java:311)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java) at
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at
java.awt.EventQueue.access$500(EventQueue.java:97) at
java.awt.EventQueue$3.run(EventQueue.java:709) at
java.awt.EventQueue$3.run(EventQueue.java:703) at
java.security.AccessController.doPrivileged(Native Method) at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.UnsupportedOperationException: Accumulate
function (min) used in rule(s) [groupedSteps] does not have
reverseSupport at
org.drools.core.reteoo.FromNodeLeftTuple.getAccumulatedObjects(FromNodeLeftTuple.java:105)
at
org.drools.core.common.AgendaItem.getObjectsDeep(AgendaItem.java:79)
at
org.drools.core.reteoo.RuleTerminalNodeLeftTuple.getObjectsDeep(RuleTerminalNodeLeftTuple.java:359)
at
org.optaplanner.core.api.score.holder.AbstractScoreHolder.extractJustificationList(AbstractScoreHolder.java:118)
at
org.optaplanner.core.api.score.holder.AbstractScoreHolder.registerConstraintMatch(AbstractScoreHolder.java:88)
at
org.optaplanner.core.api.score.buildin.hardmediumsoft.HardMediumSoftScoreHolder.addHardConstraintMatch(HardMediumSoftScoreHolder.java:58)
at
org.optaplanner.examples.opnext.solver.Rule_groupedSteps547703499.defaultConsequence(Rule_groupedSteps547703499.java:21)
at
org.optaplanner.examples.opnext.solver.Rule_groupedSteps547703499DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source) at
org.optaplanner.examples.opnext.solver.Rule_groupedSteps547703499DefaultConsequenceInvoker.evaluate(Unknown
Source) at
org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:431)
... 30 more
I am attempting to configure Ldap authentication for a Jboss web-app. Jboss loads my module, but does not authenticate credentials that are known to be good. I should point out that my module just extends LdapExtLoginModule without adding any logic. I get the same error when defering directly to LdapExtLoginModule. The error:
PBOX000070: Password invalid/Password required
is returned when I attempt to login. I tracked the error down to a null pointer being thrown by a hashtable.put() operation in org.jboss.security.auth.spi.LdapExtLoginModule.constructInitialLdapContext. Here is the stack trace:
javax.security.auth.login.FailedLoginException: PBOX000070: Password invalid/Password required
at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:284)
at com.alstom.auth.login.ldap.CustomLdapLoginModule.login(CustomLdapLoginModule.java:164)
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 javax.security.auth.login.LoginContext.invoke(LoginContext.java:762)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687)
at javax.security.auth.login.LoginContext.login(LoginContext.java:595)
at org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider.authenticate(AbstractJaasAuthenticationProvider.java:149)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at com.etse.security.SecureMethodAuthenticationManager.authenticate(SecureMethodAuthenticationManager.java:29)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174)
at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:514)
at org.jboss.security.auth.spi.LdapExtLoginModule.constructInitialLdapContext(LdapExtLoginModule.java:742)
at org.jboss.security.auth.spi.LdapExtLoginModule.createLdapInitContext(LdapExtLoginModule.java:463)
at org.jboss.security.auth.spi.LdapExtLoginModule.validatePassword(LdapExtLoginModule.java:340)
at com.alstom.auth.login.ldap.CustomLdapLoginModule.validatePassword(CustomLdapLoginModule.java:152)
at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:281)
... 40 more
The function:
private InitialLdapContext constructInitialLdapContext(String dn, Object credential) throws NamingException
{
String protocol = (String)options.get(Context.SECURITY_PROTOCOL);
String providerURL = (String) options.get(Context.PROVIDER_URL);
if (providerURL == null)
providerURL = "ldap://localhost:" + ((protocol != null && protocol.equals("ssl")) ? "636" : "389");
Properties env = constructLdapContextEnvironment(providerURL, dn, credential);
return new InitialLdapContext(env, null);
}
No hashtable.put() operations there so it must come from the InitialLdapContext constructor right?
public InitialLdapContext(Hashtable<?,?> environment,Control[] connCtls) throws NamingException {
super(true); // don't initialize yet
// Clone environment since caller owns it.
Hashtable env = (environment == null)
? new Hashtable(11)
: (Hashtable)environment.clone();
// Put connect controls into environment. Copy them first since
// caller owns the array.
if (connCtls != null) {
Control[] copy = new Control[connCtls.length];
System.arraycopy(connCtls, 0, copy, 0, connCtls.length);
env.put(BIND_CONTROLS_PROPERTY, copy);
}
// set version to LDAPv3
env.put("java.naming.ldap.version", "3");
// Initialize with updated environment
init(env);
}
connCtls is null (see constructor call) so the only put operation is env.put("java.naming.ldap.version", "3") which is obviously fine.
Any idea what's going on here? Thanks.
HashTable does not allow keys to be null. Verify that none of the keys you put into Hashtable env is not null. For example, for
env.put(BIND_CONTROLS_PROPERTY, copy);
BIND_CONTROLS_PROPERTY must not be null.
Hope that helps
IMO, You have a code from another version of the LdapExtLoginModule. The correct one could be this one on GitHub.
The code there is:
private InitialLdapContext constructInitialLdapContext(String dn, Object credential) throws NamingException
{
Properties env = new Properties();
Iterator iter = options.entrySet().iterator();
while (iter.hasNext())
{
Entry entry = (Entry) iter.next();
env.put(entry.getKey(), entry.getValue()); /* this is the line 742 */
}
So there seems to be a login module option with null value. Try to check your configuration.
Please, share more details about your environment next time. It will help a lot to evaluate your problem. The most important details:
application server version
used server configuration (i.e. configuration of the security domain in this case)