Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Accessing JNDI resources from RAP
Accessing JNDI resources from RAP [message #1743977] Wed, 21 September 2016 09:11 Go to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 190
Registered: January 2012
Senior Member
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 11:45 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 190
Registered: January 2012
Senior Member
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 08:41 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 218
Registered: March 2010
Location: France
Senior Member
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 18:56 Go to previous message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 190
Registered: January 2012
Senior Member
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: Wed Feb 21 04:08:10 GMT 2018

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

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