Strange NoClassDefFoundError when inside MaxClock

Apr 9, 2008 at 5:43am

Strange NoClassDefFoundError when inside MaxClock

I’m getting a NoClassDefFoundError when I try to run some code from a MaxClock. This code can be executed repeatedly outside of a MaxClock with no problems. How is that possible?

I’m interacting with JRuby here, so it may be a bad interaction with JRuby’s ClassLoader. I’m trying to implement a file autowatch mechanism for ruby scripts in my max ruby object. I gave up on the MaxClock approach and implemented the file watcher in a Java Thread, which is probably a more appropriate solution. That seems to work fine so far.

Anyway, thought this was pretty weird! Maybe if anyone else is having issues with MaxClock you should just switch to using standard Java Threads.

The class in question is definitely on Max’s classpath.

java.lang.NoClassDefFoundError: org/jruby/runtime/callback/FastInvocationCallback
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at org.jruby.util.JRubyClassLoader.defineClass(JRubyClassLoader.java:25)

sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.cycling74.max.Callback.execute(Callback.java:300)
at com.cycling74.max.MaxClock.tick(MaxClock.java:149)

#36804
Apr 9, 2008 at 3:59pm

hey adam.
definitely seems to be some sort of strange classloader interaction.
is org/jruby/runtime/callback in your
jruby classpath??

regardless, i would probably do file watcher with a java thread too.

t

On Apr 8, 2008, at 22:43 PM, Adam Murray wrote:

>
> I’m getting a NoClassDefFoundError when I try to run some code from
> a MaxClock. This code can be executed repeatedly outside of a
> MaxClock with no problems. How is that possible?
>
> I’m interacting with JRuby here, so it may be a bad interaction
> with JRuby’s ClassLoader. I’m trying to implement a file autowatch
> mechanism for ruby scripts in my max ruby object. I gave up on the
> MaxClock approach and implemented the file watcher in a Java
> Thread, which is probably a more appropriate solution. That seems
> to work fine so far.
>
> Anyway, thought this was pretty weird! Maybe if anyone else is
> having issues with MaxClock you should just switch to using
> standard Java Threads.
>
> The class in question is definitely on Max’s classpath.
>
> java.lang.NoClassDefFoundError: org/jruby/runtime/callback/
> FastInvocationCallback
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
> at org.jruby.util.JRubyClassLoader.defineClass
> (JRubyClassLoader.java:25)
> …
> sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at com.cycling74.max.Callback.execute(Callback.java:300)
> at com.cycling74.max.MaxClock.tick(MaxClock.java:149)
>
>
> –
> Adam Murray
> compusition.com

#126497
Apr 9, 2008 at 5:56pm

Quote: topher lafata wrote on Wed, 09 April 2008 08:59
—————————————————-
> hey adam.
> definitely seems to be some sort of strange classloader interaction.
> is org/jruby/runtime/callback in your
> jruby classpath??

That class is in jruby.jar, which is on Max’s classpath (Cycling ’74/java/lib). I believe JRuby has access to everything on the JVM (i.e. Max’s) classpath since it’s running inside MXJ. There is a separate path I need to configure for the context of the ruby scripts, and jruby.jar is on there too. I believe the JRuby classloader is for that script context. This error occurs the moment I try to eval a script when the stack trace starts with MaxClock.

I was wondering what MaxClock might be doing that doesn’t happen when I spawn my own Thread. If I knew a little more about the Max side I might be able to post intelligent questions on the JRuby mailing list.

> regardless, i would probably do file watcher with a java thread too.

Yeah, so I’m not stuck on this issue. Just curious what’s going on here.

#126498

You must be logged in to reply to this topic.