【问题标题】:Exception with connection pool-datasource redeploying weblogic12c war with hibernate c3p0连接池数据源异常与休眠 c3p0 重新部署 weblogic12c 战争
【发布时间】:2016-06-25 16:34:33
【问题描述】:

我在使用 hibernate 和 weblogic 12c 和 Oracle 11g 时遇到问题,当我安装我的应用程序时,它运行正常,但是当我更新应用程序时,它抛出了这个问题:获取可池资源时发生异常。将重试。 java.lang.NullPointerException 问候

休眠属性:

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

【问题讨论】:

  • 您在 11g 数据库的配置中有 10gdialect。安装应用程序和更新应用程序是什么意思?请发布完整的日志以及完整的配置和库(如果有的话)。
  • 您好 zeus,感谢您的回答,当我首次安装我的应用程序时,它运行良好,当我在 weblogic 12c 中更新它时,它抛出获取可池资源时发生异常。将重试:空点异常
  • 当您说更新时,您的意思是在 WebLogic 上重新部署?也许您没有关闭连接工厂/上下文,或者您的应用程序没有正确停止
  • 嗨 AntJavaDev,我的意思是重新部署,这是正确的,是来自 weblogic 的数据源,我通过 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 自动生成的 catch 块 e.printStackTrace(); } }

标签: java hibernate weblogic12c redeploy


【解决方案1】:

在 java 配置中使用 destroyMethod="" 将纠正错误 SPR-13022:

    @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(); 
        }

错误文档: https://jira.spring.io/browse/SPR-13022

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-29
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    • 1970-01-01
    • 2013-04-25
    • 2016-09-16
    • 2013-08-20
    相关资源
    最近更新 更多