disable strict mode in drools - java

I'm getting error like Error: unable to resolve method using strict-mode: ...
I've added system property drools.dialect.mvel.strict=false
I can see system property was applied to my app in jvisualvm
But I'm getting the same error with 'using strict-mode'.
How could I disable strict mode in drools?

This is how it can be done from Java:
KnowledgeBuilderConfiguration kbConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
kbConfig.setProperty("drools.dialect.mvel.strict", "false");
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder( kbConfig );
Although, setting the property should be OK. -- Maybe a look at the error might help to find a workaround?

Related

Issue in addPlugInSingleRowFunction upgrading Esper version from 5.3 to 8.3

In our existing application we are using Esper Version 5.3.
We have added few addPlugInSingleRowFunction() to use it in EPL as below --
final Configuration cepConfiguration = new Configuration();
cepConfiguration.addPlugInSingleRowFunction("toNumber", Double.class.getName(), "parseDouble");
cepConfiguration.addPlugInSingleRowFunction("toBoolean", Boolean.class.getName(), "parseBoolean");
This was working fine in 5.3 version.
Post upgrading to 8.3 above code changed as per Esper documentation --
cepConfiguration.getCompiler().addPlugInSingleRowFunction("toNumber", Double.class.getName(), "parseDouble");
cepConfiguration.getCompiler().addPlugInSingleRowFunction("toBoolean", Boolean.class.getName(), "parseBoolean");
But once the sendEventBean() method is called to send a Event to runtime we are seeing below exception every time.
Surprisingly events are getting matched as per the statements present in runtime even if below exception are coming. Though we are not sure whether some events are not matching or not.
Can someone please help on this?
applog.cls=com.espertech.esper.common.internal.epl.expression.dot.core.ExprDotNodeForgeStaticMethodEval,applog.mthd=staticMethodEvalHandleInvocationException,applog.line=228,applog.msg=Invocation exception when invoking method 'parseDouble' of class 'java.lang.Double' passing parameters [null] for statement 'stmt-0': NullPointerException : null,exc.stack=java.lang.NullPointerException\n\tat sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)\n\tat sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)\n\tat java.lang.Double.parseDouble(Double.java:538)\n\tat generated.StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.m8(StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.java:161)\n\tat generated.StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450$2.get(ANONYMOUS.java:148)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterParamIndexEquals.matchEvent(FilterParamIndexEquals.java:32)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterHandleSetNode.matchEvent(FilterHandleSetNode.java:100)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.EventTypeIndex.matchType(EventTypeIndex.java:178)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.EventTypeIndex.matchEvent(EventTypeIndex.java:124)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceBase.retryableMatchEvent(FilterServiceBase.java:179)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceBase.evaluateInternal(FilterServiceBase.java:96)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceLockCoarse.evaluate(FilterServiceLockCoarse.java:52)\n\tat com.espertech.esper.runtime.internal.kernel.service.EPEventServiceImpl.processMatches(EPEventServiceImpl.java:610)\n\tat com.espertech.esper.runtime.internal.kernel.service.EPEventServiceImpl.processWrappedEvent(EPEventServiceImpl.java:450)\n\tat com.espertech.esper.runtime.internal.kernel.thread.InboundUnitSendEvent.run(InboundUnitSendEvent.java:43)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)
You could turn on compiler logging (config.getCompiler().getLogging().setEnableCode(true);) and make sure you have INFO level logging. You can inspect "StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.m8" at line 161 to see what the problem is. Sounds like a null value gets passed to Double.parseDouble. But since I don't have the complete code its hard to say.

Using toUpperCase with Correct Locale

I'm trying to fix errors which are reported by forbiddenapis. I had that line:
paramMap.put(Config.TITLEBOOST.toUpperCase(), titleBoost);
So, its been reported as error as usual. I've tried that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.getDefault()), titleBoost);
and that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ROOT), titleBoost);
also that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ENGLISH), titleBoost);
However none of them fixed the error:
[forbiddenapis] Forbidden method invocation:
java.lang.String#toUpperCase() [Uses default locale]
What I miss?
Double-check that the bytecode you are analyzing is actually your most recent build output, and that you're looking at the same line forbiddenapis is :) . This looks to me like your source/bytecode/analysis are falling out of sync — the relevant rule shouldn't flag an error on String.toUpperCase(Locale).
Disclaimer: I haven't used forbiddenapis myself --- I wrote this answer based on the repo and on a blog post I found.

Can't get logbacks TimeBasedRollingPolicy running

I can't get this snippet running:
TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<>();
rollingPolicy.setFileNamePattern("%d{yyyy-MM-dd}.log");
rollingPolicy.start();
Whatever pattern I try, I keep getting
Caused by: java.lang.IllegalStateException: FileNamePattern [%d{yyyy-MM-dd}.log] does not contain a valid DateToken
at ch.qos.logback.core.rolling.TimeBasedFileNamingAndTriggeringPolicyBase.start(TimeBasedFileNamingAndTriggeringPolicyBase.java:46)
at ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy.start(DefaultTimeBasedFileNamingAndTriggeringPolicy.java:32)
at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.start(TimeBasedRollingPolicy.java:90)
I've tried various examples from the docs, but what works in logback.xml doesn't seem to work in code.
According to this: https://github.com/tony19/logback-android/issues/51 you need a context and an appender. There is an example there.

JavaClassFormat exception [duplicate]

I am getting this strange error while executing the following code.
EncoderRequest encoderRequest = new EncoderRequest(sid,appTxnId,pfid,transactionType,"",isUpdatetype9,true);
I have checked all the parameter values are valid. I am using java7 plateform.
can any one have come across this situation, please help.
following is the part of stacktrace i am getting.
Caused by: java.lang.ClassFormatError: Illegal local variable table length 48 in method com.cmc.facts.encoder.EncoderRequest.<init>(JLjava/lang/String;Ljava/lang/Long;Lcom/cmc/facts/enums/TransactionType;Ljava/lang/String;ZZ)V at com.cmc.facts.nist.NistReaderModel.preprossingOfNistFile(NistReaderModel.java:180) at com.cmc.facts.action.interstate.InterStateAction.uploadFIIF(InterStateAction.java:645) ... 115 more
There have been previous reports of the same error, on Junit tests and similar..
For them, adding the JVM arg -XX:-UseSplitVerifier seemed to work
Have a look at this article
You can also do this config :
Add -noverify in your jvg args
For ant config you can do : <jvmarg value="-noverify"/>
You can follow the link for more details on why we need to do this.

getting rid of Hbase configuration deprecated warning

I'm getting this error message in my log file WARN hbase.HBaseConfiguration: instantiating HBaseConfiguration() is deprecated. Please use HBaseConfiguration#create() to construct a plain Configuration how can I get rid of this?
My class extends Configured.class , and I'm instantiating configuration like this :
HBaseConfiguration hBaseConfiguration = new HBaseConfiguration(getConf());
Did anyone have the similar issue? how to fix it ?
EDIT
How can I get this version of HbaseConfiguration :
http://hbase.apache.org/docs/r0.89.20100726/xref/org/apache/hadoop/hbase/HBaseConfiguration.html
I downloaded the latest version from hbase web site(version 0.20.6) but the class is different from this one, its missing create() method and some other too.
Quoting the Javadoc:
Instantinating HBaseConfiguration() is
deprecated. Please use
HBaseConfiguration#create(conf) to
construct a plain Configuration
Instead of doing:
HBaseConfiguration hBaseConfiguration = new HBaseConfiguration(getConf());
You should do:
Configuration configuration = HBaseConfiguration.create(getConf());

Categories

Resources