Zk框架6.5.2与Hibernate 4.2.3 Final的兼容性

时间:2013-08-07 16:10:53

标签: hibernate zk

我正在尝试使用ZK和hibernate开发Web应用程序。但是当我运行tomcat服务器时,我在服务器上收到以下错误。

SEVERE: Failed to invoke class org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener
java.lang.ExceptionInInitializerError
    at org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:126)
    ....
    ....
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
    at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:97)
    ....
    ....
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
    at org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:119)
    ... 22 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 28 more

我的Hibernate配置文件的一部分:

<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/testdta</property>
        <property name="connection.username">root</property>
        <property name="connection.password">password</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="connection.pool_size">1</property>
        <property name="current_session_context_class">thread</property>
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">update</property>

        <mapping classes over here... />

    </session-factory>
</hibernate-configuration>

我的zk.xml文件:

    <zk>
    <!-- Hibernate SessionFactory life cycle -->
    <listener>
        <description>Hibernate SessionFactory life cycle</description>
        <listener-class>org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener</listener-class>
    </listener>

    <zk>
    <listener>
        <listener-class>org.zkoss.reference.developer.hibernate.web.OpenSessionInViewListener</listener-class>
    </listener>
</zk>

    <!-- Hibernate OpenSessionInView life cycle -->

    <device-config>
        <device-type>ajax</device-type>
        <timeout-uri>/timeout.zul</timeout-uri><!-- An empty URL can cause the browser to reload the same URL -->
    </device-config>
</zk>

pom.xml上列出的Hibernate依赖项

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.2.3.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.1.Final</version>
        <classifier>tests</classifier>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.0.CR2</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.4</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.10</version>
    </dependency>

有没有人有任何线索?

0 个答案:

没有答案