You are here: Blog » Atomikos on Java 11

Atomikos on Java 11
How to run the ex­am­ples with Java 11

Read this for our ex­pe­ri­ence with run­ning on JDK 11...

Are you mov­ing be­yond Java 8 to Java 11 or high­er? Then you will have some fun with the break­ing changes in­tro­duced by the new mod­ule sys­tem, as well as maven con­fig­u­ra­tion changes to make it work. This page doc­u­ments our find­ings.

The ex­per­i­ment

To test with JDK 11 we ran our ex­am­ple pro­grams (or bet­ter: tried to make them run). To be clear: we did NOT re­com­pile our core prod­uct jars un­der Java 11. We did, how­ev­er re­com­pile and run our ex­am­ple pro­grams with maven. The rest of this page de­scribes the is­sues we en­coun­tered and our so­lu­tions.

Is­sue: maven-sure­fire-plu­g­in fails

What used to work in Java 8 no longer works in Java 11. Here is an ex­am­ple of a prob­lem we got:

The prob­lem

[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

So­lu­tion

Con­fig­ure the sure­fire plu­g­in 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 par­tic­u­lar in­ter­est are the forkCount and the java.sql mod­ule changes. Both are re­quired to get rid of the er­ror.
RSS

Comments

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