Weblogic datasource disappears from JNDI tree

后端 未结 2 1608
小蘑菇
小蘑菇 2020-12-09 10:02

We are using weblogic version 12C. Steps to reproduce the issue: -

  1. Create the datasource.
  2. Deploy the application to weblogic.
  3. Application wor
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 10:26

    I had the same problem. Adding destroyMethod="" fixed it for me.

    Apparently if there is no destroyMethod, Spring tries to determine what the destroy method is. This is apparently causing the datasource to be closed and the JNDI key to be removed from the tree. Changing it to "" forces it to not look for a destroyMethod.

    @Bean(destroyMethod = "")
    public DataSource dataSource() throws NamingException{
        Context context = new InitialContext();
        return (DataSource)context.lookup("jdbc.mydatasource");
    }
    

提交回复
热议问题