Reputation: 997
Hey I'm trying to get a Maven Java project to run via Jenkins build, It run perfectly via the command line but when I run this via Jenkins. I get this error:
Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @425ea9cb
here is the full stacktrace
Building remotely on Windows10 in workspace c:\jenkins\workspace\SELENIUM Single-Browser Automated Test
hudson.remoting.ProxyException: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @425ea9cb
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.lang.reflect.Field.checkCanSetAccessible(Unknown Source)
at java.lang.reflect.Field.setAccessible(Unknown Source)
at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from ip-172-20-68-132.eu-central-1.compute.internal/172.20.68.132:42200
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:955)
at hudson.FilePath.act(FilePath.java:1072)
at hudson.FilePath.act(FilePath.java:1061)
at org.jenkinsci.plugins.gitclient.Git.getClient(Git.java:144)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:822)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:813)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1810)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused: hudson.remoting.ProxyException: java.lang.ExceptionInInitializerError
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:811)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:465)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:378)
at hudson.util.XStream2.<init>(XStream2.java:113)
at hudson.ProxyConfiguration.<clinit>(ProxyConfiguration.java:308)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.proxy.$Proxy10.<clinit>(Unknown Source)
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at hudson.remoting.RemoteInvocationHandler.wrap(RemoteInvocationHandler.java:167)
at hudson.remoting.Channel.export(Channel.java:768)
at hudson.remoting.Channel.export(Channel.java:731)
at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.writeReplace(LegacyCompatibleGitAPIImpl.java:198)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeWriteReplace(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at hudson.remoting.UserRequest._serialize(UserRequest.java:264)
at hudson.remoting.UserRequest.serialize(UserRequest.java:273)
at hudson.remoting.UserRequest.perform(UserRequest.java:223)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
at java.lang.Thread.run(Unknown Source)
Finished: FAILURE
Jenkins is not even checking out code from the repository, It is on a windows machine and the version of Java is 10 can anyone help?
Upvotes: 6
Views: 24668
Reputation: 11
If you are getting BeanException error or Exception initization error it is still not resolved then change your JDK install JDK 1.8 or 9 Exception How to set Eclipse/STS -> Windows ->Preferences ->Java -> Installed JRE-> Add-> Select the directory where you download the JDK (default c:/programFiles/Java/jre1.8) . click next -> select jre1.8->Apply
It resolved for me
Upvotes: 1
Reputation: 479
The following post gives a generic overview of the problem and discusses a workaround that uses the --add-opens
command line argument to java: https://stackoverflow.com/a/41265267/9457431
Using multiple instances of that command line argument allowed me to avoid the exception from the question and similar exceptions raised by the Jenkins agent. Below are the exceptions I encountered and the corresponding arguments that allow the exceptions to be avoided.
Exceptions:
hudson.remoting.ProxyException: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @2c07c27c
hudson.remoting.ProxyException: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @5f14797f
hudson.remoting.ProxyException: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.String java.text.AttributedCharacterIterator$Attribute.getName() accessible: module java.base does not "opens java.text" to unnamed module @1bd564bd
hudson.remoting.ProxyException: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.util.Map java.awt.font.TextAttribute.instanceMap accessible: module java.desktop does not "opens java.awt.font" to unnamed module @e93c28
Command Line Arguments:
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens java.desktop/java.awt.font=ALL-UNNAMED
Here's the agent launch command altogether:
java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED -jar agent.jar -jnlpUrl https://<Jenkins URL>/computer/<Node Identifier>/slave-agent.jnlp -secret <Secret Value> -workDir "<Work Dir>"
Note: I'm using openjdk 11 and Jenkins 2.263.2
Upvotes: 9