mittalpraveen mittalpraveen - 1 year ago 191
Java Question

Weblogic datasource disappears from JNDI tree

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

  1. Create the datasource.

  2. Deploy the application to weblogic.

  3. Application works fine.

  4. Update the deployed ear with the new one.

  5. Application is not able to connect the datasource.

  6. Datasource not available in the JNDI tree.

We need to create either a new datasource everytime or save the datasource setting again.

Can someone please check and let me know if you know some solution for this?

Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download