Jenkins Build Success Only when i restart jenkins

I have recently upgraded the Jenkins version from 2.319.2 to 2.346.2.

Post that my builds are failing at “def files = new FileNameFinder().getFileNames(env.WORKSPACE,‘*/.war *//.war */.ear *//.ear’);”.

if I restart my Jenkins and trigger the same job it gets success, however, if I retrigger the same job again it gets fails. Each time I restart Jenkins it gets success only once.

Error:

java.lang.ClassCastException: class org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to class org.apache.xerces.xni.parser.XMLParserConfiguration (org.apache.xerces.parsers.XIncludeAwareParserConfiguration is in unnamed module of loader org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader @49cc49d9; org.apache.xerces.xni.parser.XMLParserConfiguration is in unnamed module of loader org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader @6d07455b)

See the Jenkins upgrade guide where it advises you to upgrade all your plugins when upgrading Jenkins. That looks similar to messages that have been seen elsewhere when plugins needed to be updated.

also is that a class you made with pipeline steps? otherwise it’ll only work on your controller, won’t actually work on the build agent.

I have updated the plugins and tested the, still the same issue. But once I restart the Jenkins first time build will get success then after its failing.

Maybe just switch to using findFiles from the pipelines-utility-steps plugin?