Wednesday, October 12, 2011

pendule chrome extension for web developer

https://chrome.google.com/webstore/detail/gbkffbkamcejhkcaocmkdeiiccpmjfdi

Thursday, September 29, 2011

hey google, I want my cache links back

hey google, I want my cache links back

A good post about google search changes and feature regression

Monday, August 22, 2011

cobertura spring proxy cglib problem : UnsatisfiedDependencyException

Just add the proxy-target-class="true" part within <aop:aspectj-autoproxy proxy-target-class="true" />

Thanks to http://royontechnology.blogspot.com/2010/08/cobertura-and-spring-auto-proxying.html

Faulty Stacktrace :
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name '***' defined in class path resource [***]:
    Unsatisfied dependency expressed through constructor argument with index 0 of type [***]:
    Could not convert constructor argument value of type [$Proxy52] to required type [***]:
    Failed to convert value of type '$Proxy52 implementing net.sourceforge.cobertura.coveragedata.HasBeenInstrumented,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type '***'; nested exception is java.lang.IllegalStateException:
    Cannot convert value of type [$Proxy52 implementing net.sourceforge.cobertura.coveragedata.HasBeenInstrumented,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [***]: no matching editors or conversion strategy found ...

Thursday, August 18, 2011

Linux disk usage analyzer on command line

http://dev.yorhel.nl/ncdu

Thursday, August 4, 2011

fake smtp server with python

sudo python -m smtpd -n -c DebuggingServer localhost:1025

Thursday, June 30, 2011

Devoxx 2011 Home Image

I have fetch and reassemble the nice Devoxx 2011 home image which use google maps zoom feature.

Zoom Level 2

Zoom Level 4
Zoom Level 5

I hope given these images are legal. If not, feel free to contact me.

Tuesday, June 7, 2011

java rough guide to character encoding

http://illegalargumentexception.blogspot.com/2009/05/java-rough-guide-to-character-encoding.html

Friday, May 20, 2011

add static resource directories to jetty-maven-plugin 7.x

When using jetty-maven-plugin during development of a web application with the command mvn jetty:run. I need to use some static resources which I DO NOT want to put in src/main/webapp. I put DEV resources into src/test/webapp instead. But jetty does not load these resources by default. So the following jetty-maven-plugin configuration show how to provide static resources.

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <configuration>
        <webAppConfig>
        ...
            <resourceBases>
                <resourceBase>src/main/webapp</resourceBase>
                <resourceBase>src/test/webapp</resourceBase>
            </resourceBases>
        ...
        </webAppConfig>
    </configuration>
</plugin>

Tuesday, May 10, 2011

memory leak when doing redeploy with jetty

When using the mycila-testing-jetty plugin for webapp integration tests, I encounter memory leak problem with the infamous OutOfMemoryException (OOM) : PermGen Space.

You can have a OOM on heap space and permanent generation (PermGen) space in your JVM.
The heap space is mainly for short term and mid term memory allocation. The permanent generation space, as named, is for long term object such as class object which are loaded by classLoader and retained during the whole life of the JVM.

But in case of webapp running in a servlet container such as jetty, you sometime need to undeploy and redeploy your application to apply code change. With the mycila-testing-jetty plugin you can choose to either restart your server, redeploy your webapp or keep them running.

During my tests, restarting the server or keeping them runnning them was OK. But I'd always got OOM when keeping the jetty server running and only doing redeploy of the webapp. So I've track down the leak using Eclipse Memory Analyzer and jvisualvm tools.

The error come from how jetty keep sessions.

The problem is that session created during the lifetime of the webappContext are not invalidated on undeploy and so stay in the Server._sessionIdManager keeping all the webappContext class and making OutOfMemoryException PermGen Space happening.

SessionIdManager only invalidate session if the webapp ask it to. I think that except for cluster session management, when undeploying a webappContext then all the session created by it must be invalidated and cleared.

To work around, you can change the server sessionIdManager before redeploying the new webappContext :

server.setSessionIdManager(new HashSessionIdManager());


Bug issue : memory leak when doing successive redeploy of webappContext due to not invalidated session in server

Thursday, May 5, 2011

Java WAR execution source code location

this.getClass().getProtectionDomain().getCodeSource().getLocation();

Tuesday, April 26, 2011

workaround for sitemesh decoration of servlet error

Reference : workaround for sitemesh decoration of servlet error

workaround filter :

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) 
 throws ServletException, IOException { 
        HttpServletRequest request = (HttpServletRequest)servletRequest; 
        request.removeAttribute("com.opensymphony.sitemesh.APPLIED_ONCE"); 
        filterChain.doFilter(servletRequest, servletResponse); 
} 

web.xml :

<filter> 
        <filter-name>clearSiteMeshAppliedOnce</filter-name> 
        <filter-class>ClearSitemeshAppliedOnceFilter</filter-class> 
</filter> 
<filter-mapping> 
        <filter-name>clearSiteMeshAppliedOnce</filter-name> 
        <url-pattern>*</url-pattern> 
        <dispatcher>ERROR</dispatcher> 
</filter-mapping>

Thursday, April 14, 2011

Damn easy Spring MVC complex object binding within collection

During the development of our web application using Spring MVC, we wanted to allow the modification of some data such as an Actor which has an id and a name. We didn't want to show the id, only the name.

The problem is how to bind back the modified name ? We tried using PropertyEditor but this is handy to transform some data to String and back. I searched the web but at last, I understood how to do that very easily.


<ul>
    <c:forEach items="${form.actors}" var="actor" varStatus="status">
        <li>
            <form:hidden path="actors[${status.index}].id" />
            <form:input path="actors[${status.index}].name" />
        </li>
    </c:forEach>
</ul>

Et voilĂ  !

The id is bound back to the Actor as the modified name.

Note : the actors collection must be a List or an Array.

Tuesday, January 25, 2011

Web application integration testing made easy with mycila jetty testing plugin

It is time to do some advertising about a very cool way of doing integration testing of a web application (aka : a java WAR deployment and testing).

I am honored to present the mycila jetty testing plugin :D

Saturday, January 22, 2011

Google please, give my navigation reader link back !

As Google operating system blog said, they moved some of the navigation menu links.

I instantly noticed that because I use it every day.

So please Google, give my navigation reader link back or make the navigation menu customizable.

EDIT (25/01/2011) : Google give it back, thanks.

Tuesday, January 11, 2011

dry-run svn update on command line

"svn merge –dry-run -r BASE:HEAD ."