We are using weblogic version 12C. Steps to reproduce the issue: -
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?
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.
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.
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.
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"); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With