连接池数据源异常重新部署 weblogic12c war with hibernate c3p0
Exception with connection pool-datasource redeploying weblogic12c war with hibernate c3p0
我在使用 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
在 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();
}
我在使用 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
在 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();
}