woensdag 17 oktober 2007

Java Pair

Sometimes during the design of an interface I want to return two objects instead of one for a certain method. Yes, this might be bad practice. But sometimes I just need it. In good old c++ with stl, there was a solution for this by using pairs. In java, there's no such thing as pairs and a Map is too bulky. So here's the Java 5 Pair implementation:

public final class Pair {
public final A first;
public final B second;

public Pair(A first, B second) {
this.first = first;
this.second = second;

public A getFirst() {
return first;

public B getSecond() {
return second;

dinsdag 16 oktober 2007

Sun Application Server as a server

The following page http://docs.sun.com/source/819-0076/auto-restart.html#wp1027849 gives information about how to startup the sun application server as a windows service.

woensdag 10 oktober 2007

Spring and Sun Application server 8.2

I'm currently working on a project that must run on a Sun Application Server version 8.2. While setting up the webflow and template jsp pages I got the following exception:

java.lang.IllegalStateException: Unexpected reflection exception - java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
at org.springframework.util.ReflectionUtils.handleReflectionException(ReflectionUtils.java:136)
at org.springframework.core.ReflectiveVisitorHelper.invokeVisit(ReflectiveVisitorHelper.java:100)
at org.springframework.core.style.DefaultValueStyler.style(DefaultValueStyler.java:56)
at org.springframework.core.style.StylerUtils.style(StylerUtils.java:47)
at org.springframework.webflow.engine.TransitionableState.getRequiredTransition(TransitionableState.java:80)
at org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
at org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)

! So, I tested the same ear on a JBoss instance, and that worked without a problem. After doing some research I figured out that the sun application server is starting up with the following system property:


And yes, that is causing the AccessControlException, because the spring framework isn't allowed to do reflection. So how can we solve this?

Solution one: In the domain.xml file put the following line in comments

Solution two: Start editing the server.policy file for the domain. This is the most secure solution, but as solution one is much easier, I would pick that one. Also because the customer will be responsible for his own server in production.

dinsdag 9 oktober 2007

Sun Application Server 8.2 on ubuntu

By default it's not possible to install the sun application server version 8.2 on ubuntu or debian. I always got the following error:

./sjsas_pe-8_2-linux.bin: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

But the following link gave me the solution: http://www.javafree.org/javabb/viewtopic.jbb?t=853068


- Install the package "libstdc++2.10-glibc2.2". This package is by default available in the sources, so you can use synaptic or any other package manager
- Download the sun application server from: http://java.sun.com/j2ee/1.4/download.html
- chmod u+x sjsas_pe-8_2-linux.bin
- ./sjsas_pe-8_2-linux.bin
- Follow the on screen instructions.