Since I adopted a Restful architecture, I need also a simple way for the exceptions management. With Spring, it can be easily set-up with in a central class, avoiding a painful management per service. To do this, we need to define a class with the @ControllerAdvice annotation, this class will be automatically associated to our… Continue reading Add global exception management in Rest web service
Author: classNotFound
Define Restful web services using Spring
In one of my project, I had the difficult decision to switch to another technology: I replaced JSF with Angular-JS. Our goal was to speed up the development by removing the painful part implied with JSF, as a lot of server requests to manage, some view state issues, the refresh management, the need to implement… Continue reading Define Restful web services using Spring
Define configuration file outside of the classpath
Here I describe the way I use to configure my applications. The main idea is to define a property file outside of the application, doing this, it is possible to deploy the same application in several environments (dev/test/prod) without any changes. First of all, the property file: net.classnotfound.app.jdbc.server=db-server net.classnotfound.app.jdbc.port=1521 net.classnotfound.app.jdbc.sid=xe net.classnotfound.app.jdbc.user=scott net.classnotfound.app.jdbc.password=koala The tips is… Continue reading Define configuration file outside of the classpath
Spring MyBatis configuration
Here I describe the project configuration to use MyBatis as ORM and benefit of the transactions management provided by Spring. For that, we have to add the MyBatis-Spring library to the basic MyBatis. First, the Maven POM is like: <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.3</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.1</version> </dependency> And now, the Spring configuration file… Continue reading Spring MyBatis configuration
ThreadLocal usage
The ThreadLocal is very helpful to keep some information available from anywhere in the application but it is very important to release it when the process ends, otherwise, the resource will never be free and can cause a memory leak. Here is an example of using TheadLocal to store data in a web application. I… Continue reading ThreadLocal usage
My Eclipse shortcuts
Here is a list of my favorite shortcuts I use with Eclipse: [Ctrl]+[D]: Delete row [Ctrl]+[F]: Search in file [Ctrl]+[H]: Search->search… [Ctrl]+[O]: Navigation->Quick outline [Ctrl]+[Q]: Last edit location [Ctrl]+[S]: save the current tab [Ctrl]+[T]: Navigation->Quick type hierarchy [Alt]+[left/right]: Back/next to tab [Alt]+[up/down]: Move row [Ctrl]+[Shift]+[C]: Comment selection/uncomment commented selection [Ctrl]+[Shift]+[G]: Search->references->workspace [Ctrl]+[Shift]+[R]: Navigation->Open resource [Ctrl]+[Shift]+[S]:… Continue reading My Eclipse shortcuts
Display Maven release number in JSF page
In the web projects, it is often useful to see quickly the version of the deployed application. A simple solution is to get it from Maven and display it in our page, in footer or a “about” page. The main idea is to use a property file as a JSF resource as we can use,… Continue reading Display Maven release number in JSF page
Enable transactions on Informix DB
We need to have the following variables set: INFORMIXDIR=/opt/IBM/informix INFORMIXSQLHOSTS=/opt/IBM/Informix/etc/sqlhosts.ol_informix1170 INFORMIXSERVER=ol_informix1170 Now, we can enable the transactions, in first we need to put the database in “quiescent mode” (???): >/opt/IBM/informix/bin/onmode –uy Note: doing this disable access to the database. enable transactions: >/opt/IBM/informix/bin/ontape –s –L 0 –B d9exp Re-enable the connections: >/opt/IBM/informix/bin/onmode -m Helpful information: Jdbc… Continue reading Enable transactions on Informix DB
Spring Security with JSF 2 and custom login form
Here, I am integrating Spring Security with JSF 2 using a custom login form. First, the maven dependencies for Spring-Security (I consider that the JSF project is already set-up, if it is not the case, you can check here): <properties> … <spring.security.version>3.2.4.RELEASE</spring.security.version> </properties> … <!– Spring-Security dependencies –> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>${spring.security.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId>… Continue reading Spring Security with JSF 2 and custom login form
Adding AOP using Spring
I need to add some behavior to my service beans each time I start a transaction. In fact, I am converting a 2-tiers application in a web application, and previously, the users are authenticated using a real Oracle account. This way, they were able to use some user variables, using a proxy user (I will… Continue reading Adding AOP using Spring