Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 583
mittalpraveen Avatar asked Oct 03 '13 12:10

mittalpraveen


People also ask

What is JNDI tree in WebLogic?

Every WebLogic Server has a local JNDI tree, to which you bind Java EE resources such as the JDBC data sources, JMS connection factories, and so on.

What is WebLogic JNDI WLInitialContextFactory?

The WLInitialContextFactory creates initial contexts for accessing the WebLogic naming service. It can also be used to create a multitier connection to another naming service through a WebLogic Server.

How do I change DataSource in WebLogic?

In the Domain Structure tree, expand Services > JDBC and select Data Sources. Select the name of the data source that you want to restart and select the Targets tab. On the Target tab, clear the check box for each server or cluster on which you want to restart the data source. Click Save.


1 Answers

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"); } 
like image 78
Scott Leonard Avatar answered Sep 24 '22 16:09

Scott Leonard