连接池数据源异常与hibernate c3p0重新部署weblogic12c战争 [英] Exception with connection pool-datasource redeploying weblogic12c war with hibernate c3p0

查看:370
本文介绍了连接池数据源异常与hibernate c3p0重新部署weblogic12c战争的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了hibernate和weblogic 12c和Oracle 11g的问题当我安装我的应用程序时,它运行正常,但是当我更新应用程序时,它会引发此问题:获取潜在资源时发生异常。将重试。 java.lang.NullPointerException Regards



Hibernate属性:

  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 =验证

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


解决方案

在java配置文件中使用destroyMethod =将会修正bug SPR-13022:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ @Bean name =dataSource,destroyMethod =)
public DataSource getDatasourceConfiguration(){
System.out.println(empezando a buscar jndi ------------- );
尝试{
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;
尝试{
context = new InitialContext(h);
dataSource =(javax.sql.DataSource)context.lookup(ds_c719_002);
this.ds = dataSource;
context.close();
返回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);



$ b finally {
try {
context.close();}
catch(Exception e) {
e.printStackTrace();
}
//发生故障
}
返回null;


$ b @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});
返回asfb;


$Be
public SessionFactory sessionFactory(){
return sessionFactoryBean()。getObject();

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


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

解决方案

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

这篇关于连接池数据源异常与hibernate c3p0重新部署weblogic12c战争的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆