tag:blogger.com,1999:blog-5824660313967021040.post1451956580095209781..comments2022-03-26T08:56:28.677-07:00Comments on cfSearching: How to install POI on ColdFusion 8 using JavaLoader.cfcUnknownnoreply@blogger.comBlogger11125tag:blogger.com,1999:blog-5824660313967021040.post-92009454094220203872009-01-07T13:47:00.000-08:002009-01-07T13:47:00.000-08:00@Hamlet,I am very glad it was helpful! I know ther...@Hamlet,<BR/><BR/>I am very glad it was helpful! I know there are a lot more CF/POI resources out there now, versus a year or two ago. But as with many things, it is not always easy to find the right level of information that you need at the moment. So the more resources (to help bridge the gaps) the better. At least as far as I am concerned .. ;-)<BR/><BR/>- LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-87800855677931745532009-01-07T13:02:00.000-08:002009-01-07T13:02:00.000-08:00Leigh,You're a genius! I can't thank you enough f...Leigh,<BR/><BR/>You're a genius! I can't thank you enough for this blog. It worked just as you said it would.<BR/><BR/>You're probably the only one explaining CF and POI on the Internet right now - at least the only one I found in 2 weeks of surfing the web.<BR/><BR/>Thanks again, if there's anything I can do for you, please ask. I'm going to integrate this very important feature into a new website I'm creating www.iGetSpanish.com (still under construction).<BR/><BR/>Thanks again,<BR/><BR/>HamletAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-92046344973657409292009-01-07T12:12:00.000-08:002009-01-07T12:12:00.000-08:00@Hamlet,However, do I know change all my createObj...@Hamlet,<BR/><BR/><BR/><I>However, do I know change all my createObject(..) to javaLoader.Create(..)? </I><BR/><BR/>Yes, but just the ones in your own code and only the ones using the _java_ POI classes. Do not change anything in javaLoader.cfc, or it may not work properly. There is no issue with the Application.cfc because it is creating a "component", not a java object. <BR/><BR/>ie createObject("component", ..) rather than createObject("java", ..").<BR/><BR/>So the classpath problem does not apply.<BR/><BR/><BR/><BR/><BR/><I>there's an error now on the javaloader.cfc on line 93 "var class = getURLClassLoader().loadClass(arguments.className);"</I><BR/><BR/>That is be cause the javaLoader.create(..) expects different parameters than createObject(...). The javaLoader _only_ creates java objects, so you do not need to tell it the object "type" the way you do with createObject(). Just pass in the class name:<BR/><BR/>javaLoader.create("org.apache.poi.hwpf.HWPFDocument")<BR/><BR/>- LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-63452836661777804962009-01-07T10:57:00.000-08:002009-01-07T10:57:00.000-08:00Ahh - thank you. I made the change on the test co...Ahh - thank you. I made the change on the test code and it seemed to have done it. However, do I know change all my createObject(..) to javaLoader.Create(..)? The Application.cfc you showed us has the createObject and so does the javaloader.cfc - having said that, there's an error now on the javaloader.cfc on line 93 "var class = getURLClassLoader().loadClass(arguments.className);"<BR/><BR/>the error is similar: <BR/>java.lang.ClassNotFoundException: java<BR/><BR/>Thank you so much in advance,<BR/><BR/>HamletAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-48963843010976473272009-01-07T10:33:00.000-08:002009-01-07T10:33:00.000-08:00> that does not does not> c:\ColdFusion\lib\...> that does not does not<BR/>> c:\ColdFusion\lib\ <BR/><BR/>Should obviously be > c:\ColdFusion8\lib\. My typos abound today ;-)cfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-14036122391378443572009-01-07T10:30:00.000-08:002009-01-07T10:30:00.000-08:00@Hamlet,by the way, will this poi work on Macs?The...@Hamlet,<BR/><BR/><I>by the way, will this poi work on Macs?</I><BR/><BR/>Theoretically, yes. It is java so it should be platform independent. Though I do not know from personal experience.<BR/><BR/>-LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-56955035412133879372009-01-07T09:43:00.000-08:002009-01-07T09:43:00.000-08:00@Hamlet,I now keep getting this error on the line:...@Hamlet,<BR/><BR/><I>I now keep getting this error on the line:<BR/><cfset document = createObject("java", "org.apache.poi.hwpf.HWPFDocument").init( inputStream )><BR/></I><BR/><BR/>It is because you are using createObject(..) instead of javaLoader.create(..). When you use createObject() ColdFusion only searches for jars in the ColdFusion classpath. The built-in POI jar in the classpath is an older version that does not does not contain any of the hwpf classes. So that is why you are getting the "Class not found" exception. Use javaLoader.create(..) so ColdFusion will use the newer jars you downloaded instead. They do contain that class.<BR/><BR/><I>I'm not a Java developer, so I can't even begin to tell where the class would be</I><BR/><BR/>If you are curious, the built-in POI jars are located in the c:\ColdFusion\lib\ directory:<BR/><BR/>c:\ColdFusion\lib\poi-2.5.1-final-20040804.jar<BR/>c:\ColdFusion\lib\poi-contrib-2.5.1-final-20040804.jar<BR/><BR/>When you use createObject() those are the jars ColdFusion will use by default. Jars are essentially zip files. You can use a tool like pkzip, winzip, 7-zip to view the contents (Just do not extract them. They probably contain hundreds of classes ;-). <BR/><BR/>The class name "org.apache.poi.hwpf.HWPFDocument" is like a directory structure. It means that inside your POI jar, the class "HWPFDocument" will be located inside the subfolder: /org/apache/poi/hwpf. If you view the poi-2.5.1-final-20040804.jar you will notice that subfolder does not even exist. That is all the ClassNotFoundException means (ie the class file was not found ).<BR/><BR/><BR/>- LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-28467084673952530482009-01-07T06:39:00.000-08:002009-01-07T06:39:00.000-08:00Hi - thanks for responding.I now keep getting this...Hi - thanks for responding.<BR/><BR/>I now keep getting this error on the line: <BR/><cfset document = createObject("java", "org.apache.poi.hwpf.HWPFDocument").init( inputStream )><BR/><BR/>It says: Caused by: java.lang.ClassNotFoundException: org.apache.poi.hwpf.HWPFDocument<BR/><BR/>I tried it on both PC and Mac...by the way, will this poi work on Macs?<BR/><BR/>I'm not a Java developer, so I can't even begin to tell where the class would be...however, I did copy all the folders and files like you instructed. Any ideas would be greatly appreciated!<BR/><BR/>ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-28315165063811482252008-12-31T13:24:00.000-08:002008-12-31T13:24:00.000-08:00@Hamlet,1. No you do not need to extract the conte...@Hamlet,<BR/><BR/>1. No you do not need to extract the contents of the jar files. Just place the jar files themselves in the desired directory.<BR/><BR/>2. Yes, just copy it into the desired directory. _But_ the javaLoader uses multiple files, not just the CFC. You must copy all of the files into the desired directory for the component to work properly. <BR/><BR/>The .zip file for the current version (0.6) contains two folders:<BR/><BR/>/examples<BR/>/javaLoader<BR/><BR/>Copy the entire /javaLoader folder to the desired directory. For example, I copied it directly beneath my webroot:<BR/><BR/>C:\coldfusion8\wwwroot\javaloader\<BR/><BR/>3. Your error is probably related to missing files. Try copying all of the files as mentioned above. That should resolve any errors.<BR/><BR/>-LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-88385327895418076892008-12-31T07:23:00.000-08:002008-12-31T07:23:00.000-08:00I have a few questions:1. Do you have to 'extract'...I have a few questions:<BR/><BR/>1. Do you have to 'extract' all the jar files or just place them in the directory?<BR/><BR/>2. it says to 'install' the javaloader.cfc file - do you mean, just to copy it in the desired directory?<BR/><BR/>3. I keep getting this error for the javaloader.cfc file: networkClassLoaderClass = getServerURLClassLoader().loadClass("com.compoundtheory.classloader.NetworkClassLoader");<BR/><BR/>Please help, thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-27473925906213754682008-12-16T20:16:00.000-08:002008-12-16T20:16:00.000-08:00Hi Leigh,If anyone wants to know how to use the ja...Hi Leigh,<BR/><BR/>If anyone wants to know how to use the javaLoader with Ben Nadel's POI Utility custom tags, I have posted a blog entry here:<BR/><BR/>http://murrayhopkins.wordpress.com/2008/12/17/value-error-when-using-builtin-poi-in-coldfusion-mx7/<BR/><BR/>Cheers,<BR/>MurrayAnonymousnoreply@blogger.com