Is there a way to pinpoint who's doing this error?

  • Platform information:
    • Hardware: i3-530 on docker
    • OS: Lubuntu but using Docker image
    • Java Runtime Environment: The one included in the docker image
    • openHAB version: 3.1.0

Hello everyone,

I migrated to OH3 and I’m having an error during startup. I think the error was present in 2.5 but it’s been so long since I’ve rebooted OH2 that I don’t remember. I’d like to find what is throwing this error.

[WARN ] [ab.core.internal.events.EventHandler] - Creation of event failed, because one of the registered event factories has thrown an exception: Error invoking #valueOf(String) on class ‘org.openhab.core.library.types.DateTimeType’ with value ‘2-01-01T00:00:00.000-0500’.
java.lang.IllegalStateException: Error invoking #valueOf(String) on class ‘org.openhab.core.library.types.DateTimeType’ with value ‘2-01-01T00:00:00.000-0500’.
at org.openhab.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:190) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.parseType(ItemEventFactory.java:158) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:136) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:116) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.createEventByType(ItemEventFactory.java:80) ~[?:?]
at org.openhab.core.events.AbstractEventFactory.createEvent(AbstractEventFactory.java:53) ~[?:?]
at org.openhab.core.internal.events.EventHandler.createEvent(EventHandler.java:131) ~[?:?]
at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:106) ~[?:?]
at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~[?:?]
at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) ~[?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:181) ~[?:?]
… 10 more
Caused by: java.lang.IllegalArgumentException: 2-01-01T00:00:00.000-0500 is not in a valid format.
at org.openhab.core.library.types.DateTimeType.(DateTimeType.java:112) ~[?:?]
at org.openhab.core.library.types.DateTimeType.valueOf(DateTimeType.java:123) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:181) ~[?:?]
… 10 more
Caused by: java.time.format.DateTimeParseException: Text ‘2-01-01T00T00:00:00:00:00.000-0500’ could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2046) ~[?:?]
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948) ~[?:?]
at java.time.LocalDateTime.parse(LocalDateTime.java:492) ~[?:?]
at org.openhab.core.library.types.DateTimeType.parse(DateTimeType.java:232) ~[?:?]
at org.openhab.core.library.types.DateTimeType.(DateTimeType.java:106) ~[?:?]
at org.openhab.core.library.types.DateTimeType.valueOf(DateTimeType.java:123) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:181) ~[?:?]

Thank you!

You have a rule somewhere.

In that rule you are creating a DateTimeType with DateTimeType.valueOf().

The String being passed to valueOf is “2-01-01T00:00:00.000-0500” which is not a valid ISO8601 formatted date time string and therefore cannot be parsed and therefore a new DateTimeType cannot be created.

That should give you enough to narrow it down to one or two lines of code in your rules. From there you can figure out where that Sting is coming from and fix the format so it’s a valid ISO8601 format (hint, it’s year-month-day and the year needs to be four digits).

It’s also possible that you have a binding with a String Channel that is linked to a DateTime Item. In that case you need to fix the String returned by the binding (maybe with a transformation?). Again, you probably don’t have that many DateTime Items linked to a binding that will return a String like this so it should be relatively easy to find the one with the problem.

Thanks, that’s a good starting point, I’ll start by removing my rules since it’s pretty easy, it will at least tell me if it’s coming from rules or binding.

Thanks!