service library in Jenkins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

service library in Jenkins

nicolas de loof-2
Hi there,

I'm writing an extension to jenkins that can't be packaged as a plugin (need to be ran before plugins get loaded) so I created an InitLoader as a Service


@MetaInfServices
public class InitListener implements InitReactorListener {

    @Override
    public void onTaskStarted(Task task) {
        System.out.println("started :" + task.toString());
    }
...
}

When Jenkins starts I get this error =

GRAVE: Failed to initialize Jenkins
hudson.util.HudsonFailedToLoad: java.lang.NoClassDefFoundError: hudson/init/InitReactorListener
at hudson.WebAppMain$3.run(WebAppMain.java:247)
Caused by: java.lang.NoClassDefFoundError: hudson/init/InitReactorListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at com.google.common.collect.Lists.newArrayList(Lists.java:139)
at com.google.common.collect.Lists.newArrayList(Lists.java:119)
at jenkins.InitReactorRunner.buildReactorListener(InitReactorRunner.java:63)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1096)
at jenkins.model.Jenkins.<init>(Jenkins.java:900)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:233)


For a reason I can't get, this service when loaded can't access jenkins.war core classes.

I'm running from plain jenkins.war 

java -jar jenkins-2.107.3.war --commonLibFolder=./lib/


Any thoughts ?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANMVJz%3D3aDA2053-cu5oZYU3S%3DXwgXWQkPL2WEqMweuQgDO7Sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: service library in Jenkins

Jesse Glick-4
On Fri, May 18, 2018 at 9:03 AM, nicolas de loof
<[hidden email]> wrote:
> I'm writing an extension to jenkins that can't be packaged as a plugin (need
> to be ran before plugins get loaded)

I think what you are looking for is to use a standard plugin layout
but replacing

<packaging>hpi</packaging>

with

<packaging>jenkins-module</packaging>

and then add it to the list here:

https://github.com/jenkinsci/jenkins/blob/ac749d669d6ba8bd77c0827c8705c9454f973a6a/war/pom.xml#L95-L134

or use `custom-war-packager` to retrofit it into an existing
`jenkins.war` artifact.

(Most of these actually could be converted to regular plugins, I
think; it is only those things which genuinely need to run code before
the Jenkins plugin manager is initialized which must be modules, such
as `ConfidentialStore` implementations.)

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2w9%2BJmfXJh-X63u3smvQstvV6JgGM2T4ML76K%3DXoBZ3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: service library in Jenkins

nicolas de loof-2
Thanks for the tip

Le ven. 18 mai 2018 à 18:50, Jesse Glick <[hidden email]> a écrit :
On Fri, May 18, 2018 at 9:03 AM, nicolas de loof
<[hidden email]> wrote:
> I'm writing an extension to jenkins that can't be packaged as a plugin (need
> to be ran before plugins get loaded)

I think what you are looking for is to use a standard plugin layout
but replacing

<packaging>hpi</packaging>

with

<packaging>jenkins-module</packaging>

and then add it to the list here:

https://github.com/jenkinsci/jenkins/blob/ac749d669d6ba8bd77c0827c8705c9454f973a6a/war/pom.xml#L95-L134

or use `custom-war-packager` to retrofit it into an existing
`jenkins.war` artifact.

(Most of these actually could be converted to regular plugins, I
think; it is only those things which genuinely need to run code before
the Jenkins plugin manager is initialized which must be modules, such
as `ConfidentialStore` implementations.)

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2w9%2BJmfXJh-X63u3smvQstvV6JgGM2T4ML76K%3DXoBZ3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANMVJzkPGbqctsifZmoTXixvV3mFRUw2ip7CWQTELR%2B_uuQJtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: service library in Jenkins

nicolas de loof-2
didn't help unfortunately. Still get NoClassDefFoundError: hudson/model/listeners/RunListener

note : I'm not using custom-war-packager, but --commonLibFolder jenkins.war launcher option. Not sure this is commonly used ...

2018-05-18 18:53 GMT+02:00 nicolas de loof <[hidden email]>:
Thanks for the tip

Le ven. 18 mai 2018 à 18:50, Jesse Glick <[hidden email]> a écrit :
On Fri, May 18, 2018 at 9:03 AM, nicolas de loof
<[hidden email]> wrote:
> I'm writing an extension to jenkins that can't be packaged as a plugin (need
> to be ran before plugins get loaded)

I think what you are looking for is to use a standard plugin layout
but replacing

<packaging>hpi</packaging>

with

<packaging>jenkins-module</packaging>

and then add it to the list here:

https://github.com/jenkinsci/jenkins/blob/ac749d669d6ba8bd77c0827c8705c9454f973a6a/war/pom.xml#L95-L134

or use `custom-war-packager` to retrofit it into an existing
`jenkins.war` artifact.

(Most of these actually could be converted to regular plugins, I
think; it is only those things which genuinely need to run code before
the Jenkins plugin manager is initialized which must be modules, such
as `ConfidentialStore` implementations.)

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2w9%2BJmfXJh-X63u3smvQstvV6JgGM2T4ML76K%3DXoBZ3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANMVJzncsaHrzxar7iP2d2As_0Wgf9nNe8P53vMsUoUQmoD%3D1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: service library in Jenkins

Jesse Glick-4
On Fri, May 18, 2018 at 3:19 PM, nicolas de loof
<[hidden email]> wrote:
> I'm not using custom-war-packager, but --commonLibFolder jenkins.war
> launcher option.

Never heard of it, and likely does not work for this purpose. You need
an entry in `jenkins.war!/WEB-INF/lib/*.jar` as I said.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3rMm-CTXH-TpKTyysL0WnOKKAQ41gbHHQOYCJeaVTmxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: service library in Jenkins

nicolas de loof-2
right, this option indeed is used to add some jars to the higher level classloader

2018-05-18 23:31 GMT+02:00 Jesse Glick <[hidden email]>:
On Fri, May 18, 2018 at 3:19 PM, nicolas de loof
<[hidden email]> wrote:
> I'm not using custom-war-packager, but --commonLibFolder jenkins.war
> launcher option.

Never heard of it, and likely does not work for this purpose. You need
an entry in `jenkins.war!/WEB-INF/lib/*.jar` as I said.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3rMm-CTXH-TpKTyysL0WnOKKAQ41gbHHQOYCJeaVTmxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANMVJz%3DzwUQxouaNSi3FfuG90M2wX_9noM%3DzyW--eUzZ-BweTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.