How to get the deployed JNDI Namespaces in WAS
The people in enterprise applications would have definitely got their hands dirty in dealing with a buzzword called ‘components’. As a component, it has to be searched first and upon successful return of its whereabouts, a reference to it has to be returned to the caller which becomes the first step of success to the programmer who is in need of it.
So, how can you search for a component? Obviously, with some of its properties that helps to identify the components uniquely in the arena where its deployed. Its up to the programmer to be aware of the correct JNDI name (Java Naming and Directory Interface) which helps to achieve the binding of the component with its unique name.
In case of Application Servers they may have some components deployed by themselves and they let the users make use of it with the enhancement support if required. Is there a way to find out all the components deployed and their JNDI names as well?
Well, i am not going to give the way for ‘n’ number of application servers available in the market except ‘WAS’ (IBM’s WebSphere Application Server). Probably, a later time i may be able to consolidate if i get a chance to try with other application servers.😉
Here you go for WAS….
(i) Start your WebSphere Application Server (this you can achieve it by going to the ‘bin’ directory of ‘ApplicationServerRootInstallationDirectory’ and then double click on the batch file (in case of Windows, it would be “.bat” and in case of Unix like OS, it would be “.sh” [meaning a shell script]) named ‘startServer’.
Other way is you can directly go to the particular bin directly in the command prompt or shell (based on the OS) and then execute the batch file. This saves you in retaining the window. In the previous scenario where you just double click on the batch / script file the window may get vanished once the server is started. This holds for other Web Servers like Tomcat as well.
(ii) Wait for sometime till the application server is started and ready to listen. Usually it will take a couple of minutes to get started (without errors, obviously ;-))
(iii) Once the App. Server is started, issue the following command in the command prompt [if you have just double clicked on the executable batch/script file, you have to go to command prompt and navigate to the ‘bin’ directory].
“dumpNameSpace.bat -port <port_number>”
Usually the port number would be “2809” until and unless it is overridden. The command fetches you the list of components and their JNDI names. You can make use of it by redirecting it to a file in the command prompt like
“C:\IBM\WebSphere\AppServer\bin>dumpNameSpace.bat -port 2809 > namespace.txt”
The redirection symbol (the ‘greater than’ arrow mark in Windows OS) tells the OS to redirect the output of the previous command (dumpNameSpace.bat) to the next resource which is nothing but the file in our case and its name is “namespace.txt“. It will be saved in the current directory where this dumpNameSpace command is executed.