Posts Tagged ‘J2EE’

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.

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>

<a href="${largeImage}" rel="lightbox">
 <img src="${smallImage}" align="left" border="0" />
</a>

(more…)

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 about hibernate cache

One of the common mistakes when using hibernate is to think: “no problem, hibernate handles the cache for me”. Wrong! By default hibernate does not cache anything. Well, as far as I understand it cache things in the session cache, but this is usually not relevant. First here is what cache refers to in hibernate:

  • session cache, enabled by default, but with a lifetime equals to the session
  • second-level cache, controlled by: hibernate.cache.use_second_level_cache, which stores objects by id
  • query-cache, controlled by: hibernate.cache.use_query_cache ,which stores query results

However, enabling these properties does not has any effect on the application usage of a cache.

(more…)

unsupported keyword OID.2.5.4.17

The problem

Exception in thread "main" java.io.IOException: unsupported keyword OID.2.5.4.17
        at com.sun.net.ssl.internal.ssl.AVA.<init>(DashoA12275(Compiled Code))
        at com.sun.net.ssl.internal.ssl.RDN.<init>(DashoA12275(Compiled Code))
        at com.sun.net.ssl.internal.ssl.X500Name.a(DashoA12275(Compiled Code))
        at com.sun.net.ssl.internal.ssl.X500Name.<init>(DashoA12275)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect(DashoA12275)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInputStream(DashoA12275)

What’s your fault when a client running your application for more than 5 years is now receiving this error when its security provider finally upgraded it’s certificates to include: OID.2.5.4.17=<9 digit zip> now standard in almost all certificates.

Upgrade you might say but this is not simple considering that the client is AIX based:

java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1)
Classic VM (build 1.3.1, J2RE 1.3.1 IBM AIX build ca131-20030630a (JIT enabled: jitc))

Solution?

  • upgrade JSSE. No. JSSE is in EOL for some time now.
  • try to use the JSSE from 1.4.2. No, this version is not pluggable.
  • upgrade to java 1.4.2 which is not an easy task in these conditions
  • you soon realize that the IBM java has a special implementation of JSSE found in the ibmjsse.jar file so the code written in java 1.3 for the jsse plugable module is not working with the ibmjsse implementation with error:
Classe java introuvable :  com/sun/net/ssl/internal/ssl/Provider
  • finally the solution is to remove from your code the following part:
 Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
 System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
  • it only remains the problem to compile 5 years old code :)

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…)

Related Posts with Thumbnails