Apr 17, 2013

SimpleMappingExceptionResolver ignore exception

Lately i wanted to ignore ClientAbortException that raised by tomcat (catalina), instead of having a lot of stacktrace relates to this exception to have some line of my own, custom line in the log like "Client abort exception." and that's it.


There are many ways to do it, one way is using the @ExceptionHandler annotation from spring within the controller. But i have found that this solution obliged me to do so in all the relevant handlers.

Better way i think, extending the SimpleMappingExceptionResolver , overrding resolveException method,
When the exception arrive, check if the simple class name of the class inside it contains "ClientAbortException".

Why this way ?
This way you keep your code decoupled from tomcat catalina , better practice i think.


hoped i helped.

Dor

Dec 27, 2012

EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

Hi,
Lately i had this exception in my spring jdbc part of code. What it
actually means is that your query probably doesn't return any value while you are trying to assign the query result into let's say 'int'.

Change the query from queryForInt to regular query that returns a list. Use row mapper also.
Check the list, if it's empty, nothing returned from the query, decide what to do, else if the list isn't empty
and contain data, also, decide what to do.
It then will work for you.



Hoped i helped,
Dor

Sep 14, 2012

ERROR: Failed to parse POMs

Strange situation where the local build success but the build on the jenkins fails. 

After investigation i have noticed that one of the developers have add a tab somewhere in the pom. 
The tab \t character cause this error in the jenkins

Removing this character solved the issue. Of course i have reported that also to the jenkins guys. 


Hoped it helped you,

Dor

Aug 7, 2012

java.awt.color.CMMException: Invalid image format

Caused by the metadata within the picture file.
Try to save the file without the metadata (usually camera metadata). Since this version doesn't support this metadata.
Another solution, use JAI instead.


Hoped that it helped,
Dor

Aug 5, 2012

visualvm Local java applications cannot be monitored

It used to be a bug, happened to me on windows 7.

Solution can be found in the internet and is simple.

Close all your java servers/applications eclipse etc.
Go to your \users\yourusernamedir\AppData\Local\Temp\hsperfdata_yourusernamedir
And delete this directory.

For me it worked.

Dor

Jul 19, 2012

Maven parallel build

Hi All,

I have looked for a while for this option, wondered how could it be that they don't have it.

Finally i found it, since maven 3v, they add an experimental option, the T option.

You can now run maven build parallel way. Meaning, maven will check which parts from the project tree he can build in parallel and do it.

Performance ?

Big boost, something like >20%, Do it for your self and compare, you want regret it.

Good also for CI (Jenkins for example)

How?

First way,
"mvn -T 4 clean install"

-T   => Stands for telling maven to use the parallel way.

4    => Means, 4 threads to use.

Second way and my preferred,
"mvn -T 4C clean install"

-T   => Stands for telling maven to use the parallel way.

4C  => Means, 4 threads on each core


Dor

Jul 17, 2012

logback asyncappender

Since 1.0.4 logback has the famous async appender we all waited for at least me.
It's great news, not to use any custom appenders or custom async appender but their in house.

Just to inform you.
Dor