CF 10 & ClassNotFoundException: com.compoundtheory.classloader.NetworkClassLoader

749 views
Skip to first unread message

Mike Staver

unread,
Sep 23, 2012, 2:44:29 AM9/23/12
to javaloa...@googlegroups.com
I'm hoping someone can point me in the right direction here. I'm trying to use JavaLoader 1.1 and CF 10 to load the latest version of POI for some Excel spreadsheet manipulation. To get started, I have dropped the classloader jar file in a few different places. First, I put it in cfusion\lib. It didn't seem to work. I then moved it to cfusion\wwwroot\WEB-INF\lib, and again, it didn't seem to work. I obviously restarted CF both times before attempting to use it. I have verified that I'm not running in a secure sandbox mode and I have the box unchecked that says "Disable access to internal ColdFusion Java components" in CF Administrator under Settings. What happens is that I try to load up POI like so:

<cfset var.JLKey = "93345778-4949-4769-1235577891234657" />
<cfset var.paths = []>
<cfset var.jarpath = "/Users/mstaver/workspace/Fimble/ExternalCode" />
<cfdirectory action="list" name="files" directory="#var.jarpath#" filter="*.jar" recurse="true" />

<cfloop query="files">
    <cfset arrayAppend(var.paths, directory & "/" & name) />
</cfloop>
 
<cfif NOT structKeyExists(server, var.JLKey)>
    <cfset server[var.JLKey] = createObject("component", "component.JavaLoader").init(loadPaths=var.paths, loadColdFusionClassPath=true) />
</cfif>

I get an errror:

java.lang.ClassNotFoundException: com.compoundtheory.classloader.NetworkClassLoader at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method)

There is obviously a lot more output from the stack trace, but I cut it off. I'm getting this error on both a Mac OS X laptop and the Solaris 10 server where I'm going to be deploying the code. Both are running CF 10 with the latest patches and similar settings.

I have tried the latest JavaLoader.cfc from the GitHub location, the one checked in 2 months ago. That didn't fix this. Am I doing something wrong?

Mark Mandel

unread,
Sep 23, 2012, 11:16:23 AM9/23/12
to javaloa...@googlegroups.com
Don't move the jar files around. They are already right where they need to be. Javaloader will find them as long as the relative path structure all stays the same.

Mark

--
You received this message because you are subscribed to the Google Groups "javaloader-dev" group.
To post to this group, send email to javaloa...@googlegroups.com.
To unsubscribe from this group, send email to javaloader-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javaloader-dev?hl=en.



--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast

Mike Staver

unread,
Sep 23, 2012, 12:16:41 PM9/23/12
to javaloa...@googlegroups.com
Just to be clear, I was only talking about the classloader jar file. Where should it be for CF 10? The POI jar files are where I have kept them since this code worked going back to CF 7. 

-Mike

Mark Mandel

unread,
Sep 23, 2012, 1:05:55 PM9/23/12
to javaloa...@googlegroups.com
Mike,

For all versions of CF, you shouldn't be moving any of the jar files, especially the classloader one.

Mark

Mike Staver

unread,
Sep 23, 2012, 1:45:21 PM9/23/12
to javaloa...@googlegroups.com
I don't think your understanding my question. I'm trying to place your classloader jar from your JavaLoader project. I'm using the jar from 1.1. Where does it need to go in the CF 10 install? I currently have it in cfusion\wwwroot\WEB-INF\lib and I'm getting that error I posted below. I would never touch any of the built in adobe jar files. 

-Mike

Mark Mandel

unread,
Sep 23, 2012, 2:36:37 PM9/23/12
to javaloa...@googlegroups.com
Mike,

I do understand your question.

The answer is:

Don't move ANY of the .jar files that come with JavaLoader.  They are where they need to be.  If you move them, Javaloader can't find them, and hence you are getting the error you are seeing.

There are no special steps to installing .jar files in your ColdFusion install with JavaLoader - it handles it all for you without the need for anything needing to be placed in the ColdFusion classpath directly.

Mark

Mike Staver

unread,
Sep 23, 2012, 2:45:12 PM9/23/12
to javaloa...@googlegroups.com
Wow, I did not know that. In cf 7-9, I always copied that jar out into CF. I will make the changes. Thank you for the help, I don't know what I would do if this utility didn't exist :)

-Mike

Leigh

unread,
Sep 23, 2012, 2:56:25 PM9/23/12
to javaloa...@googlegroups.com
Mike,

You do not need to put the classloader jar in the CF class path. As Mark mentioned, the JavaLoader.cfc automatically looks for that jar in a subfolder called "./lib" that is *relative to the cfc's location*. If you placed JavaLoader.cfc beneath the web root, it will look for the jar in "cfusion/wwwroot/lib/" . You are getting an error because you moved it so the file cfusion/wwwroot/lib/classloader-xxxxxversionxxxxx.jar probably does not exist.

To install just download the project from riaforge.org. Then unzip it and copy the _entire_  javaLoader folder beneath the cfusion/wwwroot. ie So you'll have:

   cfusion/wwwroot/javaloader/JavaLoader.cfc
   cfusion/wwwroot/javaloader/JavaCompiler.cfc
   cfusion/wwwroot/javaloader/JavaProxy.cfc
   cfusion/wwwroot/license.txt
   cfusion/wwwroot/lib/classloader-xxxxxversionxxxxx.jar
   cfusion/wwwroot/support/*.*
   cfusion/wwwroot/tags/*.*
   cfusion/wwwroot/tmp/*.*

Then invoke the CFC with:

        createObject("component", "javaLoader.JavaLoader").init(...);

Once you have it working you can change the location, as long as you keep the relative folder structure in tact like Mark said.

-Leigh

Leigh

unread,
Sep 23, 2012, 2:57:37 PM9/23/12
to javaloa...@googlegroups.com
Mike - Whoops. Never mind. I see you already figured it out :)

-Leigh

Mike Staver

unread,
Sep 24, 2012, 12:13:54 AM9/24/12
to javaloa...@googlegroups.com
Yep, Mark's suggestion definitely did the trick. I can't believe I didn't know that before - I had always copied out the classloader jar into the coldfusion lib directories. It stopped working in version 10 - but apparently it never should have worked that way. Thanks Mark and Leigh :)


On 9/23/12 12:57 PM, Leigh wrote:
Mike - Whoops. Never mind. I see you already figured it out :)

-Leigh

Reply all
Reply to author
Forward
0 new messages