Tag Archives: open source

Why Coldfusion / CFML has its place and is worth to learn it

I actually never indulge in conversations why one programming language is better then another, because what is right to you, does not automatically mean, it is right for someone else. So, for me ColdFusion, or as we call the language itself – CFML, works very well.

Nevertheless, in this post I like to clear up some confusion that has been around. I can see where the confusion comes from as Coldfusion has gone from Allaire to Macromedia and is now “in the hands” of Adobe.

In any case, here are some reasons why CFML is still worth for you to learn.

  • CFML is open source and yes you can use it for free. I guess, many people are put off by the fact that Coldfusion has had a big price tag on it in the past. True, given the nature of PHP, Java, Phyton, Ruby, etc. being free, there was actually no reason to shell out your hard earned buck for some application server and on top of it even learn the language. Thanks to the short sighted business decisions of Macromedia and now Adobe or shall we say with the greedy money making mentality of its management, Coldfusion has been faced with a drainage of developers.
    Fortunately, this has all changed with the advent of OpenBD – the first real open source CFML server, followed shortly by Railo, another popular open source CFML server. In other words, to learn CFML and to deploy your applications, is now free and free to be.
  • Write less code. Compared to PHP, Java, C++, even Ruby and Python – CFML allows you to write the same program with much much fewer lines of code. Why would you want spend your precious time writing more code when you can do it for less? As a matter of fact, you can write your application in CFML so efficiently, that the same application written by you alone would probably need a team with Java, Ruby, etc. This is a proven fact.
  • Well designed. The CFML language is well designed and many required functions already exists for you to use. There is no need to write a wrapper for a email sending function. I mean, you don’t even need a framework, to achieve a simple tag like “<cfmail…>”. There is no obnoxious, framework to learn or write functions for this. Compare this to Java, PHP, Ruby, etc. you are very well off with CFML. (again all without a framework)
  • Build web applications fast. Due to the nature of writing less code with CFML and with the built in function, you will be writing your next web application in weeks, instead of months. On top of that, you will have a full scalable enterprise model on your hand to scale when your startup takes off. Heard about the stories of PHP web apps, that had to be converted to xyz language just to scope with the traffic. Again, if you would deploy your web application with CFML and OpenBD, you can deploy on any Java application server (Tomcat, JBoss, Websphere, etc.), connect to any database (MongoDB, H2, Oracle, MySQL, MS SQL, DB2, you name it…) and have your cluster, load balancing, caching setup done.

If you are in for writing less code and building your next web application the fast way, then I simply urge you to give CFML a try. I’m certain that you will get your project done in half the time then in another language. There is simply nothing to loose for you!

 

How to search & replace in MySQL

Thinking of a way to quickly search & replace data in a MySQL column got me to this solution:

update table
set 
column = replace(column,'thistext','thattext')

With this method I was quickly able to change millions of records today. Quick and easy.

svn: warning: cannot set LC_CTYPE locale

Somehow with the recent Ubuntu 10.04 LTS updates or maybe with a subversion update, I received some errors message of the type “locale…”. To be more precise the errors are;

svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LC_CTYPE is UTF-8
svn: warning: please check that your locale name is correct

While all SVN commands still worked, it was something I didn’t tackle with immediately. But today, I set out to fix it. Well, it only took a minute or so :)

So, if you want to fix this all you have to do is to set the “LC_ALL” variable manually. To make it permanent just edit the file “/etc/environment” and add the line:

LC_ALL=C

Save the file and exit the editor. In order for it to apply you have to logout of the current shell session. The next time you log in, the issue with SVN will be gone.

 

Fix for running MySQL 5.5.8 under MacOS X 10.6.5 (Snow Leopard)

Oracle recently released the latest MySQL 5.5.x versions. Despite of having tones of fixes and supposedly running much faster and (finally) making InnoDB the default storage engine, it is always good to keep up to date with latest releases.

But, as in the past, MaxOS X users always have to battle with getting it run correctly on their platform of choice. With this release it is no difference. This time, we are hit by permission issues and wrong path settings that prohibits MySQL to start at all and also to make it automatically startup during boot time.

Fixing startup

After installing the preference pane, you should be able to simply click the button to start/stop the MySQL server. Point is that “it should”, but it wont. This is due to a wrong path setting in the startup file. In order to make it work you have to edit a file. Jump into your favorites tool (no, it is not iTunes), but the Terminal application and enter:

nano /usr/local/mysql/support-files/mysql.server

(Nano is a editor in your shell, you can also use “vi” or “emacs”, but I guess “nano” is easy to use)

Then hit “ctrl + W” (for search) and enter “basedir=”, then hit Enter”. This will search for the string entered. Once found, change it to:

basedir=/usr/local/mysql

Once changed, hit “ctrl + W” again and search for “mysqld_pid_file_path=$datadir/`hostname`.pid” and change it to:

mysqld_pid_file_path=$datadir/`/bin/hostname`.pid

After these two changes simply press “ctrl + X” and enter “y” and then enter. This will save the changes you just made and will close the editor.

Fixing Startupitem

During reboot you might have seen the error message:

“Insecure Startup Item disabled. /Library/StartupItems/MySQLCOM has not been started because it does not have the proper security settings.”

This is because the StartUpItem has been installed with the improper permission settings. This can simply be solved with the following commands you have to enter in the terminal:

chown -R root:wheel /Library/StartupItems/MySQLCOM

That’s it. After next reboot the MySQL server will startup as expected and you will also be able to start/stop the server from the preference panel.

Fun with Cron

For some of my Ubuntu Servers (10.04) the Cron jobs did not work or only sporadically executed. I’ve asked around, but none of my friends could explain why this is so. This happened on physical as also on virtual servers. Thus I set out today to finally figure out what caused this. To mention it upfront, I did not find the cause of it, but I got my Cron jobs working again. (and learned a lot along the way)

System Crontab and User Crontab

In the past I always set cron jobs in the /etc/crontab file. This is also the way I’ve used cron in the last couple of years. By switching to Ubuntu server 9.x this worked, but somehow since 10.04 they only worked sporadically. As explained, I don’t know why this is so, but moving those cron jobs into the user (in my case the root account) with “crontab -e” they started working again.

The only difference is that one does not need to pass the user the jobs has to run in with the command, since we edit the user crontab file with “crontab -e”, but everyting else works now as expected.

Getting cron to log

Under Ubuntu logging of any cron action is disabled by default. Since, I wanted to see if my jobs are running and execute successfully I had to enable it. Enabling logging of cron is done in the system default files with:

vim /etc/rsyslog.d/50-default.conf

Uncommenting the ‘#’ before the line that says cron and it will enable logging for cron:

cron.* /var/log/cron.log

and save the file. Now simply reload or restart the rsyslog utility with:

service rsyslog restart

Note: In my case, I had to create the file “/var/log/cron.log” manually in order for cron to write the log.

Enable or preventing cron to send eMails

I guess by default, cron will send eMails on errors or completed actions to the user. In my case, I got a lof of eMails with completed actions and more from cron shortly after. Controlling sending of eMails is done by the global variable ” MAILTO=”" “. One can also direct the output to null for disabling sending of emails.

To disable cron from sending for all jobs:

Add MAILTO=”" to the top of cour crontab file.

To disable sending of eMails for individual jobs:

0 1 5 10 * /path/to/script.sh &> /dev/null

Ubuntu 10.10 and grub menu

I just upgraded one my Ubuntu server from 10.04 to 10.10 (works flawlessly) and realized that I was prompted with the grub menu during a reboot. Since this is a cloud server and it being managed over SSH, I surely wanted that Grub automatically selects the latest kernel and does not wait for an input.

To be honest, I don’t know why this changed (well the only grief with the move from 10.04 to 10.10). Luckily, this is a easy task. All there is to do is to change a value in one of the grub conf files. Edit the file “/etc/grub.d/00_header” and search for “recordfail”. This should bring you to the line;

if [ \${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=${GRUB_TIMEOUT}
fi

Now, all there is to change is the value “-1″. The value 0 will bypass the menu and any greater value is the time of countdown after a unsuccessful boot. (I changed it to 3).

After you saved the change you need to run “sudo update-grub2″ to apply the change. If all goes well, you should boot directly with the configured kernel during next reboot.

SugarCRM: Inbound eMail

SugarCRM is a good open source CRM, but the overwhelming functions and navigation makes it “sometimes” hard to really get to the one thing you want to do. In any case, it does the job well. Apart from that, I just came upon this error message within SugarCRM:

Warnings: Inbound Email cannot function without the IMAP c-client libraries enabled/compiled with the PHP module. Please contact your administrator to resolve this issue.

This definitely means that PHP is missing some mail libraries, but the message to compile PHP is kinda scary, isn’t it? Luckily, if you are using Ubuntu all you need to do is to issue an “apt-get” command and you are rolling. So here we go:

apt-get install php5-imap

This will install everything for you, make sure to restart PHP (restart Apache or the FastCGI).

Subversion: Switch to a new location

We just moved some of our subversion repositories to a new server and with it changed the URL’s. Now, in order to change any existing checkout version to grab updates from the new subversion server we issued the simple “switch” command from subversion as in:

svn sw svn://svn.domain.com/trunk .

The problem with this was that the system complained with:

svn: 'svn://svn.domain.com/trunk'
is not the same repository as
'svn://svn.newdomain.com/trunk'

The correct syntax to relocate any existing checkout copy is to use the “–relocate” switch as in:

svn sw --relocate svn://svn.domain.com/trunk svn://svn.newdomain.com/trunk 

And we are back in business…

Setting the correct Java version under MacOS X

My favorite scripting language is CFML, or as some know it as ColdFusion. I like it because it is very very powerful, easy to use and can do just about everything your xyz language can do.

For many years, ColdFusion was a closed sourced system, where the former Macromedia and now Adobe got the copyright of the code. Luckily, this has changed when OpenBlueDragon (OpenBD) came to play with the first open source CFML application server. So, now the CFML world got a very nice open source CFML language and server. Our very own open source Digital Asset Management – Razuna – runs on OpenBD as well and comes bundled with it.

Anyhow, the reason of this blog post is not CFML, but how to set the correct Java JRE environment under MacOS X. Then why did I mention CFML and OpenBD in the first place, you might ask?

Well, today I downloaded the latest version of OpenBD which runs now on Java 1.6 and is 64 bit. But when I tried to start our server (Tomcat) with the new OpenBD jar I got the following error messages in the log.

at org.apache.catalina.startup.
Bootstrap.main(Bootstrap.java:413) Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.naryx.tagfusion.cfm.application.cfHttpSessionListener)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal (WebappClassLoader.java:1854)

As we can see from the “Bad version number…” in the above line there must be some misconfiguration of the Java runtime going on. But wait, does my execution of “java -version” not state that I’m running the latest Java version? Reading from those lines, you could think so.

java version “1.6.0_13″
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)

Apparently when one looks into the Java paths of MacOS X we see that the current “JDK” is set to 1.5 and not 1.6. Judging from this, I tend to think that Apple is not setting the JDK right for Java applications. You might say, well then just set it in the “Java Preferences”, right? Wrong, I already did that as the screen below shows).

Java Preferences

So, in order to solve this, I set the correct JRE_HOME variable in my .profile in order for all Java applications to pick up the current JRE. To do that, you simple edit your .profile (with vi ~/.profile) and add the following lines to it:

JRE_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
export JRE_HOME

Save it, open a new terminal window (or close and open one) and start Tomcat. Now Tomcat is picking up the new JRE path and Java application, in my case OpenBD, that depend on the Java 1.6 JRE version will run.

OpenBD, Open Source CFML server, gets some praise from the community

Among other things, I am one of the members of the OpenBD Steering Committee. OpenBD is the first Open Source ColdFusion Application Server and has a long history of the product itself and the members of it.

But somehow, when the company behind the commercial BlueDragon product decided to open source their J2EE BlueDragon product, something strange happened. Instead of cheering to have (finally) a open source CFML server, the CFML community seamed to dislike it. The reason for this, lies beyond me and does not make any sense. Fortunately, people change!

Today Joe Rinehart, a prominent figure in the CFML community, posted some very nice comments on his blog about OpenBD. The blog title is OpenBD: I’m sorry, it’s actually nice!. Here is a quote from it:

…OpenBD started up, and immediately told me that there was an exception that was entirely my fault.  And the exception information…wow.  Anything and everything:  lines of code causing the problems, the files they were in, all of the scope variables, introspection of the CFCs that were involved, and it was all logged out to an HTML file.  Good job, OpenBD team!  This kind of raising the bar in respect to competitive products is what it’s all about!…

I want to thank Joe for giving the OpenBD product another chance and leaving all the bad vibes behind it. If you too, want to move to a pure open source stack then give OpenBD a chance today.

In case you don’t know, but Razuna, our open source Digital Asset Management, is also based on OpenBD. You can download the complete Open Source DAM offering over at the Razuna website.