Dear Team,


                While trying to port our application from WAS 8.5.5 to
tomcat 8.0.33, we have hit a roadblock and we are unable to proceed. Hence
requesting for your inputs.



Following is the scenario: we have  DataSourceManager class which looks for
datasource in the context as shown below.



Properties prop = *new* Properties();

                  prop.put("java.naming.factory.initial",
"org.apache.naming.java.javaURLContextFactory");

                  prop.put("java.naming.provider.url", “
rmi://localhost:1099”);



                  InitialContext context = *new* InitialContext(prop);

dataSource = (DataSource) context.lookup(“apl_datasource”);





Following code perfectly works well when code is run within the Tomcat
 container.
But we are unable to access the context remotely i.e from outside the
Tomcat container.

But this works fine in case of WAS when
“com.ibm.websphere.naming.WsnInitialContextFactory”
class is used.

While running a standalone client from a shell script, when inside
DataSourceManager class we do a context lookup for a data source and the
lookup fails with following exception.



javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/apl_datasource]
is not bound in this Context. Unable to find [java:comp].



It seems tomcat does not support remote access to its JNDI tree and
context initialized
is empty. Tomcat does have the data source in the context but it is only
accessible to the process running inside the containers and not accessible
to processes running outside the container. PFB the following link for your
reference.

                                                https://
stackoverflow.com/questions/744389/tomcat-what-is-the-
init-context-params-to-use-for-making-an-external-client-con



Kindly provide your inputs on 2 points

·         This link is for tomcat 5.5 and we are porting to tomcat 8. Has
scenario changed in tomcat8

·         Is there any other way to access the JNDI tree remotely by
standalone application.

·         Is the rmi protocol mentioned in provider url is supported by
tomcat, or we should change it to some another protocol.





Thanks and Regards,

Deepam Singla

Reply via email to