I am trying to upgrade from Spring Boot 2.2.4.Release to 2.6.6. I have a embedded tomcat server configured in older version of the Spring boot 2.2.4 which works perfectly fine.
@override
protected TomcatWebserver getTomcatWebServer (Tomcat tomcat) {
System.setProperty("catalina.useNaming","true");
tomcat.enableNaming();
return super.getTomcatWebServer(tomcat);
}
@Override
protected void postProcessContext(Context context){
context.getnamingResources().addResource();
}
private ContextResource testDBResource(){
ContextResource resource = ContextResource();
resource.setName("jdbc/testDatasource");
resource.setType(javax.sql.Datasource.class.getName());
resource.setProperty("factory",
com.zaxxer.hikari.HikariJNDIFactory.class.getName());
resource.setProperty("url",..);
resource.setProperty("username",..);
resource.setProperty("password",..);
}
So my TomcatServletWebserverFactory is configured is like above. I have left few configurations for brevity. This was absolutely working fine until I shifted to 2.6.6 version.
I do lookup like.
InitialContext jndiContext = new InitialContext();
dataSource = (DataSource)jndiContext.lookup("java:comp/env/jdbc/testDatasource");
Then I get the NamingException in 2.6.6.
In 2.2.4.Release I used to get HikariDataSource (testDataSource) when I print the datasource.
Please let me know I have to do any more configurations for 2.6.6 version.