Access additional data store via JNDI in uber jar deployment

Hello,

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

java:/comp/env/jdbc/(name)

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(ServiceInterceptor.java:127)
	at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

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,
Grzegorz

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

cuba.dataSourceJndiName=java:comp/env/jdbc/CubaDS

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

Only in app.properties I have:

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

but there is also an entry for primary data store in local.app.properties:

cuba.dataSourceJndiName = jdbc/CubaDS

Hello Grzegorz,

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

Thanks
Steven