Wednesday, November 17, 2010

Railo - Java Timezone Issue

I reset the system time zone in Ubuntu and then restarted Railo, but railo didn't have the new timezone.

I didn't want to reboot the server, so I researched and scripted this work-around:

<cfset variables.tzobj = CreateObject("java", "java.util.TimeZone") />

<cfset loc.timeZone = variables.tzobj.getDefault()>
Before Reset: <cfoutput>#loc.timeZone#</cfoutput><br /><br />

<cfset variables.tzobj.setDefault("US/Pacific")>

<cfset loc.timeZone = variables.tzobj.getDefault()>
After Reset:<cfoutput>#loc.timeZone#</cfoutput>

I ran that one on the server and it's good to go forever. I'll reboot the server late tonight and confirm that java gets the correct system timezone, but this worked for an immediate solution without rebooting or restarting Railo.

UPDATE: The above resolved the java offset, but issues were discovered between Railo (java) and SQL Database dates. It was converting back and forth between UTC and PDT (Pacific Daylight Savings Time). It was a mess. In addition, upon reboot Java revered back to the incorrect timezone. I had to test a fresh reboot because it was bound to happen. Glad I did.

The final solution to fixing the Java incorrect timezone came from a forum thread which pointed me to this link:

From there I leaned that there is another timezone file in Ubuntu located /etc/timezone which has Etc/UTC inside. That's it.

Simply deleting the file, or renaming it to /etc/timezone_old, and then rebooting fixed the java timezone.

The Java timezone object above is not a good solution. As I stated, there remains timezone issues between Railo CFML (essentially the Java Engine) and any other systems, namely MySQL.

Many thanks to the communities and forums for posting solutions.


Railo - CFChart - SOLVED Error: Probable fatal error:No fonts found

I built a new production server and launched the new site this morning. Everything ran great, except...

On one report page that I did not test before launch there was a small chart in the corner of the report. A <cfchart...> which was throwing this error: Probable fatal error:No fonts found.

After a quick search I discovered this is a font issue with OpenJDK which most people resolved by uninstalling OpenJDK and installing Sun's JDK.

I didn't want to do that. So I kept searching.

This error has two issues: 1) The fonts are not installed.  And/Or,  2) OpenJDK doesn't know where to find the fonts.

Tackle issue number 1 - get the fonts. This is a new server and trying to locate any of the fonts that others were installing came up blank.

sudo apt-get install libfreetype6 and restarting railo - didn't fix it anything.

sudo apt-get install dejavu* and restarting railo - didn't fix it.

I know those two commands installed a bunch of fonts, so I'm closer.

I kept researching and found these two articles which explained a lot more:

From the second link there I found the instructions to run a java command to register installed fonts in the java font properties.

sudo java -jar compilefontconfig.jar fontconfig.config fontconfig.bfc
but that command complained that it couldn't find fontconfig.config.

locate fontconfig.config showed it to be in /etc/java-6-openjdk/

I'm in /usr/lib/jvm/java-6-openjdk/jre/lib and the other file fontconfig.bfc is here, so I tried:

sudo java -jar compilefontconfig.jar /etc/java-6-openjdk/ fontconfig.bfc

And that ran properly. No output, but no complaints.

Then I restarted railo and... IT WORKED! The CFChart displayed perfectly.

And that's a wrap!

Thursday, November 4, 2010

Railo and JAVA_HOME issues (exec: 40: -jar: not found)

I have read others getting the "exec: 40: -jar: not found" error even after having the JAVA_HOME variable set, but I have not experienced that issue until today.

To resolve this issue I discovered that manually setting JAVA_EXE along with JAVA_HOME in the ~/.bashrc file fixes the issue.

Like this:  (for my java installation on Ubuntu, yours may be different)

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_EXE=$JAVA_HOME/bin/java

That's it. Then Railo worked like a charm.

Another wrap!

Wednesday, November 3, 2010

Making Apache talk to Railo

Follow these steps to make Apache talk to Railo [ubuntu]:

sudo -s  ## do everything as root
cd /opt
wget [stable railo ALL-OS WITHOUT JRE from]
tar -zxvf railo-...-without-jre.tar.gz -C .   ## to unpack into the current directory
ln -s railo-..-resin-without-jre railo
/opt/railo/bin/ start  ## to make sure it starts - leave it running
apt-get install apache2 apache2-threaded-dev openjdk-6-jre-headless build-essential automake  ## make sure all of these are installed
vim ~/.bashrc
add this to the bottom and save:  export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
. ~/,bashrc
that re-initialized the bash settings, do this to confirm:
cd /opt/railo/modules/c/src   ##certain directory names are expected here, make sym links to resolve this
ln -s apache2 resin
ln -s resin resinssl
cd /opt/railo
./configure --with-apxs=/usr/bin/apxs2
autoconfig  ## mine errored on make and asked me to run this first then make again
make install

Then in /etc/apache2/httpd.conf  comment out ALL of the caucho lines that were installed there
and place it inside the sites-available config file after the names and directories, before the log files:

LoadModule caucho_module /usr/lib/apache2/modules/
localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes

That's it. It's worked a number of times in a row for me on Ubuntu.