Advertisement
Guest User

Untitled

a guest
Sep 19th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.78 KB | None | 0 0
  1. 19:18:55,265 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 49) MSC000001: Failed to start service jboss.persistenceunit."myProject.war#myDS": org.jboss.msc.service.StartException in service jboss.persistenceunit."myProject.war#myDS": javax.persistence.PersistenceException: [PersistenceUnit: myDS] Unable to build EntityManagerFactory
  2. at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
  3. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_65]
  4. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_65]
  5. at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_65]
  6. at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
  7. Caused by: javax.persistence.PersistenceException: [PersistenceUnit: myDS] Unable to build EntityManagerFactory
  8. at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
  9. at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
  10. at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
  11. at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
  12. at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
  13. at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
  14. ... 4 more
  15. Caused by: org.hibernate.service.spi.ServiceException: Unable to instantiate specified multi-tenant connection provider [com.multitenancyprovider.MultiTenantProvider]
  16. at org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator.initiateService(MultiTenantConnectionProviderInitiator.java:97)
  17. at org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator.initiateService(MultiTenantConnectionProviderInitiator.java:43)
  18. at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:79)
  19. at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:201)
  20. at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:175)
  21. at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
  22. at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:228)
  23. at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
  24. at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
  25. at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
  26. at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
  27. at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
  28. at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
  29. at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
  30. at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
  31. ... 9 more
  32.  
  33. <?xml version="1.0" encoding="UTF-8"?>
  34. <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  35.  
  36. <persistence-unit name="myDS" transaction-type="JTA">
  37. <jta-data-source>java:/myDS</jta-data-source>
  38. <class>com.general.entities.AccountingDocumentType</class>
  39. <class>com.general.entities.AccountingOperation</class>
  40.  
  41. <properties>
  42. <property name="hibernate.multiTenancy" value="SCHEMA"/>
  43. <property name="hibernate.tenant_identifier_resolver" value="com.multitenancyprovider.SchemaResolver"/>
  44. <property name="hibernate.multi_tenant_connection_provider" value="com.multitenancyprovider.MultiTenantProvider"/>
  45. <property name="hibernate.show_sql" value="true" />
  46. <property name="hibernate.format_sql" value="true" />
  47. <property name="org.hibernate.type" value="debug" />
  48. <property name="hibernate.cache.use_second_level_cache" value="true" />
  49. <property name="hibernate.cache.use_query_cache" value="true" />
  50. <property name="hibernate.cache.infinispan.statistics" value="false" />
  51. <property name="hibernate.order_inserts" value="true"/>
  52. <property name="hibernate.jdbc.batch_size" value="20"/>
  53. <!-- Turn on entity and query cache statistics in the admin console -->
  54. <property name="hibernate.generate_statistics" value="false" />
  55. <!-- store entries in the cache in a more human friendly format - helps when interpreting logs -->
  56. <property name="hibernate.cache.use_structured_entries" value="false" />
  57. <!-- MultiTenancy -->
  58. </properties>
  59.  
  60. </persistence-unit>
  61. </persistence>
  62.  
  63. public class MultiTenantProvider implements MultiTenantConnectionProvider, ServiceRegistryAwareService {
  64.  
  65. private static final long serialVersionUID = 1L;
  66.  
  67. private DataSource dataSource;
  68.  
  69. public boolean supportsAggressiveRelease() {
  70. return false;
  71. }
  72.  
  73. public void injectServices(ServiceRegistryImplementor serviceRegistry) {
  74. try {
  75. final Context init = new InitialContext();
  76. dataSource = (DataSource) init.lookup("java:/MyDS");
  77. } catch (final NamingException e) {
  78. throw new RuntimeException(e);
  79. }
  80. }
  81.  
  82. @SuppressWarnings("rawtypes")
  83. public boolean isUnwrappableAs(Class clazz) {
  84. return false;
  85. }
  86.  
  87. public <T> T unwrap(Class<T> clazz) {
  88. return null;
  89. }
  90.  
  91. public Connection getAnyConnection() throws SQLException {
  92. final Connection connection = dataSource.getConnection();
  93. return connection;
  94. }
  95.  
  96. public Connection getConnection(String tenantIdentifier) throws SQLException {
  97. final Connection connection = getAnyConnection();
  98. try {
  99. connection.createStatement().execute("SET SCHEMA '" + tenantIdentifier + "'");
  100. } catch (final SQLException e) {
  101. throw new HibernateException("Could not alter JDBC connection to specified schema [" + tenantIdentifier + "]", e);
  102. }
  103. return connection;
  104. }
  105.  
  106. public void releaseAnyConnection(Connection connection) throws SQLException {
  107. try {
  108. connection.createStatement().execute("SET SCHEMA 'public'");
  109. } catch (final SQLException e) {
  110. throw new HibernateException("Could not alter JDBC connection to specified schema [public]", e);
  111. }
  112. connection.close();
  113. }
  114.  
  115. public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException {
  116. releaseAnyConnection(connection);
  117. }
  118. }
  119.  
  120. <datasource jta="false" jndi-name="java:/MyDS" pool-name="MyDS" enabled="true" use-ccm="false">
  121. <connection-url>jdbc:postgresql://localhost:5432/postgres</connection-url>
  122. <driver-class>org.postgresql.Driver</driver-class>
  123. <driver>postgresql-9.4.1209.jre6.jar</driver>
  124. <security>
  125. <user-name>postgres</user-name>
  126. <password>cyberlink</password>
  127. </security>
  128. <validation>
  129. <validate-on-match>false</validate-on-match>
  130. <background-validation>false</background-validation>
  131. </validation>
  132. <timeout>
  133. <set-tx-query-timeout>false</set-tx-query-timeout>
  134. <blocking-timeout-millis>0</blocking-timeout-millis>
  135. <idle-timeout-minutes>0</idle-timeout-minutes>
  136. <query-timeout>0</query-timeout>
  137. <use-try-lock>0</use-try-lock>
  138. <allocation-retry>0</allocation-retry>
  139. <allocation-retry-wait-millis>0</allocation-retry-wait-millis>
  140. </timeout>
  141. <statement>
  142. <share-prepared-statements>false</share-prepared-statements>
  143. </statement>
  144. </datasource>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement