diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 91174a02659b9e41a0f7b21eab17e2f348326b70..2027cf5ed057856027b4da1effeae1f71aa9f92b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -55,6 +55,8 @@ test:frontend:
   stage: test
   coverage: '/(\d+.\d+) \% covered/'
   before_script:
+    # java.desktop module does not export Sun Graphics implementation for mockito
+    - export MAVEN_OPTS="$MAVEN_OPTS -DargLine=--add-opens=java.desktop/sun.java2d=ALL-UNNAMED"
     - apt-get update
     - DEBIAN_FRONTEND=noninteractive apt-get install -y libxrender1 libxtst6 fontconfig libfreetype6
     - mvn dependency:purge-local-repository -DmanualInclude="lcsb.mapviewer"
diff --git a/pom.xml b/pom.xml
index c0a85b13f577bf12df8e95e5aa336c031f231e7d..fe08b39548903a7b0f9fc7e903d5217ec7dcc236 100644
--- a/pom.xml
+++ b/pom.xml
@@ -213,7 +213,6 @@
 				<configuration>
 					<useSystemClassLoader>false</useSystemClassLoader>
 					<surefire.rerunFailingTestsCount>4</surefire.rerunFailingTestsCount>
-					<argLine>--add-opens java.desktop/sun.java2d=ALL-UNNAMED</argLine>
 				</configuration>
 			</plugin>
 			<plugin>