You are here: Blog » Atomikos on Java 11

Atomikos on Java 11
How to run the examples with Java 11

|
Read this for our experience with running on JDK 11…

Are you moving beyond Java 8 to Java 11 or higher? Then you will have some fun with the breaking changes introduced by the new module system, as well as maven configuration changes to make it work. This page documents our findings.

The experiment

To test with JDK 11 we ran our example programs (or better: tried to make them run). To be clear: we did NOT recompile our core product jars under Java 11. We did, however recompile and run our example programs with maven. The rest of this page describes the issues we encountered and our solutions.

Issue: maven-surefire-plugin fails

What used to work in Java 8 no longer works in Java 11. Here is an example of a problem we got:

The problem

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project examples-jta: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null: javax/sql/DataSource: javax.sql.DataSource -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Solution

Configure the surefire plugin like this:

<plugin>
   <artifactId>maven-surefire-plugin</artifactId>
   <configuration>
      <forkCount>0</forkCount> 
      <argLine>-Xmx512m --add-modules java.sql</argLine> 
      <workingDirectory>${project.build.directory}</workingDirectory>
    </configuration>
</plugin>

Of particular interest are the forkCount and the java.sql module changes. Both are required to get rid of the error.

Add a comment

Corporate Information

Atomikos Corporate Headquarters
Hoveniersstraat, 39/1, 2800
Mechelen, Belgium

Contact Us

Copyright 2026 Atomikos BVBA | Our Privacy Policy
By using this site you agree to our cookies. More info. That's Fine