I’m currently developing a Wicket Spring Hibernate application. For development I’m using Jetty as web server.
When starting the application with mvn jetty:run everything works as expected. But when I try to start the application with mvn jetty:run-exploded some exceptions are thrown telling that the sessionFactory bean couldn’t be created.
I already search a lot about this issue but couldn’t find any hints on what triggers this error. Also the stack trace doesn’t provide very much information where exactly to start. I hope someone can point me in the right direction how to solve this issue.
As the exception stack trace is too long to post it here I pasted it on PasteBin. This happens if I start my application with mvn jetty:run-exploded. Exception Stack Trace
Here is my applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- Configurer that replaces ${...} placeholders with values from properties files -->
<!-- (in this case, JDBC related properties) -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:application.properties</value>
<value>file:///${user.home}/storefinder.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="true"/>
</bean>
<!-- a bean for storing configuration properties. -->
<bean id="runtimeConfig" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:application.properties</value>
<value>file:///${user.home}/storefinder.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="true"/>
</bean>
<!-- bean id="wicketApplication" class="com.mycompany.storefinder.backend.core.web.StoreFinderApplication" /-->
<!-- Services -->
<bean id="authenticationService" class="com.mycompany.storefinder.backend.core.service.AuthenticationServiceImpl">
<constructor-arg ref="userDao"/>
<constructor-arg ref="runtimeConfig" />
</bean>
<bean id="imageService" class="com.mycompany.storefinder.backend.core.infrastructure.filesystem.ImageFileServiceImpl">
<constructor-arg ref="imageDao"/>
<constructor-arg ref="runtimeConfig" />
</bean>
<!-- DAOs -->
<bean id="offerDao" class="com.mycompany.storefinder.backend.core.infrastructure.hibernate.OfferDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="userDao" class="com.mycompany.storefinder.backend.core.infrastructure.hibernate.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="roleDao" class="com.mycompany.storefinder.backend.core.infrastructure.hibernate.RoleDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="imageDao" class="com.mycompany.storefinder.backend.core.infrastructure.hibernate.ImageDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="storeDao" class="com.mycompany.storefinder.backend.core.infrastructure.hibernate.StoreDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Database Beans -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.h2.Driver"/>
<property name="url" value="jdbc:h2:file:target/db/storefinder"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="use_outer_join">true</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.connection.pool_size">10</prop>
<prop key="hibernate.jdbc.batch_size">1000</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.mycompany.storefinder.backend.core.domain.offer.Offer</value>
<value>com.mycompany.storefinder.backend.core.domain.image.Image</value>
<value>com.mycompany.storefinder.backend.core.domain.store.Store</value>
<value>com.mycompany.storefinder.backend.core.domain.store.OpeningPeriod</value>
<value>com.mycompany.storefinder.backend.core.domain.store.CommunicationData</value>
<value>com.mycompany.storefinder.backend.core.domain.user.Role</value>
<value>com.mycompany.storefinder.backend.core.domain.user.User</value>
<value>com.mycompany.storefinder.backend.core.domain.base.BusinessObject</value>
</list>
</property>
<!-- TODO Check -->
<property name="schemaUpdate" value="true"/>
</bean>
<!-- Tell Spring it should use @Transactional annotations -->
<tx:annotation-driven/>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
Here is my pom.xml.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.storefinder</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>StoreFinder Backend</name>
<dependencies>
<!-- LOGGING DEPENDENCIES -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>2.5.5</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- HIBERNATE & DB -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.2.0.Final</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.158</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.15.0-GA</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- COMMONS LIBS -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- JODA TIME -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-hibernate</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
<!-- WICKET -->
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-auth-roles</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-extensions</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-devutils</artifactId>
<version>${wicket.version}</version>
</dependency>
<!-- TESTING DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.unitils</groupId>
<artifactId>unitils</artifactId>
<version>${unitils.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.unitils</groupId>
<artifactId>unitils-spring</artifactId>
<version>${unitils.version}</version>
</dependency>
<dependency>
<groupId>org.unitils</groupId>
<artifactId>unitils-test</artifactId>
<version>${unitils.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-management</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>
<!-- >dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-spring3-app-rt</artifactId>
<version>1.24</version>
</dependency-->
</dependencies>
<build>
<plugins>
<!-- plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>1.24</version>
<configuration>
<configFile>src/main/webapp/WEB-INF/enunciate.xml</configFile>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin-->
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.version}</version>
<configuration>
<instrumentation>
<excludes>
<exclude>src/test/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<!-- Add code coverage report to site -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.version}</version>
</plugin>
</plugins>
</reporting>
<properties>
<wicket.version>1.5-RC5.1</wicket.version>
<jetty.version>6.1.4</jetty.version>
<cobertura.version>2.5.1</cobertura.version>
<slf4j.version>1.6.1</slf4j.version>
<springframework.version>3.0.5.RELEASE</springframework.version>
<junit.version>4.8.1</junit.version>
<unitils.version>3.1</unitils.version>
</properties>
</project>
UPDATE
As adding the Maven dependency graph of my project here would exceed the maximum allowed character count I pasted it to PasteBin.
UPDATE 2
Output of the maven-duplicate-finder plugin.
UPDATE 3
java.lang.IncompatibleClassChangeError: Implementing classmeans that some class used to implement an interface, but that interface turned into a class. Usually it’s an evidence of some version conflict.I believe you have conflicting versions of Hibernate artifacts in the classpath. If so, the problem can manifest itself only in particular configurations (such as
run-exploded) due to different ordering of classpath items.Try to run
mvn dependency:tree -Dverboseto identify conflicts.