Access additional data store via JNDI in uber jar deployment


I am trying to access an additional data store in application deployed as uberJar, in order to perform a SQL query.

When I run the application locally, I use JNDI to resolve the data source name, which is


where (name) is name of my database. And this is working fine.

However, when I build the application as uberJar, and define datasources in jetty-env.xml (overriden via -jettyEnvPath runtime parameter, an attempt to resolve the above JNDI name returns

java.lang.RuntimeException: Could not get data source from JNDI by name java:/comp/env/jdbc/lens
javax.naming.NameNotFoundException: null
	at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(
	at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(

I don’t know what is wrong. The data sources are defined in jetty-env.xml, and they are used by CUBA.
But I cannot access them via JNDI. Is it somehow related to context.xml?

Thanks for any support.

Best regards,

I can see that in WEB-INF/classes/ there is some definition like:


and there is no such definition for any of additional data stores.

Only in I have:

cuba.dataSourceJndiName_(name) = jdbc/(name)

but there is also an entry for primary data store in

cuba.dataSourceJndiName = jdbc/CubaDS

Hello Grzegorz,

I have the same issue - do you have already solved the problem?