• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

without using JNDI lookup Can i know what are the JNDI names specified in configuration xml file

I deployed ejb.jar in the application server;in the code without using context look up(JNDI lookup) Can i know what are the JNDI names specified  in configuration xml file;
0
chaitu chaitu
Asked:
chaitu chaitu
  • 7
  • 5
1 Solution
 
Mayank SAssociate Director - Product EngineeringCommented:
You could of course, specify ifs path and load it as a normal XML document using DOM or any other parser :-)
0
 
chaitu chaituAuthor Commented:
u mean parse the application server specific configuartion xml file;;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Yes. But why do you want to do this?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
chaitu chaituAuthor Commented:
my colleague has got that requirement ?Is there any other way??
0
 
Mayank SAssociate Director - Product EngineeringCommented:
None that I know of. Though it seems like a strange requirement for a production-project.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
If the requirement is to do it in J2SE (and not J2EE), then JNDI works with both:

http://www.javaworld.com/javaworld/jw-04-2002/jw-0419-jndi.html
0
 
chaitu chaituAuthor Commented:
above link works both for J2SE (standalone client) or J2EE;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Yes.
0
 
chaitu chaituAuthor Commented:
try {
           DocumentBuilderFactory dbf =    DocumentBuilderFactory.newInstance();
           DocumentBuilder db = dbf.newDocumentBuilder();
           Document doc = db.parse(new FileInputStream("c:/11111/jboss.xml"));
          Context context = new InitialContext();

            NodeList nodes = doc.getElementsByTagName("jndi-name");
            String x=null;
           
           for(int i=0;i<nodes.getLength();i++)
           {
             Node n= nodes.item(i).getFirstChild();
             System.out.println(n.getNodeValue());
             x=n.getNodeValue();
             context.bind(n.getNodeValue(), n.getNodeValue());

           }
           
       

        } catch (Exception ex) {
            System.out.println(ex);
        }
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Any errors?

Anyway make sure you close the FlieInputStream in a finally block.
0
 
chaitu chaituAuthor Commented:
now in the context i have binded all JNDI names.

then how to look up each JNDI name;;;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
You have already read them from the file. If you still want to get them from the context, you can use context.lookup ()
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now