channel example and plugin classes gives ClassNotFoundException

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

channel example and plugin classes gives ClassNotFoundException

Max Spring
I'm trying to call into Jenkins via the channel mechanism following the cli-channel-demo [1].
In my callable, I'm able to access Jenkins core classes, but not my own classes which sit in a plugin, getting ClassNotFoundExceptions.

     channel.call(new Callable<String,IOException>() {
         public String call() throws IOException {
             System.out.println("TopLevelItem.class --> "+TopLevelItem.class);
             System.out.println("MyUtil.class --> "+MyUtil.class);
             return "";
         }
     });

I can see the first output line on Jenkins' stdout:

     TopLevelItem.class --> interface hudson.model.TopLevelItem

But instead of the second output line, I see this in my caller's stdout:

     Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
             at hudson.remoting.UserRequest.perform(UserRequest.java:118)
             at hudson.remoting.UserRequest.perform(UserRequest.java:48)
             at hudson.remoting.Request$2.run(Request.java:287)
             at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
             at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
             at java.util.concurrent.FutureTask.run(FutureTask.java:138)
             at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
             ... 1 more
     Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
             at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
             at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
             at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
             at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
             at hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
             ... 7 more

I have intentionally excluded my plugin HPI from the caller's classpath, because it should use the class on the Jenkins side.

Is there a way to make the classloader see the plugin classes?
Thanks!
-Max

[1] https://github.com/jenkinsci/cli-channel-demo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: channel example and plugin classes gives ClassNotFoundException

Max Spring
Tried unsuccessfully to use DelegatingCallable and uberClassLoader:

     class RunTestCallable implements DelegatingCallable<String,Exception>{

         @Override
         public ClassLoader getClassLoader() {
             return Jenkins.getInstance().getPluginManager().uberClassLoader;
         }

         public String call() throws Exception {
             ...
         }
     }

but it barfs on not even getting the Jenkins class

     Caused by: java.lang.NoClassDefFoundError: jenkins/model/Jenkins
             at org.example.RunTestCallable.getClassLoader(RunTestCallable.java:10)
             at hudson.remoting.UserRequest.getClassLoader(UserRequest.java:76)
             at hudson.remoting.UserRequest.<init>(UserRequest.java:68)
             at hudson.remoting.Channel.call(Channel.java:667)
             ... 12 more

-Max


On 08/19/2011 01:25 PM, Max Spring wrote:

> I'm trying to call into Jenkins via the channel mechanism following the cli-channel-demo [1].
> In my callable, I'm able to access Jenkins core classes, but not my own classes which sit in a plugin, getting ClassNotFoundExceptions.
>
> channel.call(new Callable<String,IOException>() {
> public String call() throws IOException {
> System.out.println("TopLevelItem.class --> "+TopLevelItem.class);
> System.out.println("MyUtil.class --> "+MyUtil.class);
> return "";
> }
> });
>
> I can see the first output line on Jenkins' stdout:
>
> TopLevelItem.class --> interface hudson.model.TopLevelItem
>
> But instead of the second output line, I see this in my caller's stdout:
>
> Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
> at hudson.remoting.UserRequest.perform(UserRequest.java:118)
> at hudson.remoting.UserRequest.perform(UserRequest.java:48)
> at hudson.remoting.Request$2.run(Request.java:287)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> ... 1 more
> Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
> at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
> at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> at hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
> ... 7 more
>
> I have intentionally excluded my plugin HPI from the caller's classpath, because it should use the class on the Jenkins side.
>
> Is there a way to make the classloader see the plugin classes?
> Thanks!
> -Max
>
> [1] https://github.com/jenkinsci/cli-channel-demo
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: channel example and plugin classes gives ClassNotFoundException

stephenconnolly
In reply to this post by Max Spring
Which version of Jenkins are you using...

There are some edge case bugs with remoting and classloaders that I
found and KK fixed, and you'd want to be on something after remoting
was split into a separate githug repo to be sure those fixes are in.

-Stephen

On 19 August 2011 21:25, Max Spring <[hidden email]> wrote:

> I'm trying to call into Jenkins via the channel mechanism following the
> cli-channel-demo [1].
> In my callable, I'm able to access Jenkins core classes, but not my own
> classes which sit in a plugin, getting ClassNotFoundExceptions.
>
>    channel.call(new Callable<String,IOException>() {
>        public String call() throws IOException {
>            System.out.println("TopLevelItem.class --> "+TopLevelItem.class);
>            System.out.println("MyUtil.class --> "+MyUtil.class);
>            return "";
>        }
>    });
>
> I can see the first output line on Jenkins' stdout:
>
>    TopLevelItem.class --> interface hudson.model.TopLevelItem
>
> But instead of the second output line, I see this in my caller's stdout:
>
>    Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>            at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>            at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>            at hudson.remoting.Request$2.run(Request.java:287)
>            at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>            at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>            at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>            at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>            ... 1 more
>    Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>            at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>            at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>            at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>            at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>            at
> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>            at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>            at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>            at java.lang.reflect.Method.invoke(Method.java:597)
>            at
> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>            ... 7 more
>
> I have intentionally excluded my plugin HPI from the caller's classpath,
> because it should use the class on the Jenkins side.
>
> Is there a way to make the classloader see the plugin classes?
> Thanks!
> -Max
>
> [1] https://github.com/jenkinsci/cli-channel-demo
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: channel example and plugin classes gives ClassNotFoundException

Max Spring
I have been using 1.424.  I just reproduced my problem with 1.427.
The callable's classloader does not see my plugin classes.
-Max


On 08/22/2011 03:34 AM, Stephen Connolly wrote:

> Which version of Jenkins are you using...
>
> There are some edge case bugs with remoting and classloaders that I
> found and KK fixed, and you'd want to be on something after remoting
> was split into a separate githug repo to be sure those fixes are in.
>
> -Stephen
>
> On 19 August 2011 21:25, Max Spring<[hidden email]>  wrote:
>> I'm trying to call into Jenkins via the channel mechanism following the
>> cli-channel-demo [1].
>> In my callable, I'm able to access Jenkins core classes, but not my own
>> classes which sit in a plugin, getting ClassNotFoundExceptions.
>>
>>     channel.call(new Callable<String,IOException>() {
>>         public String call() throws IOException {
>>             System.out.println("TopLevelItem.class -->  "+TopLevelItem.class);
>>             System.out.println("MyUtil.class -->  "+MyUtil.class);
>>             return "";
>>         }
>>     });
>>
>> I can see the first output line on Jenkins' stdout:
>>
>>     TopLevelItem.class -->  interface hudson.model.TopLevelItem
>>
>> But instead of the second output line, I see this in my caller's stdout:
>>
>>     Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>             at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>             at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>             at hudson.remoting.Request$2.run(Request.java:287)
>>             at
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>             at
>> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>             at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>             at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>             at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>             ... 1 more
>>     Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>             at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>             at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>             at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>             at
>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>             at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>             at
>> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>             at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>             at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>             at java.lang.reflect.Method.invoke(Method.java:597)
>>             at
>> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>             ... 7 more
>>
>> I have intentionally excluded my plugin HPI from the caller's classpath,
>> because it should use the class on the Jenkins side.
>>
>> Is there a way to make the classloader see the plugin classes?
>> Thanks!
>> -Max
>>
>> [1] https://github.com/jenkinsci/cli-channel-demo
>>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: channel example and plugin classes gives ClassNotFoundException

kohsuke Kawaguchi (CB)

The issue Stephen is describing is actually the opposite. That was
remoting mechanism loading its own copy where it should have delegated
to a locally existing class. In Max's case it's failing to find the
class entirely.

In this case we were creating the server side of the channel end
incorrectly. I fixed this in 872dfe8aafa2eb4727d89016c7b08f6fb4794546
toward 1.429.


On 08/22/2011 10:19 AM, Max Spring wrote:

> I have been using 1.424.  I just reproduced my problem with 1.427.
> The callable's classloader does not see my plugin classes.
> -Max
>
>
> On 08/22/2011 03:34 AM, Stephen Connolly wrote:
>>  Which version of Jenkins are you using...
>>
>>  There are some edge case bugs with remoting and classloaders that I
>>  found and KK fixed, and you'd want to be on something after remoting
>>  was split into a separate githug repo to be sure those fixes are in.
>>
>>  -Stephen
>>
>>  On 19 August 2011 21:25, Max Spring<[hidden email]>   wrote:
>>>  I'm trying to call into Jenkins via the channel mechanism following the
>>>  cli-channel-demo [1].
>>>  In my callable, I'm able to access Jenkins core classes, but not my own
>>>  classes which sit in a plugin, getting ClassNotFoundExceptions.
>>>
>>>      channel.call(new Callable<String,IOException>() {
>>>          public String call() throws IOException {
>>>              System.out.println("TopLevelItem.class -->   "+TopLevelItem.class);
>>>              System.out.println("MyUtil.class -->   "+MyUtil.class);
>>>              return "";
>>>          }
>>>      });
>>>
>>>  I can see the first output line on Jenkins' stdout:
>>>
>>>      TopLevelItem.class -->   interface hudson.model.TopLevelItem
>>>
>>>  But instead of the second output line, I see this in my caller's stdout:
>>>
>>>      Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>>              at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>>              at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>>              at hudson.remoting.Request$2.run(Request.java:287)
>>>              at
>>>  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>>              at
>>>  java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>              at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>              at
>>>  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>              at
>>>  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>              ... 1 more
>>>      Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>>              at
>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>>              at
>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>>              at
>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>>              at
>>>  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>>              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>>              at
>>>  hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>>              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>              at
>>>  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>              at
>>>  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>              at java.lang.reflect.Method.invoke(Method.java:597)
>>>              at
>>>  hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>>              ... 7 more
>>>
>>>  I have intentionally excluded my plugin HPI from the caller's classpath,
>>>  because it should use the class on the Jenkins side.
>>>
>>>  Is there a way to make the classloader see the plugin classes?
>>>  Thanks!
>>>  -Max
>>>
>>>  [1] https://github.com/jenkinsci/cli-channel-demo
>>>
>>
>
>


--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Nectar, our professional version of Jenkins
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: channel example and plugin classes gives ClassNotFoundException

Max Spring
I'm getting a StackOverflowError (see below).
It looks like the UberClassLoader is delegating to itself.
-Max

Caused by: java.lang.StackOverflowError
         at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:447)
         at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544)
         at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:240)
         at java.lang.StringCoding.encode(StringCoding.java:272)
         at java.lang.String.getBytes(String.java:946)
         at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
         at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:228)
         at java.io.File.exists(File.java:733)
         at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:999)
         at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
         at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:68)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
         at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
         at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
         at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... many more of the same


On 08/23/2011 02:13 PM, Kohsuke Kawaguchi wrote:

>
> The issue Stephen is describing is actually the opposite. That was remoting mechanism loading its own copy where it should have delegated to a locally existing class. In Max's case it's failing to find the class entirely.
>
> In this case we were creating the server side of the channel end incorrectly. I fixed this in 872dfe8aafa2eb4727d89016c7b08f6fb4794546 toward 1.429.
>
>
> On 08/22/2011 10:19 AM, Max Spring wrote:
>> I have been using 1.424. I just reproduced my problem with 1.427.
>> The callable's classloader does not see my plugin classes.
>> -Max
>>
>>
>> On 08/22/2011 03:34 AM, Stephen Connolly wrote:
>>> Which version of Jenkins are you using...
>>>
>>> There are some edge case bugs with remoting and classloaders that I
>>> found and KK fixed, and you'd want to be on something after remoting
>>> was split into a separate githug repo to be sure those fixes are in.
>>>
>>> -Stephen
>>>
>>> On 19 August 2011 21:25, Max Spring<[hidden email]> wrote:
>>>> I'm trying to call into Jenkins via the channel mechanism following the
>>>> cli-channel-demo [1].
>>>> In my callable, I'm able to access Jenkins core classes, but not my own
>>>> classes which sit in a plugin, getting ClassNotFoundExceptions.
>>>>
>>>> channel.call(new Callable<String,IOException>() {
>>>> public String call() throws IOException {
>>>> System.out.println("TopLevelItem.class --> "+TopLevelItem.class);
>>>> System.out.println("MyUtil.class --> "+MyUtil.class);
>>>> return "";
>>>> }
>>>> });
>>>>
>>>> I can see the first output line on Jenkins' stdout:
>>>>
>>>> TopLevelItem.class --> interface hudson.model.TopLevelItem
>>>>
>>>> But instead of the second output line, I see this in my caller's stdout:
>>>>
>>>> Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>>> at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>>> at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>>> at hudson.remoting.Request$2.run(Request.java:287)
>>>> at
>>>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>>> at
>>>> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>> ... 1 more
>>>> Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>>> at
>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>>> at
>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>>> at
>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>>> at
>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>>> at
>>>> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>> at
>>>> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>>> ... 7 more
>>>>
>>>> I have intentionally excluded my plugin HPI from the caller's classpath,
>>>> because it should use the class on the Jenkins side.
>>>>
>>>> Is there a way to make the classloader see the plugin classes?
>>>> Thanks!
>>>> -Max
>>>>
>>>> [1] https://github.com/jenkinsci/cli-channel-demo
>>>>
>>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]

Max Spring
Another data point:

Printing the classloader instances in UberClassLoader.findClass()
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/PluginManager.java#L641

Gives
    cl=hudson.remoting.RemoteClassLoader@208e2fb5 this=classLoader hudson.PluginManager$UberClassLoader

I suspect the RemoteClassLoader's parent is then again the UberClassLoader.
Hence the infinite recursion.

Now this additional check does break the loop:

             if(cl!=null && cl!=this && !(cl instanceof URLClassLoader))
                 try {
                     return cl.loadClass(name);
                 } catch(ClassNotFoundException e) {
                     // not found. try next
                 }

(I wanted to check for RemoteClassLoader, but it's not visible here.)
Not sure whether this is the right way to fix the problem.

-Max


On 08/24/2011 05:37 PM, Max Spring wrote:

> I'm getting a StackOverflowError (see below).
> It looks like the UberClassLoader is delegating to itself.
> -Max
>
> Caused by: java.lang.StackOverflowError
> at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:447)
> at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544)
> at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:240)
> at java.lang.StringCoding.encode(StringCoding.java:272)
> at java.lang.String.getBytes(String.java:946)
> at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
> at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:228)
> at java.io.File.exists(File.java:733)
> at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:999)
> at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:68)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> ... many more of the same
>
>
> On 08/23/2011 02:13 PM, Kohsuke Kawaguchi wrote:
>>
>> The issue Stephen is describing is actually the opposite. That was remoting mechanism loading its own copy where it should have delegated to a locally existing class. In Max's case it's failing to find the class entirely.
>>
>> In this case we were creating the server side of the channel end incorrectly. I fixed this in 872dfe8aafa2eb4727d89016c7b08f6fb4794546 toward 1.429.
>>
>>
>> On 08/22/2011 10:19 AM, Max Spring wrote:
>>> I have been using 1.424. I just reproduced my problem with 1.427.
>>> The callable's classloader does not see my plugin classes.
>>> -Max
>>>
>>>
>>> On 08/22/2011 03:34 AM, Stephen Connolly wrote:
>>>> Which version of Jenkins are you using...
>>>>
>>>> There are some edge case bugs with remoting and classloaders that I
>>>> found and KK fixed, and you'd want to be on something after remoting
>>>> was split into a separate githug repo to be sure those fixes are in.
>>>>
>>>> -Stephen
>>>>
>>>> On 19 August 2011 21:25, Max Spring<[hidden email]> wrote:
>>>>> I'm trying to call into Jenkins via the channel mechanism following the
>>>>> cli-channel-demo [1].
>>>>> In my callable, I'm able to access Jenkins core classes, but not my own
>>>>> classes which sit in a plugin, getting ClassNotFoundExceptions.
>>>>>
>>>>> channel.call(new Callable<String,IOException>() {
>>>>> public String call() throws IOException {
>>>>> System.out.println("TopLevelItem.class --> "+TopLevelItem.class);
>>>>> System.out.println("MyUtil.class --> "+MyUtil.class);
>>>>> return "";
>>>>> }
>>>>> });
>>>>>
>>>>> I can see the first output line on Jenkins' stdout:
>>>>>
>>>>> TopLevelItem.class --> interface hudson.model.TopLevelItem
>>>>>
>>>>> But instead of the second output line, I see this in my caller's stdout:
>>>>>
>>>>> Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>>>> at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>>>> at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>>>> at hudson.remoting.Request$2.run(Request.java:287)
>>>>> at
>>>>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>>>> at
>>>>> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>>> at
>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>> at
>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>>> ... 1 more
>>>>> Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>>>> at
>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>>>> at
>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>>>> at
>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>>>> at
>>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>>>> at
>>>>> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>> at
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>> at
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>> at
>>>>> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>>>> ... 7 more
>>>>>
>>>>> I have intentionally excluded my plugin HPI from the caller's classpath,
>>>>> because it should use the class on the Jenkins side.
>>>>>
>>>>> Is there a way to make the classloader see the plugin classes?
>>>>> Thanks!
>>>>> -Max
>>>>>
>>>>> [1] https://github.com/jenkinsci/cli-channel-demo
>>>>>
>>>>
>>>
>>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]

kohsuke Kawaguchi (CB)

Yes, this code feels wrong.

I need to dig deeper why this was added in the first place, but I'd like
to remove this.

Thanks for the detective work!

On 08/25/2011 02:49 PM, Max Spring wrote:

> Another data point:
>
> Printing the classloader instances in UberClassLoader.findClass()
> https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/PluginManager.java#L641
>
> Gives
>      cl=hudson.remoting.RemoteClassLoader@208e2fb5 this=classLoader hudson.PluginManager$UberClassLoader
>
> I suspect the RemoteClassLoader's parent is then again the UberClassLoader.
> Hence the infinite recursion.
>
> Now this additional check does break the loop:
>
>               if(cl!=null&&  cl!=this&&  !(cl instanceof URLClassLoader))
>                   try {
>                       return cl.loadClass(name);
>                   } catch(ClassNotFoundException e) {
>                       // not found. try next
>                   }
>
> (I wanted to check for RemoteClassLoader, but it's not visible here.)
> Not sure whether this is the right way to fix the problem.
>
> -Max
>
>
> On 08/24/2011 05:37 PM, Max Spring wrote:
>>  I'm getting a StackOverflowError (see below).
>>  It looks like the UberClassLoader is delegating to itself.
>>  -Max
>>
>>  Caused by: java.lang.StackOverflowError
>>  at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:447)
>>  at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544)
>>  at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:240)
>>  at java.lang.StringCoding.encode(StringCoding.java:272)
>>  at java.lang.String.getBytes(String.java:946)
>>  at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
>>  at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:228)
>>  at java.io.File.exists(File.java:733)
>>  at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:999)
>>  at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
>>  at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
>>  at java.security.AccessController.doPrivileged(Native Method)
>>  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>>  at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:68)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>  at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>  at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>  at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>  ... many more of the same
>>
>>
>>  On 08/23/2011 02:13 PM, Kohsuke Kawaguchi wrote:
>>>
>>>  The issue Stephen is describing is actually the opposite. That was remoting mechanism loading its own copy where it should have delegated to a locally existing class. In Max's case it's failing to find the class entirely.
>>>
>>>  In this case we were creating the server side of the channel end incorrectly. I fixed this in 872dfe8aafa2eb4727d89016c7b08f6fb4794546 toward 1.429.
>>>
>>>
>>>  On 08/22/2011 10:19 AM, Max Spring wrote:
>>>>  I have been using 1.424. I just reproduced my problem with 1.427.
>>>>  The callable's classloader does not see my plugin classes.
>>>>  -Max
>>>>
>>>>
>>>>  On 08/22/2011 03:34 AM, Stephen Connolly wrote:
>>>>>  Which version of Jenkins are you using...
>>>>>
>>>>>  There are some edge case bugs with remoting and classloaders that I
>>>>>  found and KK fixed, and you'd want to be on something after remoting
>>>>>  was split into a separate githug repo to be sure those fixes are in.
>>>>>
>>>>>  -Stephen
>>>>>
>>>>>  On 19 August 2011 21:25, Max Spring<[hidden email]>  wrote:
>>>>>>  I'm trying to call into Jenkins via the channel mechanism following the
>>>>>>  cli-channel-demo [1].
>>>>>>  In my callable, I'm able to access Jenkins core classes, but not my own
>>>>>>  classes which sit in a plugin, getting ClassNotFoundExceptions.
>>>>>>
>>>>>>  channel.call(new Callable<String,IOException>() {
>>>>>>  public String call() throws IOException {
>>>>>>  System.out.println("TopLevelItem.class -->  "+TopLevelItem.class);
>>>>>>  System.out.println("MyUtil.class -->  "+MyUtil.class);
>>>>>>  return "";
>>>>>>  }
>>>>>>  });
>>>>>>
>>>>>>  I can see the first output line on Jenkins' stdout:
>>>>>>
>>>>>>  TopLevelItem.class -->  interface hudson.model.TopLevelItem
>>>>>>
>>>>>>  But instead of the second output line, I see this in my caller's stdout:
>>>>>>
>>>>>>  Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>>>>>  at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>>>>>  at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>>>>>  at hudson.remoting.Request$2.run(Request.java:287)
>>>>>>  at
>>>>>>  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>>>>>  at
>>>>>>  java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>>>>  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>>>>  at
>>>>>>  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>>>  at
>>>>>>  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>>>>  ... 1 more
>>>>>>  Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>>>>>  at
>>>>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>>>>>  at
>>>>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>>>>>  at
>>>>>>  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>>>>>  at
>>>>>>  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>>>>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>>>>>  at
>>>>>>  hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>>>>>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>  at
>>>>>>  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>>  at
>>>>>>  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>>  at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>  at
>>>>>>  hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>>>>>  ... 7 more
>>>>>>
>>>>>>  I have intentionally excluded my plugin HPI from the caller's classpath,
>>>>>>  because it should use the class on the Jenkins side.
>>>>>>
>>>>>>  Is there a way to make the classloader see the plugin classes?
>>>>>>  Thanks!
>>>>>>  -Max
>>>>>>
>>>>>>  [1] https://github.com/jenkinsci/cli-channel-demo
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Nectar, our professional version of Jenkins
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]

kohsuke Kawaguchi (CB)

I've removed this chunk and added some tests toward 1.429.

Thanks for catching this!

On 08/29/2011 10:11 AM, Kohsuke Kawaguchi wrote:

>
> Yes, this code feels wrong.
>
> I need to dig deeper why this was added in the first place, but I'd like
> to remove this.
>
> Thanks for the detective work!
>
> On 08/25/2011 02:49 PM, Max Spring wrote:
>>  Another data point:
>>
>>  Printing the classloader instances in UberClassLoader.findClass()
>>  https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/PluginManager.java#L641
>>
>>  Gives
>>       cl=hudson.remoting.RemoteClassLoader@208e2fb5 this=classLoader hudson.PluginManager$UberClassLoader
>>
>>  I suspect the RemoteClassLoader's parent is then again the UberClassLoader.
>>  Hence the infinite recursion.
>>
>>  Now this additional check does break the loop:
>>
>>                if(cl!=null&&   cl!=this&&   !(cl instanceof URLClassLoader))
>>                    try {
>>                        return cl.loadClass(name);
>>                    } catch(ClassNotFoundException e) {
>>                        // not found. try next
>>                    }
>>
>>  (I wanted to check for RemoteClassLoader, but it's not visible here.)
>>  Not sure whether this is the right way to fix the problem.
>>
>>  -Max
>>
>>
>>  On 08/24/2011 05:37 PM, Max Spring wrote:
>>>   I'm getting a StackOverflowError (see below).
>>>   It looks like the UberClassLoader is delegating to itself.
>>>   -Max
>>>
>>>   Caused by: java.lang.StackOverflowError
>>>   at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:447)
>>>   at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544)
>>>   at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:240)
>>>   at java.lang.StringCoding.encode(StringCoding.java:272)
>>>   at java.lang.String.getBytes(String.java:946)
>>>   at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
>>>   at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:228)
>>>   at java.io.File.exists(File.java:733)
>>>   at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:999)
>>>   at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
>>>   at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
>>>   at java.security.AccessController.doPrivileged(Native Method)
>>>   at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>>>   at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:68)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>>   at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>>   at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>>   at hudson.PluginManager$UberClassLoader.findClass(PluginManager.java:643)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>>   ... many more of the same
>>>
>>>
>>>   On 08/23/2011 02:13 PM, Kohsuke Kawaguchi wrote:
>>>>
>>>>   The issue Stephen is describing is actually the opposite. That was remoting mechanism loading its own copy where it should have delegated to a locally existing class. In Max's case it's failing to find the class entirely.
>>>>
>>>>   In this case we were creating the server side of the channel end incorrectly. I fixed this in 872dfe8aafa2eb4727d89016c7b08f6fb4794546 toward 1.429.
>>>>
>>>>
>>>>   On 08/22/2011 10:19 AM, Max Spring wrote:
>>>>>   I have been using 1.424. I just reproduced my problem with 1.427.
>>>>>   The callable's classloader does not see my plugin classes.
>>>>>   -Max
>>>>>
>>>>>
>>>>>   On 08/22/2011 03:34 AM, Stephen Connolly wrote:
>>>>>>   Which version of Jenkins are you using...
>>>>>>
>>>>>>   There are some edge case bugs with remoting and classloaders that I
>>>>>>   found and KK fixed, and you'd want to be on something after remoting
>>>>>>   was split into a separate githug repo to be sure those fixes are in.
>>>>>>
>>>>>>   -Stephen
>>>>>>
>>>>>>   On 19 August 2011 21:25, Max Spring<[hidden email]>   wrote:
>>>>>>>   I'm trying to call into Jenkins via the channel mechanism following the
>>>>>>>   cli-channel-demo [1].
>>>>>>>   In my callable, I'm able to access Jenkins core classes, but not my own
>>>>>>>   classes which sit in a plugin, getting ClassNotFoundExceptions.
>>>>>>>
>>>>>>>   channel.call(new Callable<String,IOException>() {
>>>>>>>   public String call() throws IOException {
>>>>>>>   System.out.println("TopLevelItem.class -->   "+TopLevelItem.class);
>>>>>>>   System.out.println("MyUtil.class -->   "+MyUtil.class);
>>>>>>>   return "";
>>>>>>>   }
>>>>>>>   });
>>>>>>>
>>>>>>>   I can see the first output line on Jenkins' stdout:
>>>>>>>
>>>>>>>   TopLevelItem.class -->   interface hudson.model.TopLevelItem
>>>>>>>
>>>>>>>   But instead of the second output line, I see this in my caller's stdout:
>>>>>>>
>>>>>>>   Caused by: java.lang.NoClassDefFoundError: org/example/MyUtil
>>>>>>>   at hudson.remoting.UserRequest.perform(UserRequest.java:118)
>>>>>>>   at hudson.remoting.UserRequest.perform(UserRequest.java:48)
>>>>>>>   at hudson.remoting.Request$2.run(Request.java:287)
>>>>>>>   at
>>>>>>>   java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>>>>>>   at
>>>>>>>   java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>>>>>   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>>>>>   at
>>>>>>>   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>>>>   at
>>>>>>>   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>>>>>   ... 1 more
>>>>>>>   Caused by: java.lang.ClassNotFoundException: org.example.MyUtil
>>>>>>>   at
>>>>>>>   org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
>>>>>>>   at
>>>>>>>   org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
>>>>>>>   at
>>>>>>>   org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
>>>>>>>   at
>>>>>>>   org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>>>>>>>   at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>>>>>>   at
>>>>>>>   hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch2(RemoteClassLoader.java:404)
>>>>>>>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>   at
>>>>>>>   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>>>   at
>>>>>>>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>>>   at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>>   at
>>>>>>>   hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
>>>>>>>   ... 7 more
>>>>>>>
>>>>>>>   I have intentionally excluded my plugin HPI from the caller's classpath,
>>>>>>>   because it should use the class on the Jenkins side.
>>>>>>>
>>>>>>>   Is there a way to make the classloader see the plugin classes?
>>>>>>>   Thanks!
>>>>>>>   -Max
>>>>>>>
>>>>>>>   [1] https://github.com/jenkinsci/cli-channel-demo
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Nectar, our professional version of Jenkins
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]

Tan, Yeong Sheng
In reply to this post by Max Spring
Hi Kohsuke,

Would it be ppossible to run cucumber gherkin type integration tests to test jenkins or the plugins contributions?

I am interested in contributing to adding such acceptance test driven approach to the jenkins and plugins contributions possibly through geb + cuke4duke.


Hope you can advice if this is something you hope to see being developed and folded into the testing capabilities of jenkins.

Thank you
------Original Message------
From: Kohsuke Kawaguchi
To: [hidden email]
Cc: Max Spring
ReplyTo: [hidden email]
Subject: Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]
Sent: Aug 30, 2011 2:56 AM


I've removed this chunk and added some tests toward 1.429.

Thanks for catching this!

On 08/29/2011 10:11 AM, Kohsuke Kawaguchi wrote:

>
> Yes, this code feels wrong.
>
> I need to dig deeper why this was added in the first place, but I'd like
> to remove this.
>
> Thanks for the detective work!
>
> On 08/25/2011 02:49 PM, Max Spring wrote:
>>  Another data point:
>>
>>  Printing the classloader instances in UberClassLoader.findClass()
>>  https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/PluginManager.java#L641
>>
>>  Gives
>>       cl=hudson.remoting.RemoteClassLoader@208e2fb5 this=classLoader hudson.PluginManager$UberClassLoader
>>
>>  I suspect the RemoteClassLoader's parent is then again the UberClassLoader.
>>  Hence the infinite recursion.
>>
>>  Now this additional check does break the loop:
>>
>>                if(cl!=null&&   cl!=this&&   !(cl instanceof URLClassLoader))
>>                    try {
>>                        return cl.loadClass(name);
>>                    } catch(ClassNotFoundException e) {
>>                        // not found. try next
>>                    }
>>
>>  (I wanted to check for RemoteClassLoader, but it's not visible here.)
>>  Not sure whether this is the right way to fix the problem.
>>
>>  -Max
>>
>>
>>  On 08/24/2011 05:37 PM, Max Spring wrote:
>>>   I'm getting a StackOverflowError (see below).
>>>   It looks like the UberClassLoader is delegating to itself.
>>>

------Original Message Truncated------

----------------------------------------------------------------------
This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.
Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law.
The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses.

References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link:
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]

domi
nice idea
+1


On 31.08.2011, at 16:33, Tan, Yeong Sheng wrote:

> Hi Kohsuke,
>
> Would it be ppossible to run cucumber gherkin type integration tests to test jenkins or the plugins contributions?
>
> I am interested in contributing to adding such acceptance test driven approach to the jenkins and plugins contributions possibly through geb + cuke4duke.
>
>
> Hope you can advice if this is something you hope to see being developed and folded into the testing capabilities of jenkins.
>
> Thank you
> ------Original Message------
> From: Kohsuke Kawaguchi
> To: [hidden email]
> Cc: Max Spring
> ReplyTo: [hidden email]
> Subject: Re: found fix? [Was: Re: channel example and plugin classes gives ClassNotFoundException]
> Sent: Aug 30, 2011 2:56 AM
>
>
> I've removed this chunk and added some tests toward 1.429.
>
> Thanks for catching this!
>
> On 08/29/2011 10:11 AM, Kohsuke Kawaguchi wrote:
>>
>> Yes, this code feels wrong.
>>
>> I need to dig deeper why this was added in the first place, but I'd like
>> to remove this.
>>
>> Thanks for the detective work!
>>
>> On 08/25/2011 02:49 PM, Max Spring wrote:
>>> Another data point:
>>>
>>> Printing the classloader instances in UberClassLoader.findClass()
>>> https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/PluginManager.java#L641
>>>
>>> Gives
>>>      cl=hudson.remoting.RemoteClassLoader@208e2fb5 this=classLoader hudson.PluginManager$UberClassLoader
>>>
>>> I suspect the RemoteClassLoader's parent is then again the UberClassLoader.
>>> Hence the infinite recursion.
>>>
>>> Now this additional check does break the loop:
>>>
>>>               if(cl!=null&&   cl!=this&&   !(cl instanceof URLClassLoader))
>>>                   try {
>>>                       return cl.loadClass(name);
>>>                   } catch(ClassNotFoundException e) {
>>>                       // not found. try next
>>>                   }
>>>
>>> (I wanted to check for RemoteClassLoader, but it's not visible here.)
>>> Not sure whether this is the right way to fix the problem.
>>>
>>> -Max
>>>
>>>
>>> On 08/24/2011 05:37 PM, Max Spring wrote:
>>>>  I'm getting a StackOverflowError (see below).
>>>>  It looks like the UberClassLoader is delegating to itself.
>>>>
>
> ------Original Message Truncated------
>
> ----------------------------------------------------------------------
> This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.
> Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law.
> The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses.
>
> References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link:
> http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.

Loading...