Add CORS management with Tomcat and Angular-Js

In one of my projects, I decided to setup a SOA architecture using Angular-Js as the UI layer. My main focus is to have a clear separation between the business and the presentation. Another benefit of this is that it is possible the use different servers to these 2 parts. But doing this causes an… Continue reading Add CORS management with Tomcat and Angular-Js

Multithreading and Spring Security

I manage a Spring project where I need to create a new thread to launch an asynchronous task. This project uses Spring Security and an Oracle proxy user (I will describe it in a future post), which means that, for each starting transaction, a call is made to the security context to get the current… Continue reading Multithreading and Spring Security

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 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

Starting of Spring context in web application

Using Spring in a web application, we need to load the context when the application starts. Fortunately, it can be done in a simple way, by adding the right listener in the application web.xml. Using Maven, you need to add the Spring-web dependency in your pom.xml: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.0.0.RELEASE</version> <scope>compile</scope> </dependency> And in the… Continue reading Starting of Spring context in web application

Access Spring context from web application

As I am using JSF with Spring, the beans managed by Spring are not accessible in my page, I used this Siegfried Bolz’s blog as a basis and used the facade pattern to hide access to the context. The Spring context is loaded when the application starts using ContextLoaderListener in the apllication web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>… Continue reading Access Spring context from web application

Bitronix configuration

After a first attempt to configure the JBoss transaction manager including  JMS, I finally decided to try the Bitronix transaction manager. Here is the detail of the configuration. First of all, you need to add the bitronix jars to your project, using Maven, it’s done very easily (unlike JBossTS, which needs a lot of different… Continue reading Bitronix configuration

Tomcat Datasource configuration

I describe here my favorite solution to define the datasource of my web applications. To do that in Tomcat : Copy the JDBC driver jar into the Tomcat lib directory define the datasource in the file server.xml: <GlobalNamingResources> <Resource auth=”Container” driverClassName=”oracle.jdbc.OracleDriver” maxActive=”20″ maxIdle=”10″ maxWait=”-1″ name=”jdbc/myGlobalDatasource” password=”password” type=”javax.sql.DataSource” url=”jdbc:oracle:thin:@[server]:[port]:[sid]” username=”user”/> </GlobalNamingResources> map this datasource to your… Continue reading Tomcat Datasource configuration