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

Simple Spring configuration

Spring configuration for use of a simple transaction manager (non XA). The data source must be defined in a JNDI repository (Tomcat in my case). application.xml: <?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”” xmlns:xsi=”” xmlns:tx=”” xsi:schemaLocation=””> <bean id=”entityManagerFactory” class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”> <property name=”dataSource” ref=”dataSource” /> <property name=”jpaVendorAdapter”> <bean class=”org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter”> <property name=”databasePlatform” value=”org.hibernate.dialect.Oracle10gDialect” /> <property name=”generateDdl” value=”false”… Continue reading Simple Spring configuration