Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Implementing AbstractLanguageServerTest in Maven project(Language server tests fail with NullpointerException if one chooses Maven for the Xtext project)
Implementing AbstractLanguageServerTest in Maven project [message #1827530] Sun, 17 May 2020 15:46 Go to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 19
Registered: March 2020
Junior Member
Hi there

Does someone know what one has to do to get the language server tests running in an Xtext project built with Maven?

In my Xtext project I develop an Eclipse plugin as well as the language server for VS code. Therefore, the Xtext project creation wizzard generates a Maven project (due to Eclipse plugin).

However, the generated Maven build is not able to execute Tests that extend the AbstractLanguageServerTest. I attached the simple "mydsl" example project here, with a language server test added to it.

The tests run perfectly fine in Eclipse, but the Maven build fails with a NullpointerException in the initialize method of the AbstractLanguageServerTest.

Any ideas how the Maven build has to be adapted for LSP tests? Has anyone such an Xtext project where this works?

Thanks for the help!
Stefan
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827533 is a reply to message #1827530] Sun, 17 May 2020 20:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
for some reason tycho does not seem to call the setup method
this looks like a bug.
but it seems it is fixed in tycho 1.7.0
(dont know which bug exactly it is, maybe mixture of junit and tycho version)



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827545 is a reply to message #1827533] Mon, 18 May 2020 05:56 Go to previous messageGo to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 19
Registered: March 2020
Junior Member
Hmmm, I updated the example to tycho 1.7.0 and get the same exception. Where you able to fix it in the sample project? And if yes: what exactly have you changed?
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827546 is a reply to message #1827545] Mon, 18 May 2020 06:13 Go to previous messageGo to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 19
Registered: March 2020
Junior Member
Is there a workaround maybe? Because it would be a bummer if we cannot get this working quickly... kind of show-stopper for the language server in our project :-/
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827548 is a reply to message #1827546] Mon, 18 May 2020 06:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no didnt change anything.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827549 is a reply to message #1827548] Mon, 18 May 2020 07:02 Go to previous messageGo to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 19
Registered: March 2020
Junior Member
So, you say changing the tycho version in the parent pom from 1.6.0 to 1.7.0 fixes the problem for you?
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827550 is a reply to message #1827549] Mon, 18 May 2020 07:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmm. on my machine i saw it green. could also be a problem with stuff in the dependencies/target

can you ask on tycho-user mailing list then? this should be reproducible in an non Xtext context too.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827552 is a reply to message #1827550] Mon, 18 May 2020 07:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you can also deug the setup code with
mvn clean install -DdebugPort=8000
and then do connect with remote debugger


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827553 is a reply to message #1827550] Mon, 18 May 2020 07:27 Go to previous messageGo to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 19
Registered: March 2020
Junior Member
Okay. Nothing to do with the AbstractLanguageServerTest then?

Which setup method were you talking about? (the one tycho should call)
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827555 is a reply to message #1827552] Mon, 18 May 2020 07:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hand another look.
it looks like the service loader stuff in ResourceServiceProviderServiceLoader
seems to have problems with tycho or/and java 11
(org.eclipse.tycho.surefire.osgibooter.CombinedClassLoader)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 18 May 2020 07:58]

Report message to a moderator

Re: Implementing AbstractLanguageServerTest in Maven project [message #1827558 is a reply to message #1827550] Mon, 18 May 2020 08:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
package org.xtext.example.mydsl.tests;

import java.util.ServiceLoader;

import org.eclipse.xtext.ISetup;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class DemoTest {

@BeforeEach
public void setup() {
ServiceLoader<ISetup> sl = ServiceLoader.<ISetup>load(ISetup.class);
Assert.assertFalse(IterableExtensions.isEmpty(sl));
}

@Test
public void test02_openFile() {

}

}

shows the problem in a simply test too.

=> this seems to be a tycho bug
please ask at tycho-user mailing list


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827559 is a reply to message #1827558] Mon, 18 May 2020 08:25 Go to previous messageGo to next message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 11
Registered: December 2015
Location: Rapperswil, Switzerland
Junior Member

What a pity :(

Thanks however for analyzing the problem. I asked at tycho-user mailing list now.
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827562 is a reply to message #1827559] Mon, 18 May 2020 09:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmmm. even if i configure the maven-surefire-plugin the setup method does not seem to be called.
no idea why


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827563 is a reply to message #1827562] Mon, 18 May 2020 10:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
looks like this one works

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xtext.example.mydsl2</groupId>
<artifactId>org.xtext.example.mydsl2.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.xtext.example.mydsl2.tests</artifactId>
<packaging>eclipse-plugin</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<testSourceDirectory>src,src-gen,xtend-gen,testlang-src,testlang-src-gen</testSourceDirectory>
<testClassesDirectory>target/classes</testClassesDirectory>
<failIfNoTests>true</failIfNoTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

</project>


a similar adaption for junit5 should work too


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827571 is a reply to message #1827563] Mon, 18 May 2020 13:59 Go to previous message
Stefan Kapferer is currently offline Stefan KapfererFriend
Messages: 11
Registered: December 2015
Location: Rapperswil, Switzerland
Junior Member

Thanks for your help Christian!
Previous Topic:Saving/opening files is blocked while code generation
Next Topic:Understanding why my Xtend editor is slow
Goto Forum:
  


Current Time: Sat Apr 20 03:19:45 GMT 2024

Powered by FUDForum. Page generated in 0.03669 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top