Hibernate JbossCache integration

Introduction JbossCache is a wonderfully complex piece of software. Trying to use it with Hibernate might seem an easy task at first but in reality it can also prove wonderfully complicated. First question is: why would you consider using it in the first place? Compared to ehcache for instance there are a few theoretical advantages: clustering (scalability), configurability and jmx monitoring. Next question which is not quite obvious is which version to use?...

September 20, 2010 · len

JBoss session cookies

If you are using cookies for inter-context communication you will notice after migrating from JBoss 4 to 5 that they just don’t work. If you take the time to do some cookie debuging you will notice that in JBoss 5 the cookies are bound to the context as shown bellow: Name JSESSIONID Value ACF23793236E94A664E652AA77AC7578 Host localhost Path /myApp/ Secure No Expires At End Of Session This means there is no way this cookie can be used to comunicate with /myApp2/ for instance....

September 14, 2010 · len

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. In order to solve 1 and 2 one solution is just to convert the parameters to UTF-8: String param = request.getParameter("test"); if(param != null) param = new String(param....

April 8, 2010 · len

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. application.xml The format of this file has changed from: <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> <display-name>My application</display-name> <description>My server interface</description> ... to <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java....

February 3, 2010 · len

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: apt-get remove --purge slapd ldap-utils #remove all my tests apt-get install slapd ldap-utils #install fresh ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine....

December 3, 2009 · len

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....

November 26, 2009 · len

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) First ideea (bad) Create a bag of composite elements with the actual localizations:...

June 18, 2009 · len

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....

June 14, 2009 · len

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 First approach In hibernate usual approach this is done most of the time as something similar to:...

February 10, 2009 · len

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. The problem: while trying to use a java, jni-based library the error was unavoidable: java.lang.UnsatisfiedLinkError: C:\sw_api\sw_api\windows\sw_api.dll: The operating system cannot run %1 at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) As such I decided to wrote this simple program:...

February 3, 2009 · len