Tomcat 8在启动时挂起

时间:2016-07-19 05:49:45

标签: java spring maven tomcat

我试图在Eclipse上启动我的Tomcat服务器,但它始终挂在日志上的这一行

14:44:52.467 INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default'

我甚至将超时设置为999秒仍然会超时。

我正在尝试使用Maven启动Spring Web应用程序。

所以我可以查明挂起的原因,Building JPA container EntityManagerFactory for persistence unit 'default'期间发生了什么?为什么它挂在那里?

这是我在Tomcat中的context.xml

<Resource name="jdbc/default" auth="Container" type="javax.sql.DataSource"
    maxActive="-1" maxIdle="-1" maxWait="-1" autoReconnect="true"
    username="example" password="example" driverClassName="com.mysql.jdbc.Driver"
    spring.datasource.testOnBorrow="true"
    spring.datasource.validationQuery="SELECT 1"
    url="jdbc:mysql://example:1106/example" />

<Resource name="jdbc/default_gathering" auth="Container" type="javax.sql.DataSource"
    maxActive="-1" maxIdle="-1" maxWait="-1" autoReconnect="true"
    username="example" password="example" driverClassName="com.mysql.jdbc.Driver"
    spring.datasource.testOnBorrow="true"
    spring.datasource.validationQuery="SELECT 1"
    url="jdbc:mysql://example:1106/admin" />

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>java:/comp/env/jdbc/default</non-jta-data-source>
    <properties>
        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.jdbc.batch_size" value="20" />
        <property name="hibernate.cache.use_query_cache" value="false" />
        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.cache.use_second_level_cache"
            value="false" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="jadira.usertype.autoRegisterUserTypes"
            value="true" />
    </properties>
</persistence-unit>

<persistence-unit name="default_gathering" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>java:/comp/env/jdbc/default_gathering</non-jta-data-source>
    <properties>
        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.jdbc.batch_size" value="20" />
        <property name="hibernate.cache.use_query_cache" value="false" />
        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.cache.use_second_level_cache"
            value="false" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="jadira.usertype.autoRegisterUserTypes"
            value="true" />
    </properties>
</persistence-unit>

调度-servlet.xml中

<jee:jndi-lookup id="defaultDS" jndi-name="jdbc/default"
    expected-type="javax.sql.DataSource" />

<jee:jndi-lookup id="defaultDS_gathering"
    jndi-name="jdbc/default_gathering" expected-type="javax.sql.DataSource" />

<!-- Session Factory Declaration -->
<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="defaultDS" />
    <property name="persistenceUnitName" value="default" />
    <property name="packagesToScan" value="com.default.*" />
</bean>

<bean id="entityManagerFactoryDataGathering"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="defaultDS_gathering" />
    <property name="persistenceUnitName" value="default_gathering" />
    <property name="packagesToScan" value="com.default.*" />
</bean>

<tx:annotation-driven />

<!-- Transaction Manager is defined -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<bean id="transactionManagerDataGathering" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactoryDataGathering" />
</bean>

0 个答案:

没有答案