小编Ego*_*r B的帖子

无法从无处构建Hibernate SessionFactory异常

每次我想部署我的应用程序时,都会出现一个奇怪的错误.我正在使用IntelliJ IDEA 2016.3.

我的应用程序是使用JSF,EJB和JPA(Hibernate)的Java WEB应用程序.所有的库都是由IDEA下载的(在这个项目中没有Maven),所有依赖项都附带.war文件.我正在Windows 10上部署到TomEE 7.0.2.

以下是部署中涉及的配置文件:resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <Resource id="my_internet_shop_db" type="javax.sql.DataSource">
        JdbcDriver  com.mysql.jdbc.Driver
        JdbcUrl jdbc:mysql://localhost:3306/my_internet_shop?autoReconnect=true&amp;useSSL=true
        UserName root
        Password alpine
        validationQuery = SELECT 1
        JtaManaged true
    </Resource>
</resources>
Run Code Online (Sandbox Code Playgroud)

persistence.xml中

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">

    <persistence-unit name="my_internet_shop" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>my_internet_shop_db</jta-data-source>
        <class>Objects.Order.CartEntity</class>
        <class>Objects.User.ContactEntity</class>
        <class>Objects.Order.OrderEntity</class>
        <class>Objects.Product.ProductEntity</class>
        <class>Objects.Section.SectionEntity</class>
        <class>Objects.Service.ServiceEntity</class>
        <class>Objects.User.UserEntity</class>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/my_internet_shop"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.username" value="root"/>
            <property name="hibernate.connection.password" value="alpine"/>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

我的堆栈跟踪:

org.apache.openejb.OpenEJBException: …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa exception

6
推荐指数
1
解决办法
2624
查看次数

标签 统计

exception ×1

hibernate ×1

java ×1

jpa ×1