This works fine when I place the jar file core.jar in the CF lib
folder and restart the CF server. I am able to create an instance and
even create an image (which is the goal). However when I try with
javaLoader, I can still create an instance of PApplet, but I cannot
get any further because the next call fails. When I look through the
java code it seems to be failing because of this line:
Class<?> rendererClass = Class.forName(irenderer);
or at least this line does not find the class (irenderer is simply a
string).
Should Class.forName still work even if the library has been loaded by
javaLoader?
Should I add a specific import statement in my Java code. For example
irenderer can be "processing.core.P3DGraphics". I already have the
line
import processing.core. *;
at the top of my code. Should I also add
import processing.code.P3DGraphics;
And finally just a word of warning for those that are testing out both
having the java jar files in the ColdFusion lib folder or loading them
via javaLoader. When you are testing loading with javaLoader MAKE
SURE THE JAR FILE IS NO LONGER IN YOUR CF LIB folder. I almost went
crazy with that one today.
Thanks for any advice.
William
Another newbie mistake. I was writing
papplet = server.javaLoader.create( "processing.core.PApplet" );
canvas = papplet.createGraphics( 400, 400, papplet.P3D );
and forget the init(), so I changed it to
PAppletClass = server.javaLoader.create( "processing.core.PApplet" );
papplet = PAppletClass.init();
canvas = papplet.createGraphics( 400, 400, papplet.P3D ); <----- this
is the line that causes the problem
However that still didn't solve the problem :(.
Unfortunately I do not know exactly
which line in the Java code is causing the problem. I am getting the
error message
<< You need to use "Import Library" to add processing.core.P3DGraphics
to your sketch. >>
and I can see that line in a catch in the Java code so I assume that
the error is
occuring somewhere in these lines
Class<?> rendererClass =
Thread.currentThread().getContextClassLoader().loadClass(irenderer);
Constructor<?> constructor = rendererClass.getConstructor(new
Class[] { });
PGraphics pg = (PGraphics) constructor.newInstance();
pg.setParent(this);
pg.setPrimary(iprimary);
if (ipath != null) pg.setPath(ipath);
pg.setSize(iwidth, iheight);
// everything worked, return it
return pg;
Also, yesterday I thought it was using Class.forName but maybe I was
mistaken.
When I look at the code it seems to be using
Thread.currentThread().getContextClassLoader().loadClass(irenderer);
Could this code still work with JavaLoader? Is there a potential
problem here?
William
Anyway for now I have gone back to the .jar in the CF lib directory;
That works, and I don't have
much time to experiment. Anyway the Processing code writes to a
graphics context in a
java applet class and I don't know if I can get that working on the
server so that it is a bigger problem.
Works fine running locally from the develeoper CF server.
Thanks very much for the help.
William
On Mar 10, 4:05 pm, Dennis Clark <boomf...@gmail.com> wrote:
> I've seen Mark mention using JavaLoader with thread context classloaders
> before:
>
> http://groups.google.com/group/javaloader-dev/browse_frm/thread/879b7...
Thanks for that. Once I saw the constructor for the class I sensed
that it might have been discussed before:
Just I was focussing on Class.forName; I think that was old code that
had been commented out.
Maybe I could subclass the PApplet class and override the method
causing the problem.
Anyway for now I have gone back to the .jar in the CF lib directory;
That works, and I don't have
much time to experiment. Anyway the Processing code writes to a
graphics context in a
java applet class and I don't know if I can get that working on the
server so that it is a bigger problem.
Works fine running locally from the develeoper CF server.
On Mar 10, 10:34 pm, Mark Mandel <mark.man...@gmail.com> wrote:
> On Thu, Mar 11, 2010 at 4:41 AM, wfisk <william.f...@gmail.com> wrote:
> > Thanks for that. Once I saw the constructor for the class I sensed
> > that it might have been discussed before:
> > Just I was focussing on Class.forName; I think that was old code that
> > had been commented out.
> > Maybe I could subclass the PApplet class and override the method
> > causing the problem.
>
> It's possible. Libraries that do dynamic loading of classes really need a
> way to manually set the ClassLoader that is being used. Unfortunately very
> few do.
>
>
>
> > Anyway for now I have gone back to the .jar in the CF lib directory;
> > That works, and I don't have
> > much time to experiment. Anyway the Processing code writes to a
> > graphics context in a
> > java applet class and I don't know if I can get that working on the
> > server so that it is a bigger problem.
> > Works fine running locally from the develeoper CF server.
>
> Stupid question - it works on your machine, but you're worried it won't work
> on another machine? No sure what the issue is here?
>
> --