Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring and looking up a simple String via JNDI in WebSphere

For the configuration of our applications we want to place some of the configuration in the application server.

We are currently using the WebSphere JNDI facility for looking up urls and datasources.

In addition we want to place simple Strings in the application server. We don't want to use the WebSphere "Enviroment variables".

Can the "Resource Environment" be used for such a purpose? If so, how can it be used?

We'd like to get the Strings with:

InitialContext ctx = new InitalContext();
String myString = (String)ctx.lookup("jndi/string/myString");

Are there any more simple alternatives?

We are using WebSphere Application Server 7.

like image 783
Udo Held Avatar asked Nov 24 '11 15:11

Udo Held


People also ask

How do we define JNDI in WebSphere?

The JNDI Name is the path to the DataSource object in the directory service. You must specify this same value as the -f argument in setRepo -t dbms -i initCtxFac -f filepath . Select the Component-managed Authentication Alias that you created in Configuring a JDBC Provider.

Where is JNDI name in WebSphere?

To view this administrative console page, click Applications > Application Types > WebSphere enterprise applications > application > EJB JNDI names.

How JNDI lookup works in Java?

The Java Naming and Directory Interface (JNDI) is a Java API for a directory service that allows Java software clients to discover and look up data and resources (in the form of Java objects) via a name. Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation.


1 Answers

I believe you can use Name Space Bindings for this (under Environment, Naming, Name Space Bindings.)

Blurb:

Name Space Bindings

Use this page to configure a name binding of a constant string value, an enterprise bean, a CORBA CosNaming Naming Context or CORBA leaf node object, or an object that can be looked up by using JNDI.

like image 184
McDowell Avatar answered Sep 30 '22 10:09

McDowell