21

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?

Xavi López
  • 27,550
  • 11
  • 97
  • 161
mittalpraveen
  • 481
  • 3
  • 13
  • This same question was just asked right before yours: http://stackoverflow.com/questions/19158334/shutting-down-spring-application-makes-jndi-name-for-datasource-go-away-from-jdb Your datasource is probably being shutdown and needs to be restarted. – Display Name is missing Oct 03 '13 at 15:04
  • Thanks. But is there a way to avoid this shutdown of datasource as everytime we deploy new version of EAR, we are forced to start the datasource again. – mittalpraveen Oct 03 '13 at 16:58

2 Answers2

38

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");
}
Scott Leonard
  • 746
  • 7
  • 19
  • but why does it work correctly when we use XML-based context, is there different implementation for XML-based and Java-based context loading? – Eugene Stepanenkov Dec 17 '14 at 17:21
  • @EugeneStepanenkov - We saw the same thing. We had no problem with xml, just Java config, and just on certain Weblogic servers. My assumption has always been that the implementation was slightly different in Java config. It is a long time since I worked on this project, and I have switched companies, so I am afraid I can't refer to the code I worked this out on. This has become a non-issue for me, as we try to keep services small at my new organization. We tend to deploy microservices using spring boot or docker rather than a monolithic, always on container server like Weblogic. – Scott Leonard Dec 18 '14 at 02:39
  • 5
    I wish I knew where to start googling 3 hrs ago... Thanks for this; immensely helpful! – wholevinski Apr 06 '15 at 13:53
  • 1
    Note at first this did not fix my problem even after adding destroyMethod. Then I deleted all weblogic cache/tmp files, refreshed project/maven, and restarted weblogic, and then this fix worked. – Kt Mack Oct 09 '17 at 15:44
  • 1
    I spent a few hours investigating why my JNDI name had disappeared on WLS 12c, but this answer saved me many more hours... thanks! – Kevin Hooke Oct 18 '17 at 23:51
  • Just saved my life, thanks, there was not such problem with Spring 4.2.x + WLS 12.1 but Spring 5.1.x + WLS 12.2 caused this problem for me. – Amir Pashazadeh May 12 '19 at 04:16
-2

WebLogic Server: Most Recent Configuration Changes get Rolled Back after an Admin Server Restart (Doc ID 1479592.1) To BottomTo Bottom

In this Document Symptoms Cause Solution APPLIES TO:

Oracle Weblogic Server - Version 9.2.3 and later Information in this document applies to any platform. SYMPTOMS

The most recent domain configuration changes get rolled back after an admin server restart.

After setting debug level logging, you can also see the following messages in the server logs at the time of the issue:

<> <000000>

ervers/domain_bak/config_prev_bak' to: /data/bea92/user_projects/domains/ko_webapp_domain/servers/domain_bak/config_prev>

CAUSE

A config_bak directory is present in the domain_bak directory. This causes the previous config.xml to replace the current config.xml.

SOLUTION

Remove the config_Bak directory.

Mr D.
  • 1