Friday, 28 October 2011

Dependency tree in maven

To see dependency tree in maven use command:
mvn dependency:tree

Tuesday, 25 October 2011

How to create java object in Freemarker?

If you are using Freemarker integrated with struts, look at the class org.apache.struts2.views.freemarker.FreemarkerResult. In this class there is a method createModel(). There you have a list of objects inserted into model used in freemarker rendering.

  • Application - servlet context attributes hash model
  • JspTaglibs - jsp tag lib factory model
  • Request - request attributes hash model
  • Session - session attributes hash model
  • request - the HttpServletRequst object for direct access
  • response - the HttpServletResponse object for direct access
  • stack - the OgnLValueStack instance for direct access
  • ognl - the instance of the OgnlTool
  • action - the action itself
  • exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages)
  • struts - instance of the StrutsUtil class

In the ftl code you can use struts variable:

It will return object of this type, constructed with zero parameter constructor.

Format date in java with months' name changed

I was given the task to format dates. The requester needed months' name appropriate case endings.

It can be done be SimpleDateFormat class: (this example is for Polish language)

SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
DateFormatSymbols dfs = new DateFormatSymbols();
dfs.setMonths(new String[]{"stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"});
String output = sdf.format(new Date());

Heap pollution

What is it?

Java Language Specification, Third Edition
§ Heap Pollution
It is possible that a variable of a parameterized type refers to an object that is not of that parameterized type. This situation is known as heap pollution. This situation can only occur if the program performed some operation that would give rise to an unchecked warning at compile-time.

Here is an example:

List l = new ArrayList();
List l1 = l;
Integer i = l1.get(0);

In java 7 the following additions help to deal with Heap Pollution:

  • A new mandatory compiler warning is generated on declaration sites of problematic varargs methods that are able to induce contributory heap pollution.
  • The ability to suppress those mandatory warnings at a declaration site using an @SuppressWarnings("varargs") annotation. The warnings may also be suppressing using the -Xlint:-varargs option to the compiler.
  • If the @SuppressWarnings("varargs") annotation is used on a problematic varargs method declaration, the unchecked warnings at call sites of that method are also suppressed.

Saturday, 22 October 2011

SpeakIt! - Chrome extension

Now you can mark a text in your Chrome browser and let the computer speak it!. Just install Chrome extension SpeakIt. You can find it here: SpeakIt.

Limit on Post Request - maxPostSize

Recently I was faced with a problem concerning a web page form. It stopped working without any change in the code. I have checked that due to database increase in this form I have over 50000 hidden inputs. So it looks like the server did not cope with such a big number of parameters in the post request.
I've found in the Tomcat and Jboss Connector configuration that we can define a constant maxPostSize that is the maximum size in bytes of the POST request that is handled by the container FORM parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

Wednesday, 19 October 2011

STS 2.8.0 released. Supports Java 7

The new 2.8.0 release of the SpringSource Tool Suite (STS) is available. Now it has full IDE support for Java 7!
For more details browse to:

How to exclude folders from searches in Eclipse?

Right click on a folder. Choose properties. Set the folder as derived. Derived entities are not searchable by default.

Class Currency

In java 7 we have a new class:

It represents a currency. The currencies are identified by their ISO 4217 currency codes. Visit the ISO web site for more information, including a table of currency codes.

JRebel Newsletter

JRebel Newsletter is now available here:

LiveRebel is also worth mentioning. This product allows Java EE Hot Update without downtime, no lost session, no OutOfMemoryErrors, fully automated. Here is the demo.

Wednesday, 12 October 2011

Download AppDynamics Lite 2.0

New version of AppDynamics Lite is available. The newest version of Lite enables to:
  • monitor JMX metrics
  • include proactive email alerts when errors are found
To download Lite 2.0 go to:

Alfresco Certification

Alfresco has started a certification program. Certifications will confirm technical proficiency on the Alfresco platform. There are two certification paths for Engineer and Administrator. To certify you need to pass an exam at Pearson Vue. They have over 5,000 test centres in 165 countries. Test fee is 195 USD.
More details here:

Tuesday, 11 October 2011

Spring roo fixes bugs.

I've found a bug in Spring roo. I've created a project with module WEB MVC. I generated controller with mapping in mixed case. Unfortunately, the code generated by roo didn't work. I logged into the Spring roo Jira and created an issue: After a week, the bug was fixed. I am impressed. They do have a good support!

Thursday, 6 October 2011

Use Tomcat for EJB?

The Apache Software Foundation Announces Apache TomEE Certified as Java EE 6 Web Profile Compatible. If you wanted to use Java EE think about using it. Read more on:

Alfresco 4

A new version of Alfresco is ready to be downloaded now!
Alfresco Community 4, the first open platform for social content publishing is now available to download for free. Alfresco 4 includes new tools which allow developers to create social and cloud-scale, content-rich applications. Further, it includes a new, extensible service to publish content and status updates to social sites, including YouTube, Facebook, LinkedIn, Twitter, Flickr and SlideShare.
See details here

IBM SDK Java Technology Edition Version 7

IBM have announced the availability of IBM JDK 7 for both their AIX platform and the Linux platform. Windows is not supported by the SDK They have prepared changes not only supporting Java 7 features, but also big changes in Garbage Collection. More details here.

Wednesday, 5 October 2011

Assertiveness training

I have recently participated in the Assertiveness training . It's been the best soft skills training I have attended. Here're some useful tips:

Remark: This advice is relevant to Polish language and culture. In many others it could be seen as impolite or without any sense. ;-)

Assertive refusal has to have three parts:
  • The word No
  • Information on how you will behave
  • Short explanation
  • Expression of your being sorry
When you want to verify if your refusal was assertive answer one simple question:Do I feel good about it?

It is important not to excuse yourself to much. If not, it will be harder to stop repeated requests. There are some techniques that can be used if you are asked for something again and again:
  • Broken record - repeat still the same explanation
  • "I am elephant" technique - Say slowly, ask, paraphrase.
  • Jujitsu - If you are faced with the argument that a he/she has helped you in past, but now you are not willing to help him. Remember to thank him, but tell him that this time you cannot help.
  • authority - refer to the standards or authority
Assertive request Remember to:
  1. Think what will happen if you don't succeed.
  2. State your request in a short and logic way.
  3. End with a question about the actual decision (time or price).
A good assertive creates a platform for acceptance now or in the future.

Reaction for judging critique

You have two possibilities. You can say:
  • I agree. That's what I think.
  • I do not agree. I don't think about myself that way.
Don't get nervous! Don't persuade but state. Protest on unjust generalizations. When surprised, express it!

Feedback can be positive and negative. It has to contain 3 parts:

  • Fact - that has happened
  • Attitude - how do I feel about it
  • Expectation - what do I expect, how this person should behave.

Spring roo doesn't support Java 7

As in the title, Spring roo doesn't support java 7. See here.

Caching requests with status 301 in the browser

Recently I had to fix a bug found in the web application. I tried to repeat scenario in which the application reacted incorrectly. Unfortunately, in the logs I couldn't find some request from the browser. I used Mozilla Firefox with the Data Tamper plug-in, so I saw all requests made by the browser. I thought that Apache web server could cache it after I had found that application server doesn't do it. But it did not. In the end I found that Firefox cached it. Finally, in the Firefox plug-in Web Developer I switched off the cache. So I have found for the first time that a browser caches requests with response status 301.

Tuesday, 4 October 2011

Astah version 6.5

Change Vision has released Astah version 6.5. It is the next version of a program for building UML diagrams. The biggest change is possibility for creating your own plug-ins to extend Astah. Some bugs of version 6.4 were fixed. They have also released Astah Share version 2.5, that enables you to share your diagrams on your blog and wikis more easily. To see more go to page.

Monday, 3 October 2011

Alfresco Mobile

Alfresco Software has announced Alfresco Mobile - the free iOS app for the iPad and iPhone. With Alfresco Mobile, users can work more efficiently in a mobile environment. Application for iPad and iPhone can be download here.

Free version of JRebel

ZeroTurnaround company has released JRebel 4.5. They also included a new version, called JRebel Social. It's a free version, that requires: a social login (Facebook or Twitter), a constant internet connection. It's for non-commercial use only. To see more details: JRebel Social

Sunday, 2 October 2011

Cloud Foundry Deployments with Maven

The Cloud Foundry team has released the Cloud Foundry Maven Plugin. Developers can now easily integrate cloud deployments into their Maven projects. For more details go to: