3

SPRING-DATA-JPA、GWT プロジェクトに基づいてアプリケーションをセットアップしようとすると、エラーが発生します。ホスト モードで実行しようとすると、例外が発生します。

org.springframework.beans.factory.BeanCreationException にネスト: 「org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0」という名前の Bean を作成中にエラーが発生しました: Bean の初期化に失敗しました。入れ子になった例外は org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/ * */www/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; ネストされた例外は javax.persistence.PersistenceException: [PersistenceUnit: default] EntityManagerFactory を構築できません: javax.validation.ValidationException: Unable to find the default provider

これが私のapplicationContext.xmlです:

<context:component-scan base-package="service"/>

<jpa:repositories base-package="service.repositories"
                  query-lookup-strategy="create-if-not-found"/>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="rollbackOnCommitFailure" value="true"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager"/>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driver.classname}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="user" value="${jdbc.user}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="autoCommitOnClose" value="true"/>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"/>
    <property name="packagesToScan" value="com.logicify.office.domain"/>
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true"/>
            <property name="generateDdl" value="true"/>
            <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQL82Dialect"/>
        </bean>
    </property>
</bean>

ここに pom.xml があります:

<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Logicify Infrastructure</name>

<modules>
    <module>m-domain</module>
    <module>m-service</module>
    <module>m-calendar</module>
    <module>m-admin</module>
    <module>m-supply</module>
    <module>m-entry</module>
</modules>

<properties>
    <gwtVersion>2.5.0</gwtVersion>
    <spring.version>3.1.2.RELEASE</spring.version>
    <hibernate.version>4.1.7.Final</hibernate.version>
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <build.filter.file>test.properties</build.filter.file>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.0.2.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.0-801.jdbc4</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

    </dependencies>
</dependencyManagement>

<dependencies>

    <!--GWT SDK-->
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwtVersion}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwtVersion}</version>
    </dependency>

    <!--Validation API-->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <classifier>sources</classifier>
    </dependency>

    <!--LOGGER-->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>

    <!--PROXY LIBS-->
    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>

    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>

    <!-- TESTING -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>1.9.5-rc1</version>
    </dependency>
</dependencies>


<build>
    <finalName>logicify-infrastructure</finalName>
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
    <filters>
        <filter>${project.basedir}/../properties/${build.filter.file}</filter>
    </filters>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

         <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.5.0</version>
                <executions>
                <execution>
                    <goals>
                        <goal>clean</goal>
                        <goal>compile</goal>
                        <goal>resources</goal>
                        <goal>generateAsync</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>

                <compileSourcesArtifacts>
                    <artifact>com.logicify.office:m-domain</artifact>
                    <artifact>com.logicify.office:m-admin</artifact>
                    <artifact>com.logicify.office:m-calendar</artifact>
                    <artifact>com.logicify.office:m-service</artifact>
                    <artifact>com.logicify.office:m-supply</artifact>
                </compileSourcesArtifacts>

                <runTarget>Entry.html</runTarget>
                <hostedWebapp>${webappDirectory}</hostedWebapp>
            </configuration>
            </plugin>
        </plugins>
</build>

GWT 統合なしの同じ構成は正常に機能します。どんな助けでも役に立ちます!

4

2 に答える 2

2

javax.validation を指定すると、Maksym が述べているように、実装が必要なインターフェイスのみが提供されます

<!--Validation API-->
<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
</dependency>

休止状態のバリデーターのバージョンが必要です

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.0.0.CR5</version>
</dependency>
于 2013-04-09T13:18:25.367 に答える
1

hibernate-validator.jar をクラスパスに追加してみてください。GWT 2.5.0 は Validation API (既に GWT SDK に含まれています)を使用しており、その実装を提供する必要があります。検証セットアップ手順を参照してください

于 2012-12-17T17:24:02.553 に答える