我的生产环境异常

时间:2015-12-09 14:03:02

标签: mysql jpa jdbc glassfish ejb

大家好,我的项目已处于运营阶段,但问题非常严重。

我的运行环境是:

GlassFish4.1.1,jpa(2.1)/ hibernate(4.3.5.Final),jta,EJB3.1

连接池图片: enter image description here enter image description here

Mysql驱动程序:mysql-connector-java-5.1.23-bin.jar

JDBC资源:jdbc / pmsQuery

JDBC连接池:pmsQueryPool

JPA配置文件:

  <persistence-unit name="pmsQueryPU" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>jdbc/pmsQuery</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
           <property name="hibernate.query.substitutions" value="true=1, false=0"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.hbm2ddl.auto" value="none"/>
            <property name="hibernate.jdbc.batch_size" value="1000"/>
            <property name="hibernate.order_inserts" value="true"/>
            <property name="hibernate.order_updates" value="true"/>
            <property name="hibernate.connection.characterEncoding" value="UTF-8" />
            <property name="hibernate.current_session_context_class" value="jta"/> 
        </properties>
    </persistence-unit>

JAVA CODE:

@ApplicationScoped
public class EntityManagerProvider {


    @PersistenceContext(unitName = "pmsQueryPU")
    private EntityManager pmsQueryPu;



    @Produces
    @PmsQueryPU
    public EntityManager createPmsQueryEntityManagedr() {
        return pmsQueryPu;
    }

protected void closeQueryEntityManager(@Disposes @PmsQueryPU EntityManager pmsQueryPu) {
        if (pmsQueryPu.isOpen()) {
            pmsQueryPu.close();
        }
    }

时不时出现以下异常:

  Caused by: org.hibernate.exception.GenericJDBCException: Could not open connection

    Caused by: javax.resource.ResourceException: This pool is not registered with the runtime environment : pmsQueryPool
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:667)
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getConnection(ConnectorConnectionPoolAdminServiceImpl.java:1627)
    ... 149 more
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: This pool is not bound in JNDI : pmsQueryPool
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.obtainManagedConnectionFactory(ConnectorConnectionPoolAdminServiceImpl.java:1099)
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.obtainManagedConnectionFactory(ConnectorConnectionPoolAdminServiceImpl.java:995)
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:660)
    ... 150 more
Caused by: javax.naming.NamingException: Lookup failed for '__SYSTEM/pools/pmsQueryPool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: pmsQueryPool not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.glassfish.resourcebase.resources.naming.ResourceNamingService.lookup(ResourceNamingService.java:238)
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getConnectorConnectionPool(ConnectorConnectionPoolAdminServiceImpl.java:882)
    at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.obtainManagedConnectionFactory(ConnectorConnectionPoolAdminServiceImpl.java:1015)
    ... 152 more
Caused by: javax.naming.NameNotFoundException: pmsQueryPool not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:208)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:208)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:114)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:478)
    ... 158 more
]]

0 个答案:

没有答案