2017-07-27 94 views
0

我有一个Java EE应用程序运行在Wildfly 10服务器上,我看到这个错误后,我完成了数量作为最大池大小(换句话说,如果我有5集的最大池大小,我得到六号尝试这个错误)中提到的请求如何解决“无法解除绑定工厂从JNDI:org.hibernate.engine.jndi.JndiException?

这里是我的数据源配置:

<datasource jta="true" jndi-name="java:/jdbc/ITS" pool-name="ITS" use-ccm="true"> 
        <connection-url>jdbc:oracle:thin:@prodrac-s..(conn URL here)/connection-url> 
        <driver>oracle</driver> 
        <pool> 
         <min-pool-size>2</min-pool-size> 
         <max-pool-size>5</max-pool-size> 
         <prefill>true</prefill> 
        </pool> 
        <security> 
         <security-domain>encrypted-password-its</security-domain> 
        </security> 
        <validation> 
         <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/> 
         <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/> 
         <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/> 
        </validation> 
        <timeout> 
         <set-tx-query-timeout>false</set-tx-query-timeout> 
         <blocking-timeout-millis>0</blocking-timeout-millis> 
         <idle-timeout-minutes>30</idle-timeout-minutes> 
         <query-timeout>0</query-timeout> 
         <use-try-lock>0</use-try-lock> 
         <allocation-retry>0</allocation-retry> 
         <allocation-retry-wait-millis>0</allocation-retry-wait-millis> 
        </timeout> 
        <statement> 
         <share-prepared-statements>false</share-prepared-statements> 
        </statement> 
       </datasource> 

在我的数据源对于Oracle数据库我试图连接到最大池大小设置为5和最小池大小为2.我试图增加数量甚至20,但我得到的错误在21日尝试。

以下是完整的堆栈跟踪:

2017-07-26 18:13:18,446 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) - WFLYJCA0018: Started Driver service with driver-name = OnCore-FHIR.war_oracle.jdbc.OracleDriver_12_1 
2017-07-26 18:13:19,027 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 64) - WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'OnCore-FHIR.war#its' 
2017-07-26 18:13:19,497 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 64) - HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect 
2017-07-26 18:13:19,672 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 64) - Envers integration enabled? : true 
2017-07-26 18:13:21,070 INFO [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 64) - HHH000094: Bound factory to JNDI name: hib/oncore/sessions/ITS_FACTORY 
2017-07-26 18:13:22,370 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 61) - RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.company.OnCoreInterface.rest.resources.FhirRestExampleApplicationActivator$Proxy$_$$_WeldClientProxy 
2017-07-26 18:13:22,417 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 61) - WFLYUT0021: Registered web context: /OnCore-FHIR 
2017-07-26 18:13:22,463 INFO [org.jboss.as.server] (ServerService Thread Pool -- 33) - WFLYSRV0010: Deployed "OnCore-FHIR.war" (runtime-name : "OnCore-FHIR.war") 
2017-07-26 18:13:22,682 INFO [org.jboss.as] (Controller Boot Thread) - WFLYSRV0060: Http management interface listening on http://127.0.0.1:10993/management 
2017-07-26 18:13:22,682 INFO [org.jboss.as] (Controller Boot Thread) - WFLYSRV0051: Admin console listening on http://127.0.0.1:10993 
2017-07-26 18:13:22,682 INFO [org.jboss.as] (Controller Boot Thread) - WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 13623ms - Started 482 of 740 services (435 services are lazy, passive or on-demand) 
2017-07-26 18:15:34,813 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-5) - HHH000397: Using ASTQueryTranslatorFactory 
2017-07-26 18:20:53,378 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-21) - SQL Error: 0, SQLState: null 
2017-07-26 18:20:53,378 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-21) - javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/jdbc/ITS 
2017-07-26 18:22:16,472 INFO [org.jboss.as.server] (management-handler-thread - 4) - WFLYSRV0236: Suspending server with no timeout. 
2017-07-26 18:22:16,488 INFO [org.jboss.as.server] (Management Triggered Shutdown) - WFLYSRV0241: Shutting down in response to management operation 'shutdown' 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) - WFLYJCA0019: Stopped Driver service with driver-name = jtds 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) - WFLYJCA0019: Stopped Driver service with driver-name = OnCore-FHIR.war_oracle.jdbc.OracleDriver_12_1 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) - WFLYJCA0019: Stopped Driver service with driver-name = oracleXA 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) - WFLYJCA0019: Stopped Driver service with driver-name = h2 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) - WFLYJCA0010: Unbound data source [java:/jdbc/XA_SECURITY_CORE] 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) - WFLYJCA0019: Stopped Driver service with driver-name = sqlserver 
2017-07-26 18:22:16,503 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) - WFLYJCA0010: Unbound data source [java:/jdbc/XA_ADMINISTRATION_CORE] 
2017-07-26 18:22:16,519 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) - WFLYJCA0010: Unbound data source [java:/jdbc/XA_ADMIN_SELECT] 
2017-07-26 18:22:16,519 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) - WFLYJCA0010: Unbound data source [java:/jdbc/XA_SECURITY_SELECT] 
2017-07-26 18:22:16,519 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) - WFLYUT0022: Unregistered web context: /OnCore-FHIR 
2017-07-26 18:22:16,534 INFO [org.infinispan.eviction.impl.PassivationManagerImpl] (ServerService Thread Pool -- 74) - ISPN000029: Passivating all entries to disk 
2017-07-26 18:22:16,534 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) - WFLYJCA0019: Stopped Driver service with driver-name = sqlserverXA 
2017-07-26 18:22:16,534 INFO [org.infinispan.eviction.impl.PassivationManagerImpl] (ServerService Thread Pool -- 74) - ISPN000030: Passivated 0 entries in 2 milliseconds 
2017-07-26 18:22:16,534 INFO [org.wildfly.extension.undertow] (MSC service thread 1-3) - WFLYUT0019: Host default-host stopping 
2017-07-26 18:22:16,535 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 74) - WFLYCLINF0003: Stopped default-host cache from web container 
2017-07-26 18:22:16,568 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 74) - WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'OnCore-FHIR.war#its' 
2017-07-26 18:22:16,583 WARN [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 74) - HHH000374: Could not unbind factory from JNDI: org.hibernate.engine.jndi.JndiException: Error performing unbind [hib/oncore/sessions/ITS_FACTORY] 
    at org.hibernate.engine.jndi.internal.JndiServiceImpl.unbind(JndiServiceImpl.java:213) 
    at org.hibernate.internal.SessionFactoryRegistry.removeSessionFactory(SessionFactoryRegistry.java:124) 
    at org.hibernate.internal.SessionFactoryImpl.close(SessionFactoryImpl.java:1082) 
    at org.hibernate.jpa.internal.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:347) 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$2$1.run(PersistenceUnitServiceImpl.java:237) 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$2$1.run(PersistenceUnitServiceImpl.java:217) 
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667) 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$2.run(PersistenceUnitServiceImpl.java:262) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
    at org.jboss.threads.JBossThread.run(JBossThread.java:320) 
Caused by: javax.naming.NamingException: WFLYNAM0020: Could not resolve service service jboss.naming.context.java.hib.oncore.sessions.ITS_FACTORY 
    at org.jboss.as.naming.WritableServiceBasedNamingStore.unbind(WritableServiceBasedNamingStore.java:136) 
    at org.jboss.as.naming.NamingContext.unbind(NamingContext.java:318) 
    at org.jboss.as.naming.InitialContext$DefaultInitialContext.unbind(InitialContext.java:280) 
    at javax.naming.InitialContext.unbind(InitialContext.java:445) 
    at javax.naming.InitialContext.unbind(InitialContext.java:445) 
    at org.hibernate.engine.jndi.internal.JndiServiceImpl.unbind(JndiServiceImpl.java:210) 

我想明确地关闭,像这样的连接:

} catch (NamingException ne) { 
      System.out.println(ne.getMessage()); 

     } catch (SQLException ne) { 
      System.out.println(ne.getMessage()); 

     } catch (Exception e) { 
      System.out.println(e.getMessage()); 
     } 
     finally{ 
      try { 
       HibernateSession.closeITSSession(); 

      } catch (Exception ex) { 
       log.error("Exception trying to close the Hibernate ITS session: "+ ex); 
       System.out.println(ex.getMessage()); 
      } 
     } 

能有人帮吗?

+0

这很可能是容器应该处理Hibernate的生命周期。 –

回答

0

错误是由于部署目录中存在多个同名的WAR。