Accessing JNDI resources from RAP [message #1743977] |
Wed, 21 September 2016 05:11  |
Eclipse User |
|
|
|
Hi,
we are having problems in accessing a JNDI resource (a JDBC DataSouce in particular) from RAP 3.0.2.
The code is the same that is working on a standard JSP page
Context inCtx;
DataSource ds;
try {
inCtx = new InitialContext();
Context enCtx = (Context) inCtx.lookup("java:comp/env");
ds = (DataSource) enCtx.lookup("jdbc/survey");
text.setText(""+ds);
} catch (NamingException e1) {
e1.printStackTrace();
text.setText(e1.getMessage());
}
and the JNDI resource is defined into web.xml
<resource-ref>
<res-ref-name>jdbc/survey</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
The error we are seeing in the log is the following:
javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name jdbc not found in context "java:comp/env".]
Should we configure something on the launch.ini?
Thank you very much.
Vincenzo
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.73057 seconds