Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Accessing JNDI resources from RAP
Accessing JNDI resources from RAP [message #1743977] Wed, 21 September 2016 05:11 Go to next message
Eclipse UserFriend
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
Re: Accessing JNDI resources from RAP [message #1744213 is a reply to message #1743977] Fri, 23 September 2016 07:45 Go to previous messageGo to next message
Eclipse UserFriend
Sorry,
we discovered that this is a problem specific for WebShpere (tested with version 8.5.5 both z/OS and Windows).
Tomcat, for instance, is working right!

Anyone has experience using JNDI with RAP on WebSphere?

Thank you very much
Vincenzo
Re: Accessing JNDI resources from RAP [message #1744346 is a reply to message #1744213] Mon, 26 September 2016 04:41 Go to previous messageGo to next message
Eclipse UserFriend
You probably need to put the code that lookup jndi in a runnable and execute that runnable with org.eclipse.rap.rwt.RWT.requestThreadExec(Runnable) to come back in the app server request thread
Re: Accessing JNDI resources from RAP [message #1744419 is a reply to message #1744346] Mon, 26 September 2016 14:56 Go to previous message
Eclipse UserFriend
Arnaud,
thank you! thank you!
You can't imagine how much we struggled to find a solution.
We just didn't know how to get the right thread.
It works great!
Thank you again
Vincenzo
Previous Topic:RAP 3.2
Next Topic:Create p2 repo that includes RAP
Goto Forum:
  


Current Time: Fri Jul 25 02:21:22 EDT 2025

Powered by FUDForum. Page generated in 0.73057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top