0

I'm having a problem with hibernate and weblogic 12c, and Oracle 11g When I install my app it runs correctly, but when I update the app it throws this: An exception occurred while acquiring a poolable resource. Will retry. java.lang.NullPointerException Regards

Hibernate properties:

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.show_sql=true 
hibernate.generate_statistics=false
hibernate.use_sql_comments=false
hibernate.debugging=false
hibernate.hbm2ddl.auto=validate

hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=300
hibernate.c3p0.max_statements=50
hibernate.c3p0.idle_test_period=3000
user3272931
  • 45
  • 10
  • You have 10gdialect in the config for 11g database. What do you mean by install app and update app? Please post complete logs and also the full configuration and libraries if using any. – Zeus Mar 10 '16 at 17:29
  • Hi zeus, thanks for answering, when I firs install my App, it runs perfectly, when i update it in weblogic 12c, it throws An exception occured while acquiring a poolable resource. will retry: null point exception – user3272931 Mar 10 '16 at 17:36
  • when you say update , you mean redeploy on the WebLogic ? maybe you are not closing a connection factory/ context or maybe you application isnt stopped properly – AntJavaDev Mar 10 '16 at 19:39
  • Hi AntJavaDev, I mean redeploy, that is correct, Is a datasource from weblogic, Im closing the connection via de @PreDestroy: PreDestroy public void freeDatasource() { try { System.out.println("---------"+ds.getConnection().isClosed()); ds.getConnection().close(); System.out.println("-------"+ds.getConnection().isClosed()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } – user3272931 Mar 10 '16 at 22:40

1 Answers1

0

Using the destroyMethod="" on the java config will make the bug SPR-13022 corrected:

    @Bean (name="dataSource", destroyMethod="")
    public DataSource getDatasourceConfiguration() {
        System.out.println("empezando a buscar jndi-------------");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {

        } 

     Hashtable<String, String> h = new Hashtable<String, String>();
     h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); 

      InitialContext context=null;

     DataSource dataSource = null;
    try {
        context = new InitialContext(h);
        dataSource = (javax.sql.DataSource) context.lookup("ds_c719_002");      
        this.ds=dataSource;
        context.close();
        return dataSource;
    }catch(NamingException e){

        log.error(e);
        try { 
            dataSource = (javax.sql.DataSource) context.lookup("java:comp/env/ds_c719_002");
        } catch (NamingException e1) {
 System.out.println("--------ups----");
 e1.printStackTrace();
 System.exit(1);
        }


    }
      finally {
            try {
                context.close();}
         catch (Exception e) {
             e.printStackTrace();
         }
              // a failure occurred
            }
return null;
 }


    @Bean (name="sessionFactoryBean", destroyMethod="")
    public LocalSessionFactoryBean  sessionFactoryBean()
    {

        LocalSessionFactoryBean  asfb = new LocalSessionFactoryBean ();
        asfb.setHibernateProperties(getHibernateProperties());
         asfb.setDataSource(getDatasourceConfiguration());
         asfb.setPackagesToScan(new String[]{"mx.com.banamex.tdc.modelo"});
        return asfb;
    }

    @Bean 
        public SessionFactory sessionFactory() { 
            return sessionFactoryBean().getObject(); 
        }

Bug documentation: https://jira.spring.io/browse/SPR-13022

user3272931
  • 45
  • 10