Search code examples
javaspringweblogicmybatisweblogic12c

datasource get lost on WebLogic 12.2 without any reason


We want to deploy an Spring based application on WebLogic 12.2.1.3. It uses a JDBC DataSource with jdbc/payeshws datasource.

When I deploy the application (using console or autodeploy folder), and start the application everything goes fine, but if I stop and then start the application in WebLogic console it throws an exception with root cause of:

Caused by: javax.naming.NameNotFoundException: Unable to resolve 'jdbc.payeshws'. Resolved 'jdbc'
    at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1292)
    at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:354)
    at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:227)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:527)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228)
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:527)
    at weblogic.jndi.internal.RootNamingNode.lookup(RootNamingNode.java:84)
    at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:307)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:435)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:156)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:156)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:105)
    at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:45)

If I start, stop the WebLogic again, it goes fine again.

I have even tried to restart the datasource (by enable and disabling it on AdminServer), but the problem still exists.

Our application was working on WebLogic 12.1 + Java 7 without any problem.

P.S. I'm not sure if it helps, but the application uses MyBatis for data-access.


Solution

  • I have found the answer here. I believe it is a bug of Spring 5.1.x, cause there was no such problem using Spring 4.2.x.

    I should add destroyMethod="" to datasource definition bean, as

    @Bean(destroyMethod = "")
    public DataSource jndiDataSource() {
        JndiDataSourceLookup lookup = new JndiDataSourceLookup();
        return lookup.getDataSource(datasourceJndi);
    }