0
votes

When I tried to deploy an spring boot application from STS (eclipse) to a tomcat 9 container (embedded server was turn off excluded from pom) using JNDI it fails with the following message:

"javax.naming.NameNotFoundException: Name [jdbc/Database] is not bound in this Context. Unable to find [jdbc]."

I have done a few things trying to solve it, but problem remains:

My application spring configure is:

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    application.profiles("production");
    return application.sources(Application.class);
}

public static void main(String[] args) throws Exception {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
    builder.headless(false);
    builder.profiles("production");
    builder.web(WebApplicationType.NONE);
    builder.run(args); }

And datasource config is: JNDI Datasource creation source code Image

I have tried other possible solutions (like creating context.xml in META-INF dir of app) but nothing works until now, same error is raised: Error Image

1

1 Answers

0
votes

Problem was a THIRD place with configuration files in eclipse STS exists and is located in my environment at: .metadata.plugins\org.eclipse.wst.server.core\tmp0\conf , I copy context.xml and server.xml configuration like the images and problem was solved.