Showing posts with label OSX. Show all posts
Showing posts with label OSX. Show all posts

Thursday, 16 August 2012

ColdFusion IceBreaker #6: JBOSS 7.1 and OpenOffice on Mac OSX for ColdFusion cfdocument

In continuation of  ColdFusion IceBreaker #5: JBOSS 7.1 and OpenOffice for ColdFusion cfdocument,
this post lists the detailed steps to follow for running OpenOffice code on JBOSS 7.1 on MAC OSX.

1)Install OpenOffice and add the installation path in the ColdFusion Admin
2)Edit the module.xml located in <JBOSS_HOME>/modules/sun/jdk/main and put the following entry there:
<path name="com/sun/star/lib/loader"/>
3)Copy oosdk folder from <jboss-deployment-dir>/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/ to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext. Though this is not recommended by MAC its the quickest way to ensure that the code runs well :P.
4)Edit standalone.conf located in <JBOSS_HOME>/bin
5)To JAVA_OPTS add the following entry:
-Djava.ext.dirs=<jboss-deployment-dir>/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/:<java-home>/lib/ext/
Here we use /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext if our JAVA HOME is default instead of <java-home>/lib/ext/
6)Restart jboss and you're all set 

OpenOffice+OSX Error: "The application...restore windows.." in OSX 10.7

While running OpenOffice  on Mac OSX 10.7.1 ,sometimes we repeatedly get an error "The application 'OpenOffice.org' was forced to quit while trying to restore its windows.Do you want to restore its windows again"

This is a persistant popup which might lead you into thinking that something is catastrophically wrong with your OpenOffice installation.

There are several solutions on the web but the only way that worked for me is as follows:
1) Kill all instances of soffice/OpenOffice.org
2) Goto /Users/<you>/Library/Saved Application State
Library is a hidden folder ,so use Go->Go to folder from the Finder Menu
3)Look for the folder org.openoffice.script.savedState
4)Delete this folder!!!
5)Now try to use Openoffice again.

You can observe that the popup disappears.

Alternatives (in case the previous method did not help)
 1) Kill all instances of soffice/OpenOffice.org

2) Goto /Users/<you>/Library/Application Support/OpenOffice.org/3
Library is a hidden folder ,so use Go->Go to folder from the Finder Menu
3)Look for a folder named user
4)Rename user folder to user.old (just so that you have backup)
5) Now try to use Openoffice again.
(If that still doesn't fix your problem , delete the new user folder and restore user.old to user and try again)

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 OpenOffice.org app to /Applications folder.Info will say /Applications/OpenOffice.org.app.This 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:
copyright.txt
README.txt
LICENSE.txt
jar-versions.xml
common
client
lib
docs
server
logs
bin

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
/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/rds.war/
/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/META-INF/

6)Check the presence of the OpenOffice library jars in
/Applications/JBOSS_MAC/jboss-6.1.0.Final/server/default/deploy/cfusion.ear/cfusion.war/WEBINF/cfusion/lib/oosdk/
This should now have the following folder structure:
classes
lib
lib folder should contain the following jars
-juh.jar
-jurt.jar
-ridl.jar
-unoil.jar

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
Eg:
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 run.sh
7.5) Add the locations to JBOSS_CLASSPATH
Eg:
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 ./run.sh -b 0.0.0.0 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">
</cfdocument>

View your pdf file.