0

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

Xiul
  • 93
  • 1
  • 2
  • 7

1 Answers1

0

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.

Xiul
  • 93
  • 1
  • 2
  • 7
  • After solving this problem a new one was found: "javax.management.InstanceAlreadyExistsException: Catalina:type=DataSource,class=javax.sql.DataSource" and then I added "factory = “org.apache.tomcat.jdbc.pool.DataSourceFactory”" to in global at server.xml file and it works like answered here: [link](https://stackoverflow.com/questions/28295503/migration-to-tomcat-8-instancealreadyexistsexception-datasource) – Xiul Jul 10 '19 at 22:04