Posts Tagged ‘java’

Tomcat query parameters and encodings

Did you ever wondered which from which encoding the query parameters are parsed by default in java (servlet) and the response in rendered? Say UTF-8. Wrong. Try ISO-8859-1. There are 3 cases to consider:

1. Query parameters as GET

2. Query parameters as POST

3. Response encoding. (more…)

JBoss migration 4.2.2-GA to 5.1.0-GA

In my stupidity innocence I just hoped that deploying the application on the new JBoss (from 4.2.2-GA to 5.1.0-GA) should be just a simple matter of changing paths in ant. Here are some problems I encountered and was able to fix. (more…)

JBoss and LDAP

Target: create a test environment for JBoss JAAS authentication using LDAP.

Platform: Linux Ubuntu 9.10, JBoss 4.2.2.GA, java 1.6.0_15

Install and configure openldap

Installing ldap proved to be the most complicated part as apparently Karmic stripped all ldap configuration from the install so all tutorials found on ubuntu site are useless. Finally I’ve found a thread which described the process. Here are the steps I followed: (more…)

Eclipse crashes in Ubuntu Karmic

Trying to run Apache Directory Studio I’ve found that eclupse crashes in ubuntu karmic 9.10 with the following error:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0x00d64856, pid=8870, tid=3077867296
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
# Problematic frame:
# C  [libpango-1.0.so.0+0x23856]  pango_layout_new+0x36
#

I’ve tried running it with different java version and with the GDK_NATIVE_WINDOWS=1 with no luck and found the problem unanswered on lot of sites. Finally the solution required to disable the Assistive Technologies (System -> Preferences -> Assistive Technologies). After that everything works ok.

Hibernate localized data

Here are some reflections and solutions on how to localize strings in hibernate objects.

The model

I am assuming the localized strings will be stored in the database in a structure similar to:

Table MY_OBJECT:

  • LOCALIZED_FIELD

Table LOCALIZED_DATA:

  • CATEGORY (object type)
  • LOCALE
  • LOCALIZED_FK (stores the id of the localized object but without foreign key restrictions)
  • FIELD (field of the object)
  • DATA (the actual localization)

(more…)

Tapestry, hibernate application (no.5)

A few years ago I was writting some simple tutorials about using hibernate with tapestry to build a simple application. I’ve used Tapestry 3, 4 and I found it reliable to build applications which are still in production. I could consider myself a Tapestry fan and as such I am disappointed a bit to write this article since I was expecting to find no need for it. My goal was to build a simple example of Tapestry – Hibernate application using Tapestry 5. (more…)

A bit of hibernate optimization

The context

Assume you are dealing with a hibernate operation which requires to copy a lot of objects in the database. For instance you are having 2 objects as described in the diagram bellow: budget and entries and you want to duplicate the budget and all it’s entries for some operation. There are several way to do this.

Budget - entries

Budget - entries

First approach

In hibernate usual approach this is done most of the time as something similar to: (more…)

The conflicting ssleay32 and libeay32

Since everybody seemed to be stuck with using the library on windows and yet on linux it worked from the start I’ve decided to dive into the wonderful world of windoze. (more…)

Remote java debug

This is something which should be know be every java developer: how to enable remote debugging of your java application. The solution is remarcable simple:

export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

and the start your application normally. You can use your IDE of choice for the debugging. Here is a screenshot of the eclipse configuration:

Remote java debug

Remote java debug

Locale files

When using flex and java in parallel the localization mechanism might be clear. One aspect which is not clear is the encoding of the properties files:

  • Flex locale files encoding: UTF-8
  • Java locale files encoding: ISO-8859-1

Convertor script:

..$ cat fixUTF.sh #!/bin/bash

TMP=iconv.tmp

if [ "!$2" == "!rev" ]; then	iconv -t ISO_8859-1 -f UTF-8 -o $TMP $1else	iconv -f ISO_8859-1 -t UTF-8 -o $TMP $1fimv $TMP $1
Related Posts with Thumbnails