SCM plugin with Multi-Branch Pipeline throwing InaccessibleObjectException

110 views
Skip to first unread message

Berend D.

unread,
Apr 22, 2024, 2:42:59 AM4/22/24
to jenkin...@googlegroups.com
Hi,

I'm developing an SCM plugin and I'm now testing the interaction with the Multi-Branch Pipeline plugin.

This seems to work from the SCM perspective, but the logs are cluttered with these:
2024-04-19 14:52:20.553+0000 [id=87]    WARNING o.j.p.workflow.graph.FlowNode#persistSafe: failed to save actions for FlowNode id=7
java.lang.reflect.InaccessibleObjectException: Unable to make field static final long java.io.IOException.serialVersionUID accessible: module java.base does not "opens java.io" to unnamed module @3c3c290e
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
        at com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildDictionaryEntryForClass(FieldDictionary.java:176)
        at com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildMap(FieldDictionary.java:142)
        at com.thoughtworks.xstream.converters.reflection.FieldDictionary.fieldsFor(FieldDictionary.java:80)
        at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:167)
        at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:206)
        at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:163)
        at com.thoughtworks.xstream.converters.extended.ThrowableConverter.marshal(ThrowableConverter.java:62)
        at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
        at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
        at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
        at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:283)
        at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:270)
Caused: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.actions.ErrorAction#error for class org.jenkinsci.plugins.workflow.actions.ErrorAction
        at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:274)
        at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:241)
        at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:174)
        at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:226)
        at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:163)
...

I'm not sure if my plugin causes the issue or something else, as it's  org.jenkinsci.plugins.workflow.actions.ErrorAction which can not be serialized.

It might be that I need to modify the security settings for Java to fix this, but since this pertains to an unnamed module, I'm not sure what to change (and where, as it is likely a Maven config file somewhere which controls this?).

I'm using Jenkins 2.414.3 as a baseline and JDK 17.0.10 if that is any help.

Kind regards,
Berend Dekens

Jesse Glick

unread,
Apr 22, 2024, 8:15:45 AM4/22/24
to jenkin...@googlegroups.com
How are you running Jenkins when you see this? Should not occur when either using `mvn hpi:run` nor `mvn test` on a `JenkinsRule`-based test so far as I know. https://github.com/jenkinsci/plugin-pom/blob/692c7757f468ea6b1ecf52a39edb8379020816c3/pom.xml#L65-L70 and associated setup should be passing the right JVM argument to allow this reflection.

Tim Jacomb

unread,
Apr 22, 2024, 12:30:37 PM4/22/24
to jenkin...@googlegroups.com
I find in my IDE (IntelliJ) sometimes I need to add the `--add-opens` to command line arguments for hpi:run

On Mon, 22 Apr 2024 at 13:15, 'Jesse Glick' via Jenkins Developers <jenkin...@googlegroups.com> wrote:
How are you running Jenkins when you see this? Should not occur when either using `mvn hpi:run` nor `mvn test` on a `JenkinsRule`-based test so far as I know. https://github.com/jenkinsci/plugin-pom/blob/692c7757f468ea6b1ecf52a39edb8379020816c3/pom.xml#L65-L70 and associated setup should be passing the right JVM argument to allow this reflection.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3fMOePYaXEa6q4uFc-%2BJMB8dN%2B80-aLN7V4GtnMV_muQ%40mail.gmail.com.

Berend D.

unread,
Apr 29, 2024, 9:20:58 AM4/29/24
to jenkin...@googlegroups.com
Sorry for the late reply, it took me a while to figure out that the exception only triggers for Pipeline builds (which makes sense, given the message); but as I was working on normal Job runs, it seemed to have gone away - unfortunately it did not.

I launch Jenkins like this: mvnDebug hpi:run -Dport=5000

I do not see the flags which mvnDebug uses internally but I did find a MANIFEST.MF file which states:
Add-Opens: java.base/java.lang java.base/java.io java.base/java.util java.desktop/com.sun.beans.introspect

At the risk of jumping the gun, this morning I added this to the pom.xml file:
  <properties>
...
    <jenkins.addOpens>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</jenkins.addOpens>
  </properties>

And now the error seems to be gone.

Reply all
Reply to author
Forward
0 new messages