重新部署后的DataSource context.lookup

时间:2016-03-11 22:48:50

标签: java hibernate weblogic12c redeploy

在weblogic和hibernate中搜索我的问题后,我发现问题发生在jndi查找中,当你安装应用程序时,它运行正常但是当你重新部署应用程序时会发生这种情况:

javax.naming.NameNotFoundException: Unable to resolve 'ds_c719_002'. Resolved ''; remaining name 'ds_c719_002'

我的配置文件(我使用java配置)

    @Bean 
    public DataSource getDatasourceConfiguration() {
        System.out.println("empezando a buscar jndi-------------");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e1) {

        }
     final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
     dsLookup.setResourceRef(true);
     Hashtable<String, String> h = new Hashtable<String, String>(7);
     h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); 

     InitialContext context=null;
    try {
        context = new InitialContext(h);
    } catch (NamingException e) {
        log.error(e);

    }
     DataSource dataSource;
    try {   
        dataSource = (javax.sql.DataSource) context.lookup("ds_c719_002");      
        this.ds=dataSource;
        context.close();
        return dataSource;
    } catch (NamingException e) {
        log.error(e);

    }
return null;
 }

此致

0 个答案:

没有答案
相关问题