jenkinsci / configuration-as-code-plugin

Jenkins Configuration as Code Plugin
https://plugins.jenkins.io/configuration-as-code
MIT License
2.69k stars 718 forks source link

Class not found: io.jenkins.plugins.casc.model.Mapping #1339

Closed tomlankhorst closed 4 years ago

tomlankhorst commented 4 years ago

Since the latest release I get this exception.

This is since 1.37, does not occur to my knowledge in 1.36. https://github.com/jenkinsci/configuration-as-code-plugin/compare/configuration-as-code-1.36...configuration-as-code-1.37

YAML lint of configuration file is fine.

org.yaml.snakeyaml.error.YAMLException: Class not found: io.jenkins.plugins.casc.model.Mapping
    at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:664)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:322)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:331)
Caused: Can't construct a java object for tag:yaml.org,2002:io.jenkins.plugins.casc.model.Mapping; exception=Class not found: io.jenkins.plugins.casc.model.Mapping
 in /etc/jcasc/jenkins.yaml, line 1, column 1:
    jenkins:
    ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:219)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:173)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:157)
    at io.jenkins.plugins.casc.yaml.YamlUtils.loadFrom(YamlUtils.java:127)
    at io.jenkins.plugins.casc.yaml.YamlUtils.loadFrom(YamlUtils.java:112)
    at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:608)
    at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:291)
    at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:283)
Caused: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
Caused: java.lang.Error
    at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
    at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
    at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
    at jenkins.model.Jenkins$5.runTask(Jenkins.java:1133)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused: org.jvnet.hudson.reactor.ReactorException
    at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
    at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
    at jenkins.model.Jenkins.executeReactor(Jenkins.java:1166)
    at jenkins.model.Jenkins.<init>(Jenkins.java:966)
    at hudson.model.Hudson.<init>(Hudson.java:85)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
    at hudson.WebAppMain$3.run(WebAppMain.java:250)

Your checklist for this issue

🚨 Please review the guidelines for contributing to this repository.

Description

Upon fresh-install, I get this exception.

My plugins.txt file:

github-organization-folder
bitbucket-oauth
ws-cleanup
blueocean-git-pipeline
cloudbees-folder
cloudbees-bitbucket-branch-source
pipeline-model-definition
pipeline-stage-tags-metadata
pipeline-input-step
matrix-project
pipeline-github-lib
ssh-credentials
build-timeout
blueocean
matrix-auth
authorize-project
timestamper
credentials
github-branch-source
github
ssh-slaves
docker-plugin
git
bitbucket
hashicorp-vault-plugin
email-ext
configuration-as-code
jetersen commented 4 years ago

and your jenkins.yaml file?

jetersen commented 4 years ago

Did you install the plugin from GUI or did you preload the plugin?

timja commented 4 years ago

Is the snake yaml api plugin installed?

ChristianCiach commented 4 years ago

Same problem here. Since the update of the plugin just now our jenkins instance doesn't boot anymore, without any changes to our jenkins.yaml or any other changes, except for the rebuild of our docker image that is based on jenkins:lts.

Is the snake yaml api plugin installed?

Let me check that. I was expecting that all dependencies were automatically pulled into the docker image..?

ChristianCiach commented 4 years ago

Is the snake yaml api plugin installed?

Yes, snakeyaml-api is installed. The jpi-file and the folder snakeyaml-api is present inside the plugin-folder.

timja commented 4 years ago

I can reproduce this, downloaded latest version of jenkins, installed suggested plugins, installed jcasc,

added jenkins.yaml:

jenkins:
  systemMessage: testing
jetersen commented 4 years ago

What if we revert #1332 ?

timja commented 4 years ago

I've raised a PR to blacklist this version

timja commented 4 years ago

but yeah could just revert

jetersen commented 4 years ago

Not saying #1332 is the cause but it's a likely suspect.

timja commented 4 years ago

i would put money on it 😉,

Looking at the stacktrace I've seen this before, need to pass the right class loader to snake yaml

ChristianCiach commented 4 years ago

Looking at the stacktrace I've seen this before, need to pass the right class loader to snake yaml

Can confirm. We had similar issues inside our codebase when using SnakeYAML without setting an explicit ClassLoader.

timja commented 4 years ago

Untested fix here: https://github.com/jenkinsci/configuration-as-code-plugin/pull/1340

Will try test later tonight / tomorrow unless anyone else can confirm it works for them

tomlankhorst commented 4 years ago

Thank you for your quick response. @timja 's minimal jenkins.yaml triggers this issue indeed.