Jython openhab2-jython: attribute-resolver to the items map

First of all, I would like to thank everybody involved to openHAB and especially those who made jsr223-scripting possible.
While there are good points for openHAB DSL, my opinion is, that there are some tasks where
jsr223-scripting seems to be more appropriate.
I discovered this topic not long ago, so I consider myself a NewBie.

Here is my challenge:

The code in /lib/init.py (underscores not shown) attempts to add an attribute-resolver to the items map.
This is used in /scripts/examples/testing_example.py, but on my system it causes an ERROR being logged as below:

13:02:14.726 [ERROR] [e.smarthome.automation.rules.callback] - Traceback (most recent call last):
  File "/etc/openhab2/lib/python/openhab/triggers.py", line 119, in execute
    self.callback(module, inputs) if self.extended else self.callback()
  File "/etc/openhab2/lib/python/openhab/triggers.py", line 147, in callback
    result_value = fn(*fn_args)
  File "<script>", line 19, in double_the_value
AttributeError: 'org.eclipse.smarthome.automation.module.script.def' object has no attribute 'TestNumber1'

13:02:14.728 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - bb02c8b3-7995-434f-9859-e8c68f88294b updated: IDLE
13:02:15.708 [ERROR] [ROOT                                 ] - {
  "run": 1,
  "errors": [{"name":"__builtin__.MyUnitTest.test_item", "stack":"Traceback (most recent call last):
  File \"<script>\", line 33, in test_item
AttributeError: 'org.eclipse.smarthome.automation.module.script.def' object has no attribute 'TestNumber2'
"}],
  "failures": [],
  "skipped": []
}

an additional import import openhab did not help.
after changing the 2 lines:

18    events.postUpdate("TestNumber2", str(2 * items.TestNumber1.floatValue()))
18    events.postUpdate("TestNumber2", str(2 * items["TestNumber1"].floatValue()))
32        self.assertEqual(items.TestNumber2.floatValue(), 10)
32        self.assertEqual(items["TestNumber2"].floatValue(), 10)

it runs ok, Log below:

13:09:32.317 [INFO ] [port.shared.ScriptedAutomationManager] - removeAll added handlers
13:09:32.335 [INFO ] [ort.internal.loader.ScriptFileWatcher] - Loading script 'examples/testing_example.py'
13:09:32.339 [INFO ] [smarthome.event.RuleRemovedEvent     ] - Rule 'bb02c8b3-7995-434f-9859-e8c68f88294b' has been removed.
13:09:32.381 [INFO ] [smarthome.event.RuleAddedEvent       ] - Rule '919a7ea7-e531-44de-b0f0-f8982dd83d38' has been added.
13:09:32.385 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - 919a7ea7-e531-44de-b0f0-f8982dd83d38 updated: INITIALIZING
13:09:32.389 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - 919a7ea7-e531-44de-b0f0-f8982dd83d38 updated: IDLE
13:09:32.422 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestNumber1 changed from NULL to 5
13:09:32.424 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - 919a7ea7-e531-44de-b0f0-f8982dd83d38 updated: RUNNING
13:09:32.438 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestNumber2 changed from NULL to 10.0
13:09:32.442 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - 919a7ea7-e531-44de-b0f0-f8982dd83d38 updated: IDLE
13:09:33.417 [INFO ] [port.shared.ScriptedAutomationManager] - removeAll added handlers
13:09:33.434 [INFO ] [smarthome.event.RuleRemovedEvent     ] - Rule '919a7ea7-e531-44de-b0f0-f8982dd83d38' has been removed.
13:09:33.436 [INFO ] [ort.internal.loader.ScriptFileWatcher] - Loading script 'examples/testing_example.py'
13:09:33.472 [INFO ] [smarthome.event.RuleAddedEvent       ] - Rule 'ecdbf764-296e-4494-b21c-9f5d465586da' has been added.
13:09:33.476 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - ecdbf764-296e-4494-b21c-9f5d465586da updated: INITIALIZING
13:09:33.487 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - ecdbf764-296e-4494-b21c-9f5d465586da updated: IDLE
13:09:33.514 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestNumber1 changed from NULL to 5
13:09:33.528 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - ecdbf764-296e-4494-b21c-9f5d465586da updated: RUNNING
13:09:33.532 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestNumber2 changed from NULL to 10.0
13:09:33.534 [INFO ] [smarthome.event.RuleStatusInfoEvent  ] - ecdbf764-296e-4494-b21c-9f5d465586da updated: IDLE

Since I am not professional with python, I cannot sort out, if this is a possible configuration problem, or
a problem with the (discontinued) init.py.

The above Log shows, that the file is being logged to be loaded twice. This is addressed in another post.

Any hint is appreciated.

It is working for me. For issues like this, I try to write a very simple script to log diagnostic information. This can provide clues about the source of the problem. For example,

from openhab.log import logging, LOG_PREFIX
log = logging.getLogger(LOG_PREFIX)

# Required item:
#   String TestString1

import openhab
log.info(items.TestString1)

For me, this logs the value of the TestString1 item.

Have you defined items in your files?