Guest User

Untitled

a guest
Jan 31st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 KB | None | 0 0
  1. [2018-01-31T11:51:15.852-0200] [glassfish 4.0] [WARNING] [] [com.mchange.v2.resourcepool.BasicResourcePool] [tid: _ThreadID=264 _ThreadName=C3P0PooledConnectionPoolManager[identityToken->1hge39o9tic1bab1mwszpa|98964cd]-HelperThread-#1] [timeMillis: 1517406675852] [levelValue: 900] [[
  2. com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@9f55fed -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
  3. java.sql.SQLException: java.lang.IllegalStateException: This web container has not yet been started
  4. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
  5. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
  6. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
  7. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
  8. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
  9. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
  10. at com.mysql.jdbc.Util.handleNewInstance(Util.java:443)
  11. at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
  12. at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
  13. at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
  14. at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
  15. at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
  16. at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
  17. at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
  18. at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
  19. at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
  20. at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
  21. at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
  22. Caused by: java.lang.IllegalStateException: This web container has not yet been started
  23. at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1652)
  24. at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
  25. at java.lang.Class.forName0(Native Method)
  26. at java.lang.Class.forName(Class.java:191)
  27. at com.mysql.jdbc.Util.getInstance(Util.java:408)
  28. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
  29. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
  30. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
  31. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
  32. at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:807)
  33. at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
  34. at sun.reflect.GeneratedConstructorAccessor356.newInstance(Unknown Source)
  35. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  36. at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  37. at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
  38. ... 11 more
  39. ]]
  40.  
  41. <!-- ****Configurações de Conexão ao Banco de Dados **** -->
  42. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  43. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/meuBD?zeroDateTimeBehavior=convertToNull</property>
  44. <property name="hibernate.connection.username">root</property>
  45. <property name="hibernate.connection.password">123456</property>
  46.  
  47.  
  48. <!-- **** Propriedades do C3P0 - Pool de Conexão **** -->
  49. <property name="hibernate.c3p0.acquireIncrement">3</property>
  50. <property name="hibernate.c3p0.initialPoolSize">5</property>
  51. <property name="hibernate.c3p0.minPoolSize">5</property>
  52. <property name="hibernate.c3p0.maxPoolSize">50</property>
  53. <property name="hibernate.c3p0.maxIdleTime">5</property>
  54.  
  55. <property name="hibernate.c3p0.acquireRetryAttempts">50</property>
  56. <property name="hibernate.c3p0.numHelperThreads">20</property>
  57. <property name="hibernate.c3p0.checkoutTimeout">0</property>
  58. <property name="hibernate.c3p0.testConnectionOnCheckin">true</property>
  59.  
  60.  
  61. <!-- **** SQL Dialect **** -->
  62. <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  63.  
  64.  
  65. <!-- **** Gerenciamento do Contexto da Sessão **** -->
  66. <property name="current_session_context_class">thread</property>
  67.  
  68.  
  69. <!-- **** Desabilitando Cache de segundo nível **** -->
  70. <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
  71.  
  72. <!-- **** Mapeamento das Entidades **** -->
  73.  
  74. private static SessionFactory sessionFactory;
  75.  
  76. public static SessionFactory getFactory() {
  77. if (sessionFactory == null) {
  78. sessionFactory = HibernateUtil.buildSessionFactory();
  79. }
  80.  
  81. return sessionFactory;
  82. }
  83.  
  84. private static SessionFactory buildSessionFactory() {
  85. try {
  86. Configuration configuration = new Configuration().configure();
  87. StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();
  88. serviceRegistryBuilder.applySettings(configuration.getProperties());
  89.  
  90. ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
  91. SessionFactory session = configuration.buildSessionFactory(serviceRegistry);
  92. return session;
  93.  
  94. } catch (HibernateException ex) {
  95. System.err.println("Criação da SessionFactory failed." + ex);
  96.  
  97. throw new ExceptionInInitializerError(ex);
  98. }
  99. }
  100.  
  101. private final Class<Entidade> classe;
  102. private Transaction transaction = null;
  103. private SessionFactory sessionFactory = null;
  104.  
  105. @SuppressWarnings("unchecked")
  106. public GenericDAO() {
  107. this.classe = (Class<Entidade>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
  108. sessionFactory = HibernateUtil.getFactory();
  109. }
  110.  
  111. public void salvar(Entidade entidade) {
  112. try {
  113. transaction = sessionFactory.getCurrentSession().beginTransaction();
  114. sessionFactory.getCurrentSession().save(entidade);
  115. transaction.commit();
  116.  
  117. } catch (RuntimeException erro) {
  118. if (transaction != null) {
  119. transaction.rollback();
  120. }
  121. throw erro;
  122. }
  123. }
  124.  
  125. public void excluir(Entidade entidade) {
  126. try {
  127. transaction = sessionFactory.getCurrentSession().beginTransaction();
  128. sessionFactory.getCurrentSession().delete(entidade);
  129. transaction.commit();
  130.  
  131. } catch (RuntimeException erro) {
  132. if (transaction != null) {
  133. transaction.rollback();
  134. }
  135. throw erro;
  136. }
  137. }
  138.  
  139. public void editar(Entidade entidade) {
  140. try {
  141. transaction = sessionFactory.getCurrentSession().beginTransaction();
  142. sessionFactory.getCurrentSession().update(entidade);
  143. transaction.commit();
  144.  
  145. } catch (RuntimeException erro) {
  146. if (transaction != null) {
  147. transaction.rollback();
  148. }
  149. throw erro;
  150. }
  151. }
  152.  
  153. public List<Entidade> listar() {
  154. List<Entidade> resultado;
  155.  
  156. try {
  157. transaction = sessionFactory.getCurrentSession().beginTransaction();
  158.  
  159. Criteria consulta = sessionFactory.getCurrentSession().createCriteria(classe);
  160. resultado = consulta.list();
  161.  
  162. transaction.commit();
  163.  
  164. } catch (RuntimeException erro) {
  165. if (transaction != null) {
  166. transaction.rollback();
  167. }
  168. throw erro;
  169. }
  170. return resultado;
  171. }
  172.  
  173. @SuppressWarnings("unchecked")
  174. public Entidade buscar(Integer id) {
  175. Entidade resultado;
  176.  
  177. try {
  178. transaction = sessionFactory.getCurrentSession().beginTransaction();
  179.  
  180. Criteria consulta = sessionFactory.getCurrentSession().createCriteria(classe);
  181. consulta.add(Restrictions.idEq(id));
  182. resultado = (Entidade) consulta.uniqueResult();
  183.  
  184. transaction.commit();
  185.  
  186. } catch (RuntimeException erro) {
  187. if (transaction != null) {
  188. transaction.rollback();
  189. }
  190. throw erro;
  191. }
  192. return resultado;
  193. }
Add Comment
Please, Sign In to add comment