0

私は休止状態、gwt、JPA、Tomcat、および春を使用しているこのプロジェクトを持っています。とにかく、私はこのエラーを解決しようとしましたが、成功しませんでした。これは私のエラーです:

         log4j:WARN No appenders could be found for logger(org.hibernate.cfg.annotations.Version).
       Please initialize the log4j system properly.
       Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit:          projetA] Unable to configure EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:371)
    atorg.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
    at com.pac.projetA.shared.Dto.Main.main(Main.java:14)
        Caused by: org.hibernate.HibernateException: Unable to get the default Bean     Validation factory
    at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:104)
    at org.hibernate.cfg.AnnotationConfiguration.applyBeanValidationConstraintsOnDDL(AnnotationConfiguration.java:477)
    at org.hibernate.cfg.AnnotationConfiguration.applyConstraintsToDDL(AnnotationConfiguration.java:429)
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:403)
    at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)
    at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1449)
    at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1077)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:275)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:359)
    ... 4 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)`enter code here`
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:95)
    ... 13 more
4

2 に答える 2

0

pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">

    <!-- POM file generated with GWT webAppCreator -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pac</groupId>
    <artifactId>projetA</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>GWT Maven Archetype</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.5.1</gwtVersion>
        <springframeworkVersion>3.2.3.RELEASE</springframeworkVersion>
        <org.hibernate.version>3.5.1-Final</org.hibernate.version>
        <!-- <tomcat.webport>8082</tomcat.webport> <tomcat.ajpport>8182</tomcat.ajpport> 
            <tomcat.context>/parent</tomcat.context> -->
        <!-- GWT needs at least java 1.5 -->
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.0.1.Final</version>
 </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${org.hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>${org.hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${org.hibernate.version}</version>
        </dependency>

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

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

        <!-- Apache log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

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

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframeworkVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${springframeworkVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springframeworkVersion}</version>
        </dependency>





    </dependencies>

    <build>
        <!-- Generate compiled stuff in the folder used for developing mode -->
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

        <plugins>

            <!-- GWT Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.5.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test</goal>
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
                    documentation at codehaus.org -->
                <configuration>
                    <runTarget>projetA.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                    <i18nMessagesBundle>com.pac.projetA.client.Messages</i18nMessagesBundle>
                </configuration>
            </plugin>

            <!-- Copy static web files before executing gwt:run -->
            <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.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.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> 
                <version>2.0</version> <configuration> <path>${tomcat.context}</path> <port>${tomcat.webport}</port> 
                <ajpPort>${tomcat.ajpport}</ajpPort> <systemProperties> <JAVA_OPTS>-XX:MaxPermSize=256m</JAVA_OPTS> 
                </systemProperties> </configuration> </plugin> -->

        </plugins>
    </build>

</project>
于 2013-10-10T09:55:28.320 に答える
0

プロジェクトに hibernate-validator を追加する必要があります。

http://www.hibernate.org/subprojects/validator/download

log4j の警告を取り除きたい場合は、log4j.properties ファイルを追加する必要があります。

これを削除します。これは不要であり、ほぼ確実にエラーを引き起こしています。以前のコメントが表示された場合は、これを削除することをお勧めします。これは単なるインターフェース バインディングであり、jsr303 検証 API の実装コードではありません。Hibernate はこれを最初に確認しており、検証に hibernate-validator ライブラリを使用していません。

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>test</scope>
    </dependency>
于 2013-10-09T20:59:30.587 に答える