mvn 3.0.3 + java 7 Datasource fail

11 11 2011

Okay just wanted to mention that if you’ve done a custom Datasource for java 6 and try to compile it with java 7 on maven using backwards compability you get this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on pr
oject wallboard-cisco-drivers: Compilation failure
[ERROR] \nino\develop\eclipseworkspace\projects\internalcomponents\Applications\wallboard\trunk\wallboard-cisco-dri
vers\src\main\java\com\netdesign\dao\cisco\general\[149,43] error: is not abstract and does not override abstract method getParentLogger() in
[ERROR] -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :wallboard-cisco-drivers

Please notice that i’ve specified this in my pom:


Only solution are to grab an old jdk 6 and compile it with that.. I was using jdk 1.7.0.

Feel free to correct me if im wrong somehow.

Guice and JDBC #2

4 11 2011

So a little while ago, I wrote about jdbc and guice.. I’ve been using mybatis since then.. And it just came to me yesterday “with mybatis you can do simple jdbc with guice”. Something similar to Spring JDBC templates.

So heres how (integer select), using annotation approach in something called a mapper class.

@Select(value = "select ${sql}")
public Integer updateCustomerEntrance(@Param("sql") String sql);

Thats it the only stuff you need to ensure are that your select will return an integer, and thats it. Mybatis will manage connection pool, connection etc for you.

It’s probably also possible for you to just return a object.. you’ll need at least 3 methods one for each type of sql, select update and delete.

However this approach are not at all utilizing mybatis’s power and are prone to SQL injection.. But it will do the job, and you can then go ahead an convert your legacy code slowly to use mybatis’s full potential.

Heres howto setup guice using it:

Connecting to db_cra uccx 8

3 06 2010

So im trying to connect to db_cra on a uccx 8, and it turned out to be a litte harder than expectet. In the cisco documentation the Informix database should be called something like hostname_uccx. In our case our servers are named SERVERNAME-number so the informix name should be SERVERNAME-number_uccx, thats not the case.

Heres the recipe:

Find the real name of the informix server: run this on your uccx CLI:

file dump inactivelog /uccx/log/db/uccx_repl_output_util.log

Go to the last page using SPACE and look for something like this:

2010-05-14 22:00:23,242 - uccxdb.util - DEBUG - getservers processing
2010-05-14 22:00:23,244 - uccxdb.util - DEBUG - getservers: processing line g_poc5_uccx8_uccx group           -               -               i=1
2010-05-14 22:00:23,244 - uccxdb.util - DEBUG - getservers: processing line poc5_uccx8_uccx onsoctcp POC5-UCCX8 poc5_uccx8_uccx g=g_poc5_uccx8_uccx b=32767
2010-05-14 22:00:23,245 - uccxdb.util - DEBUG - The servers are [['poc5_uccx8_uccx'], ['g_poc5_uccx8_uccx']]
2010-05-14 22:00:23,453 - uccxdb.util - DEBUG - Setting property to CTI-JTAPI on poc5_uccx8_uccx

And that’s it. So in our case our server got lower cased and underscored, “poc5_uccx8_uccx”.

If you want you can use the ibm JDBC driver ( and the SQL squirrel (

Guice Caching And Interceptors

14 05 2010

A little while ago I wanted to try out Guice 2′s Interceptors. And amazingly enough, I managed to create an integration towards ehcache in a couple of hours and had fun too.

The result is this

package org.slurry.cache4guice;

public interface Calculator {

        public int calculateSomethingWild(Integer number) throws InterruptedException ;

        public int calculateSomethingWild(Integer number,Integer number2) throws InterruptedException ;


package org.slurry.cache4guice;

import org.slurry.cache4guice.annotation.Cached;

public class CalculatorImpl implements Calculator {

        public int calculateSomethingWild(Integer number)
                        throws InterruptedException {

                return number;


        public int calculateSomethingWild(Integer number, Integer number2)
                        throws InterruptedException {

                return number + number2;


And bind it in your module

package org.slurry.cache4guice;


public class GuiceModule extends AbstractModule {

        protected void configure() {



So what’s backing those annotations in line 19 and 28 of the first source code box, whats doing all the magic?
1. An annotation, dada :)

package org.slurry.cache4guice.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD)
public @interface Cached {


2. An interceptor, more interesting, look at line 18 the most important thing in the interceptor implementation

package org.slurry.cache4guice.aop;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;


public class CacheInterceptor implements MethodInterceptor {

        private CacheManager cacheManager;

        private CacheKeyGenerator cacheKeyGenerator;

        public Object invoke(MethodInvocation invocation) throws Throwable {

                return getResultFromCacheOrMethod(invocation);



3. Some Guice setup, in a module look at line 18,19 and 20. And actually line 19 are only needed if you need something injected into your interceptor

package org.slurry.cache4guice.module;

import net.sf.ehcache.CacheManager;

import org.slurry.cache4guice.annotation.Cached;
import org.slurry.cache4guice.aop.CacheInterceptor;
import org.slurry.cache4guice.aop.CacheKeyGenerator;
import org.slurry.cache4guice.cache.StringBasedKeyGenerator;


public class CacheModule extends AbstractModule {
        protected void configure() {

                CacheInterceptor cacheInterceptor = new CacheInterceptor();
                bindInterceptor(Matchers.any(), Matchers.annotatedWith(Cached.class),

        protected Class getCacheKeyGeneratorClass() {

                return StringBasedKeyGenerator.class;

So could it be easier? I mean theres only 3 steps. Now I haven’t shown all the code, only the relevant ones for guice. There’s a little more to it. And I should probably expand the functionality, so there’s a evict from cache annotation, that can evict certain caches. So did you need a cache for guice or did you want to play with interceptors, now you got both :)

All hosted here, with source code and tests,  if you have additions please contribute


14 05 2010

So sitting in the hotel, geecon 2010 are over. All in all a nice experience. A little small maybe. But content was great, thats the important thing. And if you look at the price, if probably the best conference for the price, 100 eur… Cant get much cheaper.

The website

And the slides/videos (some, I guess they’ll all come latter) :

Guice JDBC and Pools

12 03 2010

These last days I’ve been working on a Rest application¬† which provides a generic interface to a database. So the idea are to provide a “REST” driver that can look into any given database. Since I needed look into any given table I could’nt use my ordinary stack with guice / warp persist and JPA. But had to create my own jdbc template (like spring jdbc template).¬† Doing db stuff one needs a connection pool and since C3P0 are somewhat dead (haven’t had a release in ages), I decided to go with Apache DBCP.

Im having one problem though if I use PoolableDatasource I get the dreaded “ Address already in use: connect”. If I manage the pool via the ObjectPool myself, it works like a charm. Not what I’ve hoped for.

Im wondering if it would be better (simpler) if I i used (Bone CP). I guess some one should make something like the Spring jdbc template for guice.

I’ve done some more testing and found out following things:

  • C3P0 are simple to setup, you can always owervrite defaults by property files or xml files
  • C3P0 are slower than Apache DBCP
  • Apache DBCP, pooled connection does not work or I am using it wrong
  • Bone CP, cannot connect to a jdbc uri with embedde password, user / password needs to be setup explicitly (which gives problems when using in memory hsql, no password / user)

For now I think i will be sticking to C3P0 since i gives the most clean implentation, although a little slower than the rest (we are talking miliseconds, for 150 concurrent users).

EDIT I need to revisit Bone CP since it has been updated and are now available in central repo :)

Rest Guice and JAX-WS

10 03 2010

These days im working on a small rest application, I found these resources to be helpful: (archetypes) (setting up jax-ws with guice) (a little more info, but the article above are enough) (framework for creating xml fragments)

So for unit tests im using dbuit to seed the hsql database and grizzly to run the application, jersey client acts as client.

I’ll probably add code examples to this article when I get time.


Get every new post delivered to your Inbox.