Enable ehcache debug in jboss

I’ve been trying to setup ehcache clustering in JBoss and unless there is a problem I’ve noticed there is little logging involved. So enabling logging should be a straightforward operation, I said. And it sure is if you bother to consider that the default ehcache distribution uses slf4j which is packed only with the jdk logger. So by default no matter how much you configure log4j no logging will be done....

November 9, 2011 · len

Call Oracle procedure from hibernate

After debuging for a few hours I’ve found the proper way of calling an Oracle function from hibernate and to use the return parameters. Here is the solution. The Oracle SQL function which returns -1 or 0: <pre lang="sql">create or replace function checkLastNPass (userId IN number, ... other params) RETURN SYS_REFCURSOR is st_cursor SYS_REFCURSOR; prevId number:= userId; ... other scope variables begin ... OPEN st_cursor FOR select -1 as retVal from DUAL; return st_cursor; ....

October 17, 2011 · len

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

Integrating Lightbox into Tapestry 5

This show a basic way of using Lightbox 2.03 (wiki) into Tapestry 5. First step Just copy the css, images and js/lightbox.js into the web directory. Note: the scriptaculous.js, effects.js and prototype.js are not required as they are already included in T5. Modify the .tml file <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My app</title> <link rel="stylesheet" href="${context:css/style.css}" type="text/css" media="screen" /> <script type="text/javascript" src="${context:js/lightbox.js}"></script> <link rel="stylesheet" href="${context:css/lightbox.css}" type="text/css" media="screen" /> </head> …...

August 18, 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