Wednesday, December 19, 2007

Oracle, modPerl, and french accents

Since moving from one Linux server to another, our modPerl application had a hard time saving accented characters from the french language (éàè etc...). The characters were saved in the database as upside-down question marks, or at least that's how my TOAD installation displayed them.

It was determined that in order to overcome this problem, we needed to set the NLS_LANG environment variable to the value 'AMERICAN_AMERICA.WE8ISO8859P1'.

But setting that variable in the Apache user's profile doesn't work, nor does setting it through httpd.conf's PerlSetEnv statement.

We had to set it in a Perl script that is loaded through the PerlRequire statement in httpd.conf (I called that script startup.pl). Not only that, it needed to be set in the BEGIN block of that script :

BEGIN {
$ENV{ORACLE_HOME} = '/u01/app/oracle/product/10.2.0/client_1/';
$ENV{NLS_LANG} = 'AMERICAN_AMERICA.WE8ISO8859P1';
}

This is documented elsewhere on the web, but it doesn't hurt to have it here :-)

Humbly...

Tuesday, December 18, 2007

Apache's AddDefaultCharset

Simple problem this morning, we switched servers for one of our Perl applications, and upon running it, we noticed that all accented characters were displayed as weird characters.

The page was coded as ISO-8859-1...

The problem was Apache's AddDefaultCharset which was set to UTF-8. I don't know if the httpd.conf had this setting originally, or if it's our admin that changed it, but sure enough putting it back to ISO-8859-1 fixed our problem.

I know, we'd be better off with UTF-8, but hey, as long as it works...

Humbly...

Friday, December 14, 2007

modPerl and Oracle...

Previously, we were using an older version of the Oracle client on a Linux machine.

We're now trying to recreate the server setup on a VMWare virtual machine that is using Oracle 10.2.0. This server has Apache running with modPerl connecting to Oracle.

The error message we were getting at first was "ERROR OCIEnvNlsCreate (check ORACLE_HOME, permissions, NLS settings etc." or something like that.

The first action that we took was to make the apache user a part of the oinstall group. This made the perl scripts work with Oracle, but not under modPerl.

In order to make script work under modPerl, we added a BEGIN {} group at the start of a startup file that was loaded by the httpd.conf file. Here's the instruction :

BEGIN {
$ENV{ORACLE_HOME} = ‘’;
}

That fixed the modPerl problem.

Tomcat and app-name.xml

I'll start with a stupid but frustrating problem I had this morning.

I have a Tomcat server set up on my machine as a development server, and we deploy tested code on a production server.

The application-name.xml file in the META-INF directory gets copied to the conf/catalina/localhost directory when a War file is deployed on a Tomcat server using Tomcat's HTML manager.

This morning, then, I had to change the connector description for an application because we were switching database servers. So, I changed the description in the META-INF directory, repackaged my War file, and deployed on my server. When I tested the application, data was saved to the original database, and not the new one.

For some reason, the xml file in conf/Catalina/localhost was not being replaced with the new one. I deleted it, re-deployed the War, and voilà, the new database was now active...

Stupid, but it made me waste time.

Very humbly,

Bercy

Should have started this years ago...

Hi,

I'm a web developer living in Canada, with roughly 12 years of full-time work experience as of 2007. I also started programming computers for fun when I was about 12 years old in the eighties...

Technologies that I've used include C, C++, Java, Fortran, Perl, modPerl, Tomcat, Apache, Oracle, mySql, Struts, Hibernate, Motif, Eclipse, ASP, IIS, and I'm sure I'm forgetting some. Recently, I've been mostly using Java with Oracle or mySql, and Tomcat / Apache.

My goal here is to very humbly show where I encounter problems when developing software. We all rely on Google to help us out in finding out solutions to our dev problems, and it usually works out not too bad. But, sometimes it's painstakingly hard to find a solution, and this is just my small contribution to the dev world, hoping that it'll help someone someday.