Category Archives: Java

Using more than one property file in Spring MVC

Spring is one of the most important, powerful and also complex frameworks in the actual Java panorama.

Unfortunately for me, I’m very forgetful so it is worth to write a post-reminder to increment the possibilities I never forget again something like this.

Using property files in Spring

Since Spring 3, the use of properties in our code was made really simple thanks to the placeholders.

Supposing a property file with next content:

It is enough to add the next configuration element in our servlet configuration XML file:

Later, at any place of our program we can easily get the properties using @Value annotation:

And what if you have more than one property files?

Supposing we have a second property file with the values:

Spring allows to specify more than one properties file adding a new placeholder:

The problem comes when you try to use the property from the second file, using @Value("${second_file_prop}"), Spring will throw an exception saying it can find the second_file_prop value. This is because Spring try to find the property in the first file and if it does not find it throws an error.

To avoid this ugly effect we need to use the ignore-unresolvable attribute in the placeholder:

This way if Spring does not find a property in the first file it will continue looking at the second one.

The order

In addition, the placeholder element can use the order attribute that determines the order in which Spring must look at the files. So a good way to express the previous configuration is:

Related Posts:

The Book: GeoServer Beginner’s Guide

GeoServer is one of the most importants open source geospatial servers nowadays. Implemented in Java, based on the powerful GeoTools libraries, GeoServer offers a great degree of interporability publishing data from major spatial data sources using Open Geospatial Consortium (OGC) standards.

Hopefully, for those who work or start working with GeoServer, recently Packt Publishing has released a new book titled GeoServer Beginner’s Guide.

Written by Stefano Iacovella, with contributions from Brian Youngblood, the book guide us on the main topics to work with GeoServer, through the next list of chapters:

Chapter 1: GIS Fundamentals
Chapter 2: Getting Started with GeoServer
Chapter 3: Exploring the Administrative Interface
Chapter 4: Accessing Layers
Chapter 5: Adding Your Data
Chapter 6: Styling Your Layers
Chapter 7: Creating Simple Maps
Chapter 8: Performance and Caching
Chapter 9: Automating Tasks: GeoServer REST Interface
Chapter 10: Securing GeoServer Before Production
Chapter 11: Tuning GeoServer in a Production Environment
Chapter 12: Going Further: Getting Help and Troubleshooting

Despite of its title, the book is great from newbies to those with intermediate knowledges on GeoServer, and also put some efforts on advance topics, like performance and configuration for production environment chapters.

Personally, I like the way Stefano writes: simply, plain and, most important, making clear complex questions. In addition, the book is plenty of samples and figures which help us to understand better what is talking on.

Conceptually, we can divide the book in three sections: introduction (chapter 1, 2 and 3), basic or common usage (chapters 4, 5, 6 and 7) and advanced topics (chapter 8, 9, 10 and 11).

The book introduces us in the GIS world  (chapter 1) starting with an introduction of many related topics: projections, coordinate systems, modeling information, etc. After this, it shows how to install GeoServer (chapter 2) in two different operating systems: Ubuntu Linux and Windows and finally, passed to show the main aspects of the administrative interface of GeoServer (chapter 3).

From here, the book covers the main aspect on how to access, add and serve data (chapter 4 and 5), how to style to serve them in a better way (chapter 6) and basic samples on how to create maps against GeoServer using Google Maps, OpenLayers and Leaflet libraries.

The third block, concentrates improving the performance of the server using the GeoWebCache system (chapter 8), administer GeoServer via its REST interface (chapter 9), securing its access and administration (chapter 10) and tune it up ready for a production environment (chapter 11).

The book is mainly oriented to WMS but dedicates the chapter 12 to talk specifically on WFS and WCS, also supported by GeoServer.

Without a doubt, GeoServer Beginner’s Guide is a book must be on your working table.

Related Posts:

Architexa product review

Architexa product is an Eclipse plugin from company. As their web site say:

Architexa helps you understand and document large/complex Java code bases within Eclipse

and allowing to create and explore diagrams that make sense.

I have tried it really little but the conclusions are clear: Architexa is a tool with a great potential.


Installing Architexa is really easy because it is prepared as any other Eclipse plugin (see the install section).

I’m using Eclipse 4.2 (Juno) and the steps were:

  • Go to Help > Install new software and add a new place called architexa with the URL:
  • Select the Architexa plugin and click next button until installation is done.

Really easy, don’t you?

After Eclipse restarts you will be asked for a valid Architexa user. Go to the registration page and register for a free license. That’s all.

Exploring a project

To test Architexa I have opened a relatively small maven project, which allows to download files from an FTP server. It haven’t a great domain model neither thousand of classes but has all the necessary to test the basic Architexa capabilities.

  • Layered diagrams
  • Class diagrams
  • Sequence diagrams

The bad

Before to continue, I must say Architexa seems to me a product with a great potential, but on the other hand it leaves me with bad feelings.

I prefer to comment all the bad things first so the good things comes later and the reader was left with a good feeling.

  • The Architexta web site is IMO horrible and much more the personal area of each user ( In addition it seems not much stable, at least for me the profile and setting sections fails with a 500 server error.
  • Once Architexa is installed it needs to build an index from your code. Initially I don’t built the index (when the tool ask me to do it) and after importing the project and building it by hand, it seems not work properly. For some reason my index was corrupted and I need to remove and import the project a couple of times before it woks.
  • The layered, class and sequence diagrams are powerful tools but the way to explore and navigate could be a bit more intuitive. In addition the shapes and colors used could be improved.

As you can see the bad things are almost all related to design and visual aspects, not to the product functionality. Nothing a good web designer can solve.

My opinion for Architexa guys is: Architexa is a great product so make it looks like a great product.

Working with the diagrams

Because the project is a small the most useful diagrams has been the class and sequence diagrams.

In the case of class diagram I added some classes related to the task to download and read radar files. Once a class is added to the diagram you can make actions like:

  • select which methods can be visible in the diagram
  • navigate from a method to other classes (show called method)
  • show which classes references a method (show calling method)

Thanks to this actions you can explore the classes and its dependencies in both directions.

The sequence diagram works in a similar way, you start adding a class or method and, for example, given a method add all the used methods from the same class or from other classes:

Finally, in the layered diagram I have added some classes to see its dependencies. Easily we can see the classes and the packages they belong to.

In addition, on any diagram you can select a class or method and navigate directly to the source code to see the corresponding lines of code.


As I commented previously Architexa is a tool with a great potential. It can help team members to understand better how code works or documenting processes.

As a future features I would like to suggest its integration with the debugger. First the possibility to highlight the current executed method on the class or sequence diagram. Second, the possibility to allow to create a diagram step by step while debugging, that is, selecting which methods or classes we want to add to the sequence diagram while advancing step by step in the code.

Congratulations to the Architexa team for their product !!!

Related Posts:

Jelastic, cloud platform for Java

Some days ago I receive an invitation for testing Jelastic product but, unfortunately, I was very busy with the OpenLayer Cookbook review tasks and didn’t have much time to look at it. 

Today, Saturday, I had a while, made my homework and had my first contact with the platform.

Who is behind Jelastic?

That was my first question so I took a look to the Jelastic web site.

The best way to answer this is looking at the Jelastic Team section. Founders, advisers, special partners conforms a real professional team. As special partners you will find the MySQL (Michael “Monty” Widenius) and Nginx (Igor Sysoev) authors.

Special mention too to their evangelists (not mentioned in the web page). In my case, Judah Johns spent their time writing me two personal emails simply to let me know about the Jelastic platform and the possibility to test it for free. That’s a real evangelist ;)


Sign up with the service is really easy. Once sent the registration email you will receive a welcome email with an initial password for log in.

First impression

My first impression with Jelastic, from the web page to the service once logged in, was: Ough!!!

I know design is something subjective, what you love other can hate, but the first impression is what counts in a 75%.

Sorry Jelastic but, from my point of view, you need a redesign. That darker theme is absolutely dreadful.


After the first impression I start working in something more functional, which is what really matters for a developer.

An environment is a concrete configuration of servers for load balancing, application logic and storage.

Load Balancing is achieved with Nginx server.

Application logic is implemented as a Java server side application and can run on Tomcat6, Tomcat7, Jetty6 or GlasFish3 servers using JDK6 or JDK7.

For storage we can use SQL or NoSQL solutions. For SQL we have the most known open source projects: PostgreSQL 8.4, MySQL 5.5 and MariaDB 5.2. For NoSQL we can use MongoDB 2.0 or CouchDB 1.1.

Creating a new environment is incredible easy. We can choose to use a load balancer or not, define the number of application logic server instances, possibility of high availability (which means session replication) and the storage service.

Once created, the environment’s topology can be modified at any time. At practice this means you can scale your application adding more application server instances or applying the high availability options, which allows to replicate the sessions. In addition you can change or add a new store services.

Note: Be aware if you change your relational or NoSQL server because data lost.

Deploying applications

For testing purposes, Jelastic comes with a HelloWorld.war sample applications. Deploy it is as easy as selecting and deploying on one of your, previously created and configured, environments.

To deploy your own application you need to upload it first. After uploaded your application will be shown in the applications list and you could deploy like previously commented.

Server configuration

Once created the environment, you have access to the configuration files of your servers.

I played a bit with a simple Tomcat+MySQL configuration and see you:

  • have access to modify files like web.xml or server.xml
  • can change logging preferences
  • can upload new JAR files to or remove them from the lib folder
  • have access to the webapps folder
  • have a shortened version of my.cnf file you can edit.

Log files and monitoring

Jelastic monitors the servers of your environments and presents the results in a nice graphical way.

In addition it also allows to see the log files of the servers:

Looking log files in the browser is something funny, but I would like a way (I didn’t find it) to download the log files to my local machine. Looking for errors in a production environments with tons of lines isn’t easy to do in that text area.


Connect your application to the storage service (relational or NoSQL database) is really easy. The documentation contains samples for all the databases the Jelastic has support.

The application logic servers have access to a home directory where you can create property files or upload whatever you want your application can use later using:


At the opposite of Amazon AWS, Google App Engine or others, Jealastic is completely oriented to Java.

If you are a Java developer and ever worked with AWS or Google App Engine you will find Jelastic complete different and incredible easy to use, really similar as a usual day to day work.

While AWS is machine oriented, where you start as many EC2 instance as you require, with Jelastic you have the concept of cloudlet and you can forget completely to manage machine instances and their resources.

Note: A cloudlet is roughly equivalent to 128 MB RAM and 200Mhz CPU core.

I have written this post before dinner so, as you can see, it is nothing exhaustive but a simple platform presentation.

A great continuation would require to explain the experiences working with a real application, deploying operations and tweaking the running environment to achieve good performance with lowest cloudlet consume.

If someone is interested, another great article could compare the cost of the same application running with Amazon AWS and Jelastic: where runs with better performance and which one is cheaper.

Related Posts: