UnsatisfiedLinkError with maven-surefire-plugin

When running a unit test with the maven-surefire-plugin, this error occures:

java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM

I know how to cope with this problem in my IDE, I simply have to select the correct runtime JRE in the test's run configuration. However, when the test is run on a TeamCity build server, the error mentioned above occurs.

Is there any surefire or TeamCity option to configure the runtime JRE?

This is my current surefire configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <skipTests>false</skipTests>
    <includes>
      <include>**/*Test.java</include>
    </includes>
    <parallel>methods</parallel>
    <threadCount>10</threadCount>
  </configuration>
</plugin>

Answers


When configuring a Maven build step in TeamCity, select a target JDK with the appropriate "bitness" (x86 in your case):

At least one of your build agents should have a 32-bit JDK discovered and available. You can check whether this is the case for a particular agent by Agents -> Connected -> -> Agent Parameters -> Environment Variables. Here's an example of JDK_* variables with their values:

JDK_14       C:\Program Files (x86)\Java\jdk1.4.2_19
JDK_15       C:\Program Files\Java\jdk1.5.0_22
JDK_15_x64   C:\Program Files\Java\jdk1.5.0_22
JDK_16       C:\Program Files (x86)\Java\jdk1.6.0_45
JDK_16_x64   C:\Program Files\Java\jdk1.6.0_45
JDK_17       C:\Program Files (x86)\Java\jdk1.7.0_76
JDK_17_x64   C:\Program Files\Java\jdk1.7.0_76
JDK_18       C:\Program Files\Java\jdk1.8.0_40
JDK_18_x64   C:\Program Files\Java\jdk1.8.0_40

Here, JDK_18 and JDK_18_x64 having the same value means that the agent hasn't found a 32-bit 1.8 JDK.


You can use the jvm tag to specify which JVM to use :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <jvm>${env.MY_JAVA_HOME}/bin/java</jvm>
        <skipTests>false</skipTests>
        <includes>
            <include>**/*Test.java</include>
        </includes>
        <parallel>methods</parallel>
        <threadCount>10</threadCount>
    </configuration>
</plugin>

This example assumes that you have a MY_JAVA_HOME environment variable.


Need Your Help

JavaFx Could not load @font-face font because of com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged

java javafx java-8 javafx-2 javafx-8

I had already asked a similar question here but it seems It wasn't clear since I had a lot of code in the project and couldn't post it here So please don't mark as duplicate.

unable to connect to MySQL database using JDBC

java mysql jdbc database-connection

I have this Java application in which I am now developing a module that can read and execute SQL statements from a file and output the results of the queries. If I launch the module via its main me...