How to use a JNDI resource in Spring Boot Application running on extern Tomcat8

I have a spring boot web-application which is deployed as war file to a Tomcat8 Server.

This Tomcat 8 Server offers the connectivityService over JNDI.

If I consume this service in normal dynamic-web-application it works just fine with this:

Context ctx = null;
try {
    ctx = new InitialContext();
} catch (NamingException e1) {
    // TODO Auto-generated catch block
ConnectivityConfiguration configuration = null;
try {
    configuration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration");
} catch (NamingException e) {
    // TODO Auto-generated catch block

I register the resource in the web.xml with:


But if try to consume it in my Spring-Boot application it gives me this exception:

javax.naming.NameNotFoundException: Name [connectivityConfiguration] is not bound in this Context. Unable to find [connectivityConfiguration].

In my spring boot there is no web.xml, so how to register the resource?

I tried it to register it in the properties-file, but it gives me the same exception:


I can’t find a solution for my specific case.

I would really appreciate some guidance.