[EDIT] – Title from
InstantiationException on org.openhab.core.library.types.StringType
to
The name ‘unkown(XStringLiteralImpl,XStringLiteralImpl)’ cannot be resolved to an item or type.
As the InstationException has been resolved.
I am using a timer to check if an item updates been received on time, and if not update an item…
Whenever I receive an update on time, I also receive the InstantiationException in openhab.log.
The rule:
// ----- 170205 MaxG: Irrigation tank heart beat timer
var Timer Timer_Tank_Irrigation_Reporting = null
// ----- 170205 MaxG: check if tank is reporting its level continuously
// if not, there is a problem: power, network, controller...
rule "Irrigation tank update not received"
when
Item Tank_Irrigation_Level received update
// which happens every 60 seconds (hard-coded in Tank Controller)
then
if(Timer_Tank_Irrigation_Reporting == null) {
logInfo("IrriTank.rule", "Tank_Irrigation: creating timer")
// create a timer to expire in 2 miutes
Timer_Tank_Irrigation_Reporting = createTimer(now.plusMinutes(2), [|
logInfo("IrriTank.rule", "Tank_Irrigation: timer expired and setting to OFF")
Tank_Irrigation_Reporting.postUpdate(OFF)
Timer_Tank_Irrigation_Reporting = null
])
} else {
logInfo("IrriTank.rule", "Tank_Irrigation: update received on time")
Tank_Irrigation_Reporting.postUpdate(ON)
Timer_Tank_Irrigation_Reporting.reschedule(now.plusMinutes(2))
}
end
the item:
String Tank_Irrigation_Reporting "Tank Level reporting is [%s]" <settings>
What I also noticed – after pulling the network plug – I get the same error in the OFF side AND the item is not updating to OFF, leading me to suspect the postUpdate to be incorrect… I have tried putting quotes around the ON/OFF in the postUpdate which creates even longer (non-sensical to me) error messages.
OK… what I found in the interim is that ON and OFF needs to be in double quotes, and both variants of the postUpdate do work… and to get rid of the InstantiationException error.
However, I get an error (that error that does not mean much to me), which only occurs when reloading the rules, after that is is working without a problem / error.
2017-02-05 15:32:46.291 [INFO ] [o.model.script.RefillStop.rule] - AllowIrrigationTankDemand....: false
2017-02-05 15:32:46.777 [INFO ] [o.model.script.RefillStop.rule] - AllowHouseBorewaterTankDemand: false
2017-02-05 15:32:59.465 [INFO ] [hab.model.script.IrriTank.rule] - Tank_Irrigation: creating timer
2017-02-05 15:33:59.412 [INFO ] [hab.model.script.IrriTank.rule] - Tank_Irrigation: update received on time
2017-02-05 15:33:59.700 [ERROR] [org.quartz.core.JobRunShell ] - Job DEFAULT.2017-02-05T15:32:59.637+10:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: org.eclipse.xtext.xbase.impl.XClosureImplCustom@18a0cbc (explicitSyntax: true) threw an unhandled Exception:
java.lang.RuntimeException: The name '<unkown>(<XStringLiteralImpl>,<XStringLiteralImpl>)' cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor672.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28) ~[na:na]
at com.sun.proxy.$Proxy87.apply(Unknown Source) ~[na:na]
at org.openhab.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:44) ~[na:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213) ~[quartz-all-2.1.7.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-all-2.1.7.jar:na]
2017-02-05 15:33:59.746 [ERROR] [org.quartz.core.ErrorLogger ] - Job (DEFAULT.2017-02-05T15:32:59.637+10:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: org.eclipse.xtext.xbase.impl.XClosureImplCustom@18a0cbc (explicitSyntax: true) threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
at org.quartz.core.JobRunShell.run(JobRunShell.java:224) ~[quartz-all-2.1.7.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-all-2.1.7.jar:na]
Caused by: java.lang.RuntimeException: The name '<unkown>(<XStringLiteralImpl>,<XStringLiteralImpl>)' cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor672.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28) ~[na:na]
at com.sun.proxy.$Proxy87.apply(Unknown Source) ~[na:na]
at org.openhab.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:44) ~[na:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213) ~[quartz-all-2.1.7.jar:na]
... 1 common frames omitted
2017-02-05 15:34:59.312 [INFO ] [hab.model.script.IrriTank.rule] - Tank_Irrigation: update received on time
2017-02-05 15:35:59.394 [INFO ] [hab.model.script.IrriTank.rule] - Tank_Irrigation: update received on time
Thanks… have changed to a switch again, and changed the postUpdate w/o the quotes…
Here the relevant pieces…
// ----- 170205 MaxG: Irrigation tank heart beat timer
var Timer Timer_Tank_Irrigation_Reporting = null
// ----- 170205 MaxG: check if tank is reporting its level continuously
// if not, there is a problem: power, network, controller...
rule "Irrigation tank update not received"
when
Item Tank_Irrigation_Level received update
// which happens every 60 seconds (hard-coded in Tank Controller)
then
if (Timer_Tank_Irrigation_Reporting == null) {
logInfo("IrriTank.rule", "Tank_Irrigation_Reporting: creating timer")
// create a timer to expire in 2 minutes
Timer_Tank_Irrigation_Reporting = createTimer(now.plusMinutes(2)) [|
logInfo("IrriTank.rule", "Tank_Irrigation_Reporting: timer expired setting to OFF")
Tank_Irrigation_Reporting.postUpdate(OFF)
Timer_Tank_Irrigation_Reporting = null
]
} else {
//logInfo("IrriTank.rule", "Tank_Irrigation_Reporting: update received on time")
Tank_Irrigation_Reporting.postUpdate(ON)
Timer_Tank_Irrigation_Reporting.reschedule(now.plusMinutes(2))
}
end
.sitemap:
Switch item=Tank_Irrigation_Reporting
.items
Switch Tank_Irrigation_Reporting "Tank Level reporting is [%s]" <settings>
error:
2017-02-05 19:55:58.042 [INFO ] [hab.model.script.IrriTank.rule] - Tank_Irrigation_Reporting: creating timer
2017-02-05 19:56:57.696 [ERROR] [org.quartz.core.JobRunShell ] - Job DEFAULT.2017-02-05T18:23:51.683+10:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: org.eclipse.xtext.xbase.impl.XClosureImplCustom@124358f (explicitSyntax: true) threw an unhandled Exception:
java.lang.RuntimeException: The name '<unkown>(<XStringLiteralImpl>,<XStringLiteralImpl>)' cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor672.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28) ~[na:na]
at com.sun.proxy.$Proxy87.apply(Unknown Source) ~[na:na]
at org.openhab.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:44) ~[na:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213) ~[quartz-all-2.1.7.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-all-2.1.7.jar:na]
2017-02-05 19:56:57.734 [ERROR] [org.quartz.core.ErrorLogger ] - Job (DEFAULT.2017-02-05T18:23:51.683+10:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: org.eclipse.xtext.xbase.impl.XClosureImplCustom@124358f (explicitSyntax: true) threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
at org.quartz.core.JobRunShell.run(JobRunShell.java:224) ~[quartz-all-2.1.7.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-all-2.1.7.jar:na]
Caused by: java.lang.RuntimeException: The name '<unkown>(<XStringLiteralImpl>,<XStringLiteralImpl>)' cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor672.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) ~[na:na]
at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28) ~[na:na]
at com.sun.proxy.$Proxy87.apply(Unknown Source) ~[na:na]
at org.openhab.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:44) ~[na:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213) ~[quartz-all-2.1.7.jar:na]
... 1 common frames omitted
I have not changed any other things in my config… and do not have errors in my logs… other than what I’ve posted here today. The system is running for almost a year, was an apt-get install on rPi2 Jessie… and OH1.8.3
Also: the error occurs only once after loading the .rules… and 1 minute after the timer was created. That means it errors when the first update is received (updates come in every minute).
If you get the error only one time after a reload of your rules, I would say the problem is that the item is still uninitialised on the first run. If you have persistence on the item, maybe that is not working(any more)?
Changed the Switch back to a String (as it behaves the same WRT the error).
Enabled persistence for both Tank_Irrigation_Reporting and Tank_Irrigation_Level… still the same behaviour = same error, only once after rules has been loaded and rule has been triggered the first time.
I have verified the rule by looking at others on various sources. It seems my rule has no errors.
The bracket was sorted by eliminating one command, bracket pair after the other.
I have no further ideas on what to do with this.
Multiple ways to skin a cat
Call me stubborn, but I want to get this work, because it should! I mean it does work, it is onyl the first trigger that fails… and I like clean code and results. So while some would be happy that it works most of the time, I am not.
Maybe it’s just a timing issue…in such as when the else-part comes to the timer.reschedule, the the timer actually expired and has been set to null again, thus throwing the error? maybe you should add a check for timer==null around the Tank_Irrigation_Reporting.postUpdate(ON) like:
if timer==null {
Tank_Irrigation_Reporting.postUpdate(ON)
//do the whole timer set routine
} else {
Tank_Irrigation_Reporting.postUpdate(ON)
Timer_Tank_Irrigation_Reporting.reschedule(now.plusMinutes(2))
}
And as far as the brckets in the createTimer are concerned:
Now I know why there are two (three) version for coding this timer business. Thanks Rich!
I installed the designer again; just to make sure there is no syntax error in my rule, and there are no red crosses in my rules (or elsewhere).
Should I just give it a rest – as in this is too hard?!
I have spent 6 hours reading the forum with related issues, and none of them got resolved (other than syntax errors)… is this a bug?
When you reload the rules file, you almost certainly have a copy of the timer already running. Reloading the rules file will not destroy it, only the handle var.
I guess it will mess up when it completes; I couldn’t say how it might affect the “new” rule creating another timer but it might be an explanation.
Does that fit with error only seen on rules reload, but not at system startup?
Just quickly scanning the thread. I apologize if I’m way off base.
The problem you are seeing was one I say for awhile in OH 1 and OH 2. I don’t know when or if the problem went away (I’m pretty much exclusively using Expire binding now instead of Timers in Rules, I highly recommend it, makes rules a lot simpler).
The error appeared to be related to OH trying to cancel times that no longer exist on a rules reload. At least when I noticed those errors I would have one for each Timer I had active at the time.
Both are correct. It was an unfortunate but of syntactic sugar the designers if the language chose. The [] denotes a lambda. If a lambda is the last argument to a method call you can define the lambda outside the closing ).
You will notice I always define my lambda inside the ().
In short, (time, [ lambda]) and (time) [ lambda ] are both correct.
Actually it is perfectly valid to send the String “ON” to a Switch Item. The String must be all caps but the Switch Item knows how to parse it. If you use the Actions, the String “ON” gets sent even when you usesendCommand(MyItem, ON).
Possibly. Something weird is going on for sure.
At this point I would consider the Expire binding as the more “correct” approach and recommend considering using it.
Sometimes discretion is the better part of valor. Semper gumby.
I haven’t tried the ‘reboot’ yet… all the stuff I’ve read on this forum does not get to the bottom of it…
… my system is running quite a few things, hence, rebooting is a last resort; and was a reason once to give up on Windows
Now that two smarty pants suggested the Expire binding, which I will now use.
… don’t you worry… always appreciate your replies.
I tried both versions of the time; same (error) result.
While I am open to change, I do not change just because I could… I am not on OH2 because of the many problems associated with it; this createTimer thing had tons of examples; yes, lots that had problems, but I thought there must be a few working ones out there (maybe they didn’t look at the log or ignored it) – and look at the effort I put into getting this right 8+ hours by now… however, given your and Watou’s reply to use the Expire binding, I will go that route…
Thanks to all for hanging in there trying to solve such an awkward error!