Showing posts with label CFML. Show all posts
Showing posts with label CFML. Show all posts

Monday, 30 March 2015

Cloud Tech 101

“It went up, it went up to the cloud”
“You can’t get it down from the cloud?”

“Nobody understands the cloud, it’s a ****ing mystery.”

... says Cameron Diaz ! Well, here is something that should help !




[Update]: Here is the link to a more detailed article : http://mashable.com/2015/04/02/public-private-hybrid-cloud/?utm_cid=mash-com-Tw-main-link

Source: http://www.intel.in/content/www/in/en/cloud-computing/cloud-computing-innovation-infographic.html

Tuesday, 5 February 2013

ColdFusion IceBreaker #8 : ColdFusion 32 bit or 64 bit ???

So what happens when you take over an existing ColdFusion installation and want to update it ?
Or something doesn't work and you want to verify if its "supposed" to work for a particular bit version???

Its a bit typical to check whether ColdFusion was installed in its 32bit or 64 bit flavor,particularly if you were not the one who installed it

Here are a few ways to detect the current bit version of your installed ColdFusion server

1)Use your install logs

Open the install log (Adobe_ColdFusion_X_xxxxx(optional for 9)_InstallLog.log.
It will contain the following information:
-java.version :  This is the version of the Java used in the installer.Might not necessarily match your system's java version
-java.vm.name : Observe this carefully .If its a 64bit install ,this value will mention 64 Eg: Java HotSpot(TM) 64-Bit Server VM' .If its a 32 bit install there wont be any such mention Eg: Java HotSpot(TM) Server VM
Instead of "Server" it might say "Client' depending on installation,but that is irrelevant for judging whether its a 32bit or a 64 bit install
-os.arch : This explicitly states x86 for 32 bit install and x64 for 64 bit install

2)Use java -version

Goto <ColdFusion-Home>/runtimr/jre/bin
Give java.exe -version
You should be able to see java version,runtime environment and the java vm name

N.B. The Java information in Administrator->System information reflects the java that CF is using as opposedto the java that the installer used,so don't count on it

Tuesday, 25 September 2012

ColdFusion IceBreaker #7 : Unprotect your protected PDF through CF

Protecting your PDF with a password is a common everyday use case .
Using ColdFusion this can be done in a single easy step.

But sometimes we need to programmatically de-crypt/un-protect the same PDF.
There can be various ways of accomplishing this feat,but again ColdFusion makes it easy and a single step process

The trick to get to the treat ( the un-protected pdf , in this case ) is to use cfpdf tag and set your encyption to none using the "encrypt" attribute. You can do so only if you have the owner password , as technically only the document owner should have the permissions to change the security settings of a document

So assuming your PDF is called MyPdf.pdf with a owner password of "changesettings",use the below mentioned code to remove password protection from your PDF

<cfpdf action="protect" source="MyPdf.pdf" destination="MyUnsafePdf.pdf" 
password="changesettings" encrypt="none" />

Open MyUnsafePdf.pdf and you have your pdf without password protection


Wednesday, 19 September 2012

Convert your pfx keystore to jks keystore

Many times we need to convert our PKCS12 keystore/digital signature/digital id file to JKS files.

There are various many ways of doing it . Most blogs talk about how OpenSSL would help you do it and other go on about new tools.But its all within java keytool's capabilities.

Its actually as simple as what I quote below.

Goto your <JAVA_HOME>/jre/bin


keytool -importkeystore -srckeystore MyPfx.pfx -srcstoretype pkcs12 -srcstorepass mysrcpassword  -destkeystore exportfrompfx.jks -deststoretype jks -deststorepass mydestpassword


This process will create a new jks file and call it exportfrompfx.jks

All the certificates with their aliases will be exported from MyPfx.pfx to exportfrompfx.jks

Use the following command then to verify your new keystore:

keytool -list -storetype jks -keystore exportfrompfx.jks -v


To selectively add each certificate use its alias.

Get the alias using the above mentioned list command

keytool -list -storetype jks -keystore exportfrompfx.jks -v


Use keytool to import that alias into your JKS keystore

keytool -importkeystore -srckeystore MyPfx.pfx -srcstoretype pkcs12 -srcstorepass mysrcpassword -srcalias alias -destkeystore exportfrompfx.jks -deststoretype jks -deststorepass mydestpassword -destalias destalias



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, 18 April 2012

ColdFusion IceBreaker #5: JBOSS 7.1 and OpenOffice for ColdFusion cfdocument


In JBOSS7.1 , there have been major changes in the class loading behaviour of applications .Due to this we need to make a few changes to use ColdFusion's cfdocument and other OpenOffice features.Class loading is based on modules,with each module having its module.xml in which one can specify dependencies on the other modules using the <dependencies> element.

To support OpenOffice with JBOSS7.1 for cfdocument, you need to:
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)Start JBOSS with the following flag in the standalone.bat/standalone.sh.
-Djava.ext.dirs=<jboss-deployment-dir>/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/oosdk/:<java-home>/lib/ext/
(':' for unix based machines and ';' in windows)

The <dependecies> element can be used to specify dependencies on the paths and packages  from the class loader which loaded JBoss Modules.These can in turn be specified for re-exported if specified using the <export> element.The <path> element is used here to list the paths.

Adding the oosdk package to the java.ext.dir ensures that the classes of that package can be found and loaded without them being on the actual class path.

One need not add the individual jars to the JBOSS classpath or the java classpath

Click here  for MAC OSX specific instructions. These just make life easier :D.

Thursday, 1 March 2012

ColdFusion IceBreaker #4 : The "CF10-HTML5 Video" story begins !


With Coldfusion 10, we deep dive into the world of HTML5 video support through the CFMEDIAPLAYER tag.

Then(CF 9) :  The cfmediaplayer tag could only support Flash videos,the likes of flv,f4v.

Now (CF 10):  The cfmediaplayer can now support HTML 5 videos , the likes of mp4,ogv,webm ; formats conditioned for video playback over the internet.These require no additional plugins. You can skin/style the player,use Javascript functions ,set event handlers and even set a customised title !

More on all that later!!

Snippet #1:  Just specify your HTML5 video in the source attribute of the cfmediaplayer tag
<cfmediaplayer name="player1" source="sample_webm.webm" />

Play the snippet in Firefox or Chrome to view the webm video

Alternately , you can use ColdFusion.MediaPlayer.setSource() method and add to your existing code.

Snippet #2 : Use the all new "type" attribute to tell your browser whether to play the same video as flash or HTML. This is pretty useful when you want to enforce a particular type of content to be sent to the client.
MP4 videos can play as flash and HTML videos. This essentially means that if you try to play an MP4 video with flash enabled,you see a flash player loaded (right click on the player and observe the "About Flash Player" info ) and when flash is disabled the HTML% player is loaded

Try this in Chrome to see the difference:
<cfmediaplayer name="player2" source="sample_mp4.mp4" type="html" /><br>
<cfmediaplayer name="player3" source="sample_mp4.mp4" type="flash" />
The Flash and HTML5 players have been designed to look as identical as possible so as to support seamless fallback.

Snippet #3: Use the HTML source tag to set multiple videos as sources to the cfmediaplayer tag and let ColdFusion handle the video playback depending on video support by the browser

<cfmediaplayer name="player4" source="sample_webm.webm" type="html">
<source src="sample_mp4.mp4" type="video/mp4" />
</cfmediaplayer>

Now play the snippet in IE9,Firefox,Chrome and Safari .

You will see :
IE9 and Safari5 : playing sample_mp4.mp4 in HTML because it currently doesnt support WEBM
Firefox and Chrome : playing sample_webm.webm

A few things to consider :


1)Use the <!DOCTYPE html > and the <head/> <body> tags to write your cfm page for best results. A few browsers will not render the player properly otherwise!
2)Can't play your video ?  Are you using a web server ? Then make sure the right mime-types are added so that content can be served to the client.
3)Video playback is subject to browser support for formats,codecs and rendering.

More on Flash-HTML fallback in the next post!

Downloads :

Right Click and save as to download sample_mp4.mp4

Right Click and save as to download sample_webm.webm







Sunday, 22 January 2012

ColdFusion IceBreaker #3: Configuring Websphere Application Server (WAS) with OpenOffice to support ColdFusion (CF) tagcfdocument

Configuring Websphere Application Server (WAS) with OpenOffice to support ColdFusion (CF) tag cfdocument.

Websphere Application Server (WAS)  is considered a fairly typical application sever considering its complex topology and various flavours.
This post is in continuation to the previous one which spoke of OpenOffice Configuration on JBOSS on Lion
Here I shall detail how to configure the same in Websphere Application Server 7.0 ND  (WAS) using IBM HTTP Server as the web sever.

The process is rather simple if you consider the amount of time and effort taken on other servers

1)Goto WAS Integrated Console
2)Goto Servers->Websphere Application Servers->server1
server1 is the default websphere application server created for a profile.Please use the the server on which you have deployed your ColdFusion Zeus application.For my purpose,I have used server1 and have deployed my ColdFusion ear on this server.
3)Click server1
4)On the Configuration tab of server1 , look for Java and Process Management.This can be found under Server Infrastructre section.Click "Java and Process Management"
5)Click "Process definition " from the Java and Process Management sub section
6)On the Configuration tab , look for Additional Properties.Under Additional Properties , you will  find a Java Virtual Machine link.Click it.
7)Place your links in Classpath text box using semi colon as the delimiter.For Example :


C:\<was -deployement-directory>\AppServer\profiles\<profile-name>\installedApps\<cell-name>\Adobe_ColdFusion_Zeus.ear\cfusion.war\WEB-INF\cfusion\lib\oosdk\lib\juh.jar; C:\<was -deployement-directory>\AppServer\profiles\<profile-name>\installedApps\<cell-name> \Adobe_ColdFusion_Zeus.ear\cfusion.war\WEB-INF\cfusion\lib\oosdk\lib\jurt.jar C:\<was -deployement-directory>\AppServer\profiles\<profile-name>\installedApps\<cell-name> \Adobe_ColdFusion_Zeus.ear\cfusion.war\WEB-INF\cfusion\lib\oosdk\lib\ridl.jar; C:\<was -deployement-directory>\AppServer\profiles\<profile-name>\installedApps\<cell-name> \Adobe_ColdFusion_Zeus.ear\cfusion.war\WEB-INF\cfusion\lib\oosdk\lib\unoil.jar; C:\<was -deployement-directory>\AppServer\profiles\<profile-name>\installedApps\<cell-name> \Adobe_ColdFusion_Zeus.ear\cfusion.war\WEB-INF\cfusion\lib\oosdk\classes

8)Restart your WAS server and you are good to go

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.

Wednesday, 5 October 2011

ColdFusion Icebreaker#1 : Tried CF yet ?


Most of us , if we have something to do with the world wide web,  know the basic concepts of servers...
We know about application servers,web servers...who they are,what they do and when they are used....
Tomcat , Apache , Websphere Appplication Server(popularly called WAS) are common names today.

ColdFusion (CF) is one such server with a huge difference. Its easy !
Easy to install,easy to create powerful applications in and easy to deploy.
You can use the ColdFusion Markup Language  (called CFML) to do pretty much all that you can in any other language, only in fewer lines of code!

The basics are pretty simple : you write .cfm pages(essentially similar to JSP pages) for the view and put your business related code in CFC (ColdFusion components..essentially similar to Java classes)

For instance, lets talk about DB connections . Most developers will/would at least once in their lives have done a DB call, and if Java is what you speak , then it pretty much follows a common algorithm of :

1)Choose the driver
2)Load the driver
3)Get a connection
4)Create handlers to execute your query
5)Run your query
6)Store your results
7)Use your results

Add to that all the necessary exception handling,connection setting, data source setup and what you have is a considerable amount of time spent coding and debugging before the code is good to go.

As of CF 9, thanks to ORM , it is as easy as writing a few tags

1)Setup your data source in the CF Admin data source section.This lets you choose your database from a drop down .All you need to provide are the connection parameters like IP,password etc
2)Provide this datasource name is an Application.cfc file
Eg:   <cfset this.name="MyORMApp"
       <cfset this.ormenabled="TRUE">
       <cfset this.datasource="<your-datasource-name>"
3)Create a cfc that maps to your table (Need not even specify the table name, as long as its the same as the cfc name)
Eg:   <cfcomponent persistent="true">
           <cfproperty name="ROLL NO">
           <cfproperty name="MARKS">
        </cfcomponent>
4)Directly use functions that perform the necessary pull and push of data from the database.
Use this in UI tags like cfgrid
Eg : EntityLoad() = select *

And voila !! you have run a select query without having to bother about the type of driver you used,its syntax and all the related complications.

All this and more..but in less lines of code.

Feel free to try CF..the developer edition is free !