Questions tagged [jndi]

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 objects via a name.

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 objects via a name. Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation. Additionally, it specifies a service provider interface (SPI) that allows directory service implementations to be plugged into the framework. It may make use of a server, a flat file, or a database; the choice is up to the vendor.

For additional info check:

3073 questions
28
votes
4 answers

Configure hibernate to connect to database via JNDI Datasource

Hi all I'm using Hibernate+Struts2+Tomcat6+Mysql as my J2EE framework. I've been using hibernate's built-in connection pooling mechanism but it turned out to be problematic where mysql closes it's connections after 8 hours. Anyway I googled around a…
SJ.Jafari
  • 1,236
  • 8
  • 27
  • 39
27
votes
4 answers

Junit Testing JNDI InitialContext outside the application server

Context context = new InitialContext(); dataSource = (DataSource) context.lookup("java:comp/env/jdbc/multiDS"); connection = dataSource.getConnection(); Please help me to mock the above code. Hi Tom Anderson I tried the below code @BeforeClass …
ravichandra
  • 273
  • 1
  • 4
  • 7
26
votes
7 answers

Initialcontext in a standalone Java program

I'm using a JNDI for creating connection pool. It works great in a web application. I believe the InitialContext is provided by the tomcat server. Context initContext = new InitialContext(); Context envContext =…
Satish Jonnala
  • 619
  • 3
  • 9
  • 21
25
votes
8 answers

Tomcat vs Weblogic JNDI Lookup

The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds". For development (localhost), we might be running Tomcat and when declared in the section of server.xml, Tomcat will hang JNDI datasources…
Luther Baker
  • 7,236
  • 13
  • 46
  • 64
23
votes
1 answer

Best practice to get EntityManagerFactory

What is the best approach to get EntityManagerFactory in web app(jsp/servlets)? Is this a good way When should EntityManagerFactory instance be created/opened?, or is it better to get it from JNDI, or something else?
Evgeni Dimitrov
  • 21,976
  • 33
  • 120
  • 145
23
votes
1 answer

What is the relationship between java:comp/env and java:global?

What is the relationship between java:comp/env and java:global (regarding 3.1 spec)? Seems like java:comp/env contains specific to EJB references. What means "specific" in this case?
Yamahar1sp
  • 510
  • 1
  • 6
  • 13
23
votes
2 answers

How to store string values in context.xml

I'd like to store connection URLs in a JNDI binding for my Tomcat application. Since Tomcat uses context.xml for JNDI resource defining, I need to figure out the propert way to store a String (or multiple strings for multiple connections) in…
user1768830
23
votes
2 answers

Differences of connection pool, jdbc and jndi

I need to know if my understanding on the above is correct. In a connection pool you set multiple connections with the use of java.sql.Datasource. In jdbc we directly specify the connection url and oracle.jdbc.driver.OracleDriver and it's always one…
Harshana
  • 7,297
  • 25
  • 99
  • 173
22
votes
6 answers

How do I connect to a Websphere Datasource with a given JNDI name?

I'm using Websphere Portal 7.0 and creating a portlet with RAD 8.0. My portlet is trying to make a db2 connection to a remote server. I wrote a java program locally to do a basic JDBC connection to the server and get records from a table. The code…
jason
  • 2,219
  • 5
  • 33
  • 66
22
votes
2 answers

Understanding JNDI

JNDI is like a map on steroids right? I use a key to find references to objects. Also, what is InitialContext? I don't seem to get the idea.
arg20
  • 4,893
  • 1
  • 50
  • 74
21
votes
4 answers

What does "javax.naming.NoInitialContextException" mean?

As the title suggests, what does "javax.naming.NoInitialContextException" mean in non technical terms? And what are some general suggestions to fix it? EDIT (From the console): javax.naming.NoInitialContextException: Need to specify class name in…
jdbcnewbie.
  • 839
  • 3
  • 8
  • 9
21
votes
5 answers

How do I lookup a JNDI Datasource from outside a web container?

I have the following environment set up: Java 1.5 Sun Application Server 8.2 Oracle 10 XE Struts 2 Hibernate I'm interested to know how I can write code for a Java client (i.e. outside of a web application) that can reference the JNDI datasource…
masotime
  • 506
  • 1
  • 3
  • 14
20
votes
10 answers

Connection cannot be cast to oracle.jdbc.OracleConnection

Why java.sql.Connection cannot be cast to oracle.jdbc.OracleConnection in code below? My main goal is to pass to Oracle connection new user name and save it in 'SESSION' table in for example 'osuser' column because I want to trace in DB user changes…
Roman
  • 1,121
  • 4
  • 23
  • 38
20
votes
6 answers

Setting up JNDI Datasource in jUnit

I am trying to set up some jUnit testing. Our database is connected by the server using JNDI. We have an xml describing the setup in root.xml. How do I set up jUnit to hook up to the database? I'd prefer to have it just read the the stuff off of…
Joe
  • 7,922
  • 18
  • 54
  • 83
20
votes
2 answers

javax.naming.CommunicationException: simple bind failed

When trying to connect to the LDAP server using a simple LDAP application I am getting an error which says "simple bind failed". I am assuming this is related to some sort of BIND. I have a bind property in one of the property file for a different…
misguided
  • 3,699
  • 21
  • 54
  • 96