0
votes

I'm deploying a Spring boot application on WebLogic 12c.

Without Jndi datasource all works fine. I tried to configure on WebLogic a datasource with name "jdbc/MyDataSource" and on my application I setted the propertie like that:

spring.datasource.jndi-name=jdbc/MyDataSource

But, when I deploy my web app I receive the following error:

weblogic.application.ModuleException: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.MyDataSource' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/MyDataSource'

I tried also the following properties configuration without success:

spring.datasource.jndi-name=java:comp/env/jdbc/MyDataSource

spring.datasource.jndi-name=java:/jdbc/MyDataSource

spring.datasource.jndi-name=java:jdbc/MyDataSource

My maven configuration:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath />
</parent>

My Spring App Configuration:

@EnableSwagger2

@ComponentScan({ "com.ws.repository", "com.ws.service", "com.ws.controller" })

@EntityScan("com.ws.entity")

@EnableJpaRepositories(basePackages = "com.ws.repository")

public class MyServiceApplication {
...
}

Expected:

I want to use the same jndi datasource because I want to deploy many services that use just one datasource

2

2 Answers

1
votes

I solved modifying the servers destination (all, including AdminServer) of the datasource and saving the configuration

1
votes

Try the default DataSource, and set the lookup name(java:comp/DefaultDataSource), and check if it works.

I have an example using Spring with Wildfly, all JNDI names(Datasource, JMS, Java Mail, EntityManagerFactory, etc) are working well.