VS Studio Code Copy Paste creates Error in openHAB Log

Hello there,

I am using the newest version of the VS Studio Code also the newest of the Openhab Extension.

At the moment I get a strange Error, when I copy and paste something (as a example in my rules)
It seems like a “crash” and VS Studio Code and Openhab shows some Errors.

Openhab Log Viewer:

2022-12-15 13:46:49.142 [ERROR] [xt.ide.server.concurrent.ReadRequest] - Error during request: 

java.lang.RuntimeException: Cannot create a resource for 'java:/Objects/org.openhab.core.items.GenericItem'; a registered resource factory is needed

	at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:263) ~[?:?]

	at org.eclipse.xtext.ide.server.ProjectManager.getResource(ProjectManager.java:169) ~[?:?]

	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:436) ~[?:?]

	at org.eclipse.xtext.ide.server.findReferences.WorkspaceResourceAccess.readOnly(WorkspaceResourceAccess.java:36) ~[?:?]

	at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.doRead(DocumentSymbolService.java:332) ~[?:?]

	at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:112) ~[?:?]

	at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:99) ~[?:?]

	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$25(LanguageServerImpl.java:607) ~[?:?]

	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438) ~[?:?]

	at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:606) ~[?:?]

	at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:594) ~[?:?]

	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$24(LanguageServerImpl.java:585) ~[?:?]

	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]

	at java.lang.Thread.run(Thread.java:829) [?:?]

VS Studio Code Error:

openHAB vscode extension has been activated
[Error - 1:46:50 PM] Request textDocument/definition failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.RuntimeException: Cannot create a resource for 'java:/Objects/org.openhab.core.items.GenericItem'; a registered resource factory is needed
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:704)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
	at org.eclipse.xtext.ide.server.concurrent.AbstractRequest.logAndCompleteExceptionally(AbstractRequest.java:73)
	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:69)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

This problem only occurs when I try to copy and paste.
I can go ahead and save the files and work like nothing happens.

Is there someone else who ever had this problem and can maybe give me a hint ?

Are you really using Visual Studio ?
The extension is for Visual Studio Code, big difference.

sorry, I’ve already changed that.
of course its studio code :slight_smile: didn’t thought of that other version.

Those errors are due to the openHAB extension for VS Code, and don’t cause any actual harm. They’re just annoying. If they really annoy you, I believe you can remove them by setting the Language Server to false. However, doing that will prevent VS Code from offering inline suggestions as you type.

1 Like

Hm - I have the same problem since many month. Is there another “solution” as just to ignore it?

I started facing crashes of openhab service when I for example save a rule with error using the VS Code extension. I havent noticed this before but it happens in the last few days.

I slowly finalized my OH automation and I wanted to install a clean installation without all the unnecessary things I had until now, and this is happening on my newly prepared USB drive
I just updated to 3.4.
I have Aeon Zwave stick on ttyACM1.

`openhabian@openhabian:~ $ sudo systemctl status openhab
● openhab.service - openHAB - empowering the smart home
     Loaded: loaded (/lib/systemd/system/openhab.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/openhab.service.d
     Active: active (running) since Mon 2022-12-19 21:42:22 CET; 4min 55s ago
       Docs: https://www.openhab.org/docs/
   Main PID: 32076 (java)
      Tasks: 329 (limit: 4915)
        CPU: 5min 48.885s
     CGroup: /system.slice/openhab.service
             └─32076 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openhab -Dopenhab.conf=/etc/openhab -Dopenhab.runtime=/usr/share/openhab/runtime -Dopenhab.us>

Dec 19 21:42:22 openhabian systemd[1]: Started openHAB - empowering the smart home.
Dec 19 21:44:40 openhabian karaf[32076]: RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyACM1`

I don’t think this has anything to do with the OP’s question. If you can’t find any other similar posts, you should start a new discussion.

If I knew of one, I would have mentioned it. :wink:

As far as I’m aware, disabling the language server is they only “solution”. I seem to recall that the developer who worked on this portion of the VS Code extension is no longer active with OH, and no one else in our community knows how to to update it. If you’ve got the expertise and time necessary to do it, I suspect that a lot of people would be grateful for your efforts!

1 Like

The lsp (language server protocol) features where introduced in one big (incomplete) pr.

The idea was to first have a remote server component which is available from the openHAB installation a user has connected to the vscode extension.

Later there also should be a local language server component, to increase speed and ressource usage.

Both controibutors (vscode extension side and the main contributor for the initial work in openhab core for the server part) are no active contributors anymore.

I (as probably last leftover regularly contributor to the extension) have tried to get into that lsp stuff different times but have decided to no longer put any effort in it.

The only thing I could do easily, is remove the whole lsp part.
But this would also cause many complains. Therefore I am not doing anything, before doing wrong anyway. (#Lindner , sorry for the german joke. I couldn’t resist. :laughing: )

1 Like

Thanks Russ and Jerome! It’s a pity that the lsp is not further developed.