Wednesday, 23 November 2011

ColdFusion IceBreaker #2: Configuring JBoss in OSX Lion with OpenOffice to support cfdocument

ColdFusion empowers users to deploy it as a EAR/WAR file in their existing Application Server (J2EE config) and all the CF features can be used along with the benefits offered by the Application Server.
The <cfdocument> tag in ColdFusion lets you convert your word document to PDF and powerpoint presentations to PDF/HTML format and in some of its use cases , uses OpenOffice (About OpenOffice)

If OpenOffice is installed before ColdFusion is installed on your machine then ColdFusion detects the presence of OpenOffice and adds the location of OpenOffice to ColdFusion Administrator->Server Settings->Document

However,when deployed as a EAR/WAR, and despite detecting the OpenOffice location ,the OpenOffice library jars need to be added to the server configuration files  manually before Openoffice can be used through <cfdocument>.

A quick link for the know-it-all :ColdFusion : Configuring OpenOffice for J2EE servers

Below are mentioned a few steps for installing JBOSS on Mac OSX Lion and configuring OpenOffice on it.

1)Download OpenOffice for OSX .The zip file would download to the /Downloads folder on your mounted device

2)Unzip the file using Archive Utility and install OpenOffice

3)In some cases,it is shown as a device under the mounted device.Drag and drop the app to /Applications folder.Info will say /Applications/ will have the folder Contents.

4)Install JBOSS.Simply download the zip file,place it in a temporary location and unzip it
Eg: /Applications/JBOSS_MAC/jboss-6.1.0.Final/
JBOSS is now installed
This would now have the following folder structure:

5)Install ColdFusion as an EAR.Use the installer to create an ear file and expand it (java -xvf) to generate cfusion.war,META-INF and rds.war.Expand cfusion.war and rds.war.
This should now have the following folder structure:
/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF etc

6)Check the presence of the OpenOffice library jars in
This should now have the following folder structure:
lib folder should contain the following jars

7)Now,add these to the java paths of JBOSS as follows:

7.1) Goto /Applications/JBOSS_MAC/jboss-6.1.0.Final/bin
7.2) Edit run.conf
7.3) Add the locations to java.class.path
JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.class.path=/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/classes:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/lib:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib"
7.4) Edit
7.5) Add the locations to JBOSS_CLASSPATH
export JBOSS_CLASSPATH="$JBOSS_CLASSPATH:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/classes:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/lib/juh.jar:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/lib/jurt.jar:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/lib/ridljar:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/lib/unoil.jar:/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib"

8)Use sudo ./ -b to start your server
This will enable other IPs to access your ColdFusion Application

9)Login to ColdFusion Administrator->Server Settings->Document.Check the OpenOffice installation directory.

10)Try to run a simple <cfdocument> example
<cfdocument format="pdf" srcfile="<path_to_word_doc>" filename="<path_to_destination_with_file_name>" overwrite="true">

View your pdf file.

No comments:

Post a Comment