OH2.4 VScode error when coding

I am running VScode on Windows 10, with OH2.4.0 running on a rPi3

When I am updating rule files (which do not show any errors and run fine), I get the error below.
I have no clue as to what it means.
Can it be switched off, as it pops up in the bottom of the screen reducing my editor window, which is more of a nuisance than help.

[Error - 10:41:40] Request textDocument/definition failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.RuntimeException: Cannot create a resource for 'java:/Objects/org.eclipse.smarthome.model.script.actions.LogAction'; a registered resource factory is needed
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
	at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:647)
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:632)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
	at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$run$0(ReadRequest.java:43)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: Cannot create a resource for 'java:/Objects/org.eclipse.smarthome.model.script.actions.LogAction'; a registered resource factory is needed

[edit] HAd a look at this [SOLVED] Item refreshes state very quickly but cannot see any relationship. It also happens with any rule file.
My rule files parse w/o errors.

The error tells something about LogActions that were not able to be completed.

Do you use logging and if yes can you paste one of the rules where you use it?

I use logging probably in its simplest form:

logInfo("rule step", "... blah set to {}", blah.state)


logInfo("rule step", "... blah set to x")

A rule I use logging…

rule "Start Irrigation1"
		// triggers to start this group; either auto (by cron) or manual
		Item Irrigation1_Auto changed to ON or
		Item Irrigation1_Now  changed to ON
		// only irrigate if allowed is ON
		if (Irrigation1_Allowed.state == ON) {

			// start up valve 1 of 4
			logInfo("Irrigation1.10", "Irrigation1 started...")

			// capture current meter (from last session) and store it in last session total
			logInfo("Irrigation1.11a", "... PumpStation1_LastSessionTotal set to {}", PumpStation1_LastSessionTotal.state)
			logInfo("Irrigation1.11b", "... PumpStation1_LastSessionTotal set to {}", PumpStation1_LastSessionTotal.state)

			// zero the last session memory and start at zero for this session
			logInfo("Irrigation1.11c", "... PumpStation1_LastSessionMemory -> to {}", PumpStation1_LastSessionMemory.state)
			logInfo("Irrigation1.11d", "... PumpStation1_LastSessionMemory -> to {}", PumpStation1_LastSessionMemory.state)

			// ----- reset meter to 0 for good...
			// reset the controller's meter to 0
			publish("mymosquitto", "ArgyleCourt/Property/PumpStation1/Command", "resetMeter")
			publish("mymosquitto", "ArgyleCourt/Property/PumpStation1/Meter", "0")

			// we now have to update this value as well, because the controller does
			//   not publish back the forced change to 0

			// reset the session volume counter to zero
			logInfo("Irrigation1.13b", "... PumpStation1_Meter .......... set to 0 -> {}", PumpStation1_Meter.state)
			logInfo("Irrigation1.14a", "... PumpStation1 VolumeSession .. set to {}", PumpStation1_MemoriseMeterRead)
			PumpStation1_MemoriseMeterRead = (PumpStation1_Meter.state as Number).intValue
			logInfo("Irrigation1.14", "... PumpStation1 VolumeSession ... set to 0; is it? -> {}", PumpStation1_MemoriseMeterRead)

			// update 'curr'ent valve name; which is #1

			// now switch valve 1 ON
			logInfo("Irrigation1.15", "..> turning ............................ Irrigation1_1 ON")

		} else {

			logInfo("Irrigation1.16", "Irrigation1 not started -> not allowed!")

I think you’ve got some kind of debug mode enabled? The logfile it cannot create is on the local/editing machine and not the remote host?

Haven’t changed anything related to logging other than this rule, which logs to a file:

			// logging relay controller reboots
			val String errMsg = now.toString + " " + Shed_RC41_Message.state.toString.replace('|', '_')
			val String errCmd = executeCommandLine("/bin/sh@@-c@@echo " + errMsg + " >> /etc/openhab2/html/RelayController41.txt; echo $?", 3000)

and this in the Thing file

Thing logreader:reader:openhablog [ refreshRate=10000, errorPatterns="ERROR+" ]

which OH can write to as can be seen int he log file it adds to:

2019-10-16T19:16:37.128+10:00 Arduino_RelayController41_INFO_has rebooted
2019-10-17T13:15:28.608+10:00 Arduino_RelayController41_INFO_has rebooted
2019-10-19T13:15:18.538+10:00 Arduino_RelayController41_INFO_has rebooted
2019-10-19T13:15:37.410+10:00 Arduino_RelayController41_INFO_has rebooted

What I’m trying to say is this is a VSCode problem, not your running openHAB. VSCode is trying to create or access some log file - I’ll have a guess VSC has tried to execute your rule locally due to some debug setting, and/or it’s trying to access a remote logfile.

I don’t know how any of this stuff works. I do not have an “openHAB server” option in the dropdown selector for my debug ‘output’ tab. To the right of that is a ‘clear’ button, but I guess the message comes back?

any update on this?
I am having the same problem… with OH 2.5 and VSCode 0.6

Please post a screenshot of your error message.

I seem to have missed that las post, so i will give a really late answer.

VsCode (or at least the openHAB extension) doesn’t execute/debug rules.
It also doesn’t access log files in the background.

The openHAB server Output Tab is generated from the remote LSP server connection.
If remote LSP is disabled, the corresponding Output tab isn’t activated.

So here are the short facts:

  • The error message is generated from remote lsp server in your openHAB environment.
  • It then gets delivered via lsp conenction into the remote lsp client module
  • The remote lsp client itself then adds this message to the openHAB server output.

So the error is somehow thrown while checking the rule via lsp.
@wborn you have something with lsp a while ago.
Maybe you have an idea about this error and how we can dig into solving it or whats the server side cause for throwing it.

1 Like

I haven’t been annoyed enough by it to further investigate this. :wink:

See also:

Ah thanks.
I have seen this issue already and participated in discussion.
Sometimes its hard to keep an overview in this many related repositories…