Wicket应用程序在启动jetty时会抛出异常:run-explosion

时间:2011-09-26 17:10:47

标签: java hibernate spring jetty wicket

我目前正在开发Wicket Spring Hibernate应用程序。对于开发我使用Jetty作为Web服务器。

使用mvn jetty:run启动应用程序时,一切都按预期工作。但是当我尝试使用mvn jetty:run-exploded启动应用程序时,会抛出一些异常,告知无法创建sessionFactory bean。

我已经对此问题进行了大量搜索,但未找到任何触发此错误的提示。堆栈跟踪也没有提供准确启动的信息。我希望有人能指出我正确的方向如何解决这个问题。

由于异常堆栈跟踪太长而无法在此处发布,因此我将其粘贴到PasteBin上。如果我使用mvn jetty:run-exploded启动我的应用程序,就会发生这种情况。 Exception Stack Trace

这是我的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>

这是我的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>

更新

在此处添加我的项目的Maven依赖关系图会超过我将其粘贴到PasteBin的最大允许字符数。

更新2

Output of the maven-duplicate-finder plugin

更新3

1 个答案:

答案 0 :(得分:2)

java.lang.IncompatibleClassChangeError: Implementing class表示某些类用于实现接口,但该接口变为类。通常它是某些版本冲突的证据。

我相信你在类路径中有Hibernate工件的冲突版本。如果是这样,由于类路径项的排序不同,问题只能在特定配置(例如run-exploded)中表现出来。

尝试运行mvn dependency:tree -Dverbose以识别冲突。