30.12.06

Windows Live Blog Client

Blogger.com got upgraded and my blogger client w.Bloggar refused to work properly with the new beta.blogger.com. Althought the newly announced beta -> production change, w.Bloggar didn't still work.

I started looking at alternatives and found Microsoft Windows Live Blog Client that seems to work nicely with the new Blogger.com.

As the new year 2007 is arriving I wish you all:

29.10.06

Configuring Jetty 6 to work with Oracle DB

I had the need to print out certain things from my OracleXE database + setup a Web Services engine. My Linux box was running only on 256MB of RAM so I needed a small servlet engine to acts as application server for my JSP application. There were two main options I considered:

  1. Tomcat

  2. Jetty



Tomcat



Started with Tomcat 5.5. Installed Tomcat. Installed Axis 1.4. For Axis I needed to manually install bunch of missing JARs. Tried a simple JSP page with JSLT and SQL tags to dig out information from OracleXE. Just to get into phase where I didn't get any missing class exceptions took me a while. I had to manually install mail.jar, activation.jar, xmlsec.jar etc. In the end of stripping out the exceptions I finally could connect the OracleXE database but the only problem was that none of the results were not displayed in the actual JSP result HTML (despite the connection to the database was working). Weird... I used quite a bit of time searching internet for answer how to get this working.

It was time to throw the towel to the ring. Farewell Tomcat.

Jetty



Downloaded Jetty 6.0.1. Installed it. Installed Axis 1.4. Axis installation was a nice surprise, almost all the needed libraries were already there for Axis 1.4. I only needed to add xmlsec jar file and Axis was happy. Axis installation was much more fluent in Jetty than in Tomcat. Tried my test JSP to connect OracleXE. There I faced some challeges but got over them very fast and was up and running with working JSP, using JSLT + SQL tags printing results out of my Oracle database.

Jetty was a pleasant surprise to me. For those folks that needs sample application that works with Oracle database using data sources, here are the steps to do it:

1. Create directory webapps-plus under $JETTY_HOME if that directory doesn't exists.
Jetty 6.0.1 is configured out-of-the-box with JNDI support if you deploy your application under webapps-plus directory. Also in order to get the JNDI support you need to start the Jetty engine with following parameters:

java -jar start.jar etc/jetty.xml etc/jetty-plus.xml



2. Create a sample application subdirectory $JETTY_HOME/webapps-plus/mysample.
3. Copy WEB-INF from $JETTY_HOME/webapps/test to $JETTY_HOME/webapps-plus/mysample
4. Copy Oracle JDBC driver to $JETTY_HOME/webapps-plus/mysample/WEB-INF/lib. I use ojdbc14.jar.
5. Edit the jetty-web.xml in $JETTY_HOME/webapps-plus/mysample/WEB-INF

You can configure the Oracle datasource in this config file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://j
etty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">

<Call class="org.mortbay.log.Log" name="debug">
<Arg>executing jetty-web.xml</Arg>
</Call>

<!-- Add a DataSource only valid for this webapp -->
<New id="oraclexe" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/oraclexe</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleDataSource">
<Set name="user">scott</Set>
<Set name="password">tiger</Set>
<Set name="URL">jdbc:oracle:thin:@myhostname.com:1521:XE</Set>
</New>
</Arg>
</New>
</Configure>


6. Create a sample JSP file that reports data from Oracle database using the data source defined in jetty-web.xml:

Here is the sample JSP with SQL tags:

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
<title>Oracle DB Test</title>
</head>
<body>

<h2>Results</h2>
<sql:query dataSource="jdbc/oraclexe" var="rs">
SELECT * FROM dual
</sql:query>

<c:choose>
<c:when test="${rs.rowCount == 0}">
Sorry, no messages found.
</c:when>
<c:when test="${rs.rowCount == null}">
Sorry, no messages found (null).
</c:when>
<c:otherwise>
Messages found (${rs.rowCount})
</c:otherwise>
</c:choose>

<c:forEach var="row" items="${rs.rows}">
Dummy ${row.dummy}<br/>
</c:forEach>

</body>
</html>


7. Bounce jetty to get all the changes in effect.

If everythings went well, you should be having a working connection to Oracle database printing out something like:
Results
Messages found (1) Dummy X

18.8.06

Disabling Gnome/KDE in RedHat startup

Here is something that I consider FAQ but never remember how to do it after installing RedHat Linux.
How to disable graphical desktop in server startup? This is to conserve system resourses when server is used only remotely e.g. SSH.

su -
vi /etc/inittab

Look for a line like this: id:5:initdefault:

This line specifies default runlevel on boot.
Default runlevel. The runlevels used by RHS are:
0 - halt (Do NOT set initdefault to this)
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot (Do NOT set initdefault to this)

Change the 5 in the quote above to a 3. Save and reboot.

27.3.06

HAM

BAM (Business Activity Monitoring) is cool new technology for business monitoring.
There are products like Oracle BAM

Home Activity Monitoring (HAM?) is a word I could describe following ultra COOL Dutch site: http://www.bwired.nl/
.

Amazing !! :)

22.2.06

OC4J (9.0.4, 10.1.2 and 10.1.3) log file rotation

For those that want to rotate the OC4J log files under $ORACLE_HOME/opmn/logs, there are new parameters not documented in 9.0.4/10.1.2 documentation:

[New JVM parameters]
"stdstream.filesize"
Max file size limit of each archive. Unit is megabyte.
"stdstream.filenumber"
Max number of files that oc4j can keep as archives. The oldest file
will be automatically deleted if the limit is exceeded.
"stdstream.rotatetime"
Time when the log file is rotated. Format is "HH:mm". The archive
will be rotated at the specified time everyday.

[Usage]
ex 1: rotate stdout/stderr when the file size is reached to 2.5M byte.
java -Dstdstream.filesize=2.5 -jar oc4j.jar -out std.out -err std.err
ex 2: rotate stdout at 13:30 everyday
java -Dstdstream.rotatetime=13:30 -jar oc4j.jar -out std.out
ex 3: rotate stdout at 13:30 everyday and keep 10 files as archive
java -Dstdstream.rotatetime=13:30 -Dstdstream.filenumber=10 -jar oc4j.jar -out std.out

The generated log file would look like <filename w/o extension>_yyyy_MM_dd_HH_mm_ss.<extension>
e.g. std_2004_07_08_13_24_53.out

[Note]
1. The same parameter are used for both "-out" and "-err".
2. In AS mode, the log files will be created under <island name and process id> directory
(this isn't changed by this fix, existing code handles this)
3. Both "filesize" and "rotatetime" parameters can be used at the same time.

opmn.xml
In order to get these parameters in opmn.xml you need to define it as follows:
...
<category id="start-parameters">
<data id="java-options" value="-server -Djava.security.policy=$ORACLE_HOME/j2ee/home/config/java2.policy -Djava.awt.headless=true -Dstdstream.filesize=0.2 -Dstdstream.filenumber=5"/>
<data id="oc4j-options" value="-out std.out -err std.err"/>
</category>
...

You will find the new log files under:$ORACLE_HOME/j2ee/home/home_default_island_1

The file naming will be like:
std_2006_02_22_14_01_17.out
std_2006_02_22_14_16_25.out

15.1.06

HTML DB Region Title Dynamic Translation

I've been working at home to build our family web site using OracleXE and HTML DB (2.1). One of the targets for the new design is to support multiple languages dynamically so that whenever user has either English, Finnish or Swedish browser preference the web site should display using that language.


HTML DB has translation capabilities built-in but the functionality wasn't exactly what I was looking for. I wanted the same HTML DB application to support all above languages, not to have multiple languages and multiple applications.


Everything else was doable, I created dynamic content relational tables and the content of the web pages is retrieved from the database using the language preferred.


One problem are was region titles, which doesn't support translatability within the same application out of the box. I am able to print out the region title using application level attributes, so called substitution variables. This is half way what I wanted but there is no language perspective to this. I want to print out the welcome region box title as "Welcome", "Tervetuloa", "Välkommen" dependent on the browser language.


I finally discovered a way to do this. First of all I have to use javascript to do this. Secondly I thought I could use the "navigator.language" variable from the client browser to discover the preferred language of the browser, but this didn't work exactly as I thought. Namely this variable prints out the installed browser language, not the preferred language that user has selected from the browser preferences.


The workaround to discover how to get the "HTTP_ACCEPT_LANGUAGE" -setting took awhile. Finally I got a working Javascript snippet that did the trick with HTML DB:
<script type="text/javascript">var language = '&BROWSER_LANGUAGE.';
if (language.indexOf('fi') > -1) document.write("Tervetuloa");
else if (language.indexOf('sv') > -1) document.write("Välkommen");
else document.write("Welcome")</script>



So the key is to use the &BROWSER_LANGUAGE. -substitution variable to find out the preferred browser language to get the right result.