OH2 - variable initialization in rules file fails at startup

Here is the beginning of my rules file:

import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
import org.joda.time.*
import java.util.regex.Matcher
import java.util.regex.Pattern


var DateTime lastDesarmTime = now.minusDays(1)
var boolean regulVeranda = false
var boolean lancementSonos = false
var boolean initMinimoteCourt = true
var boolean initMinimoteLong = true
val Pattern patternVoice1 = Pattern::compile("(donner|allumer|éteindre|passer en hors gel|passer en mode confort|passer en mode réduit|lecture|stop lecture|remettre le son|couper le son) (le |la |les |l'|du )(.*) (du |de la |de l'|dans le |dans la |dans l')(.*)")
val Pattern pattern2 = Pattern::compile("x-sonosapi-stream:s(\\d+?)\\?.+")
val Pattern pattern3 = Pattern::compile("x-rincon:.+")

When starting OH 2 (beta 2), here are the errors I get:

2016-02-04 23:42:59.240 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'lastDesarmTime' on rule file 'maisonOH2.rules' cannot be initialized with value '<XFeatureCallImplCustom>.minusDays(<XNumberLiteralImpl>)': An error occured during the script execution: The name '<XFeatureCallImplCustom>.minusDays(<XNumberLiteralImpl>)' cannot be resolved to an item or type.
2016-02-04 23:42:59.257 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'patternVoice1' on rule file 'maisonOH2.rules' cannot be initialized with value '<XFeatureCallImplCustom>::compile(<XStringLiteralImpl>)': An error occured during the script execution: The name 'Pattern' cannot be resolved to an item or type.
2016-02-04 23:42:59.262 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'pattern2' on rule file 'maisonOH2.rules' cannot be initialized with value '<XFeatureCallImplCustom>::compile(<XStringLiteralImpl>)': An error occured during the script execution: The name 'Pattern' cannot be resolved to an item or type.
2016-02-04 23:42:59.267 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'pattern3' on rule file 'maisonOH2.rules' cannot be initialized with value '<XFeatureCallImplCustom>::compile(<XStringLiteralImpl>)': An error occured during the script execution: The name 'Pattern' cannot be resolved to an item or type.

Any idea ?

Of course, it does not happen in OH 1.8.

Hi,
I was suffering from the same problem. When a fully quallified the Pattern class, it worked.

val java.util.regex.Pattern patternVoice1 = java.util.regex.Pattern::compile("(donner|allumer|éteindre|passer en hors gel|passer en mode confort|passer en mode réduit|lecture|stop lecture|remettre le son|couper le son) (le |la |les |l'|du )(.*) (du |de la |de l'|dans le |dans la |dans l')(.*)")
val java.util.regex.Pattern pattern2 = java.util.regex.Pattern::compile("x-sonosapi-stream:s(\\d+?)\\?.+")
val java.util.regex.Pattern pattern3 = java.util.regex.Pattern::compile("x-rincon:.+")

Thank you for the advice, I will it.

As the problem suddenly reappeared, I tried your tip but unfortunately it does not help.

Have you followed migration guide?
http://docs.openhab.org/tutorials/migration.html#rules

All references to org.openhab.core.* in imports and class references should be removed.

import org.joda.time.* statements should also be removed.

My 2 first imports were removed.
joda.time is still present. To continue having access to the variable “now”, do you know what import I should use ?

None I believe.
Designer will probably complain, if you use that, but doesn’t stop it working

I replaced

import org.joda.time.*

by

import org.joda.time.DateTime

It solved validation warning. My rule file is even ok in Designer.
But the current problem at the origin of this topic is still present.