What does javax.naming.NoInitialContextException mean?
It basically means that the application wants to perform some "naming operations" (e.g. JNDI or LDAP lookups), and it didn't have sufficient information available to be able to create a connection to the directory server. As the docs for the exception state,
This exception is thrown when no
initial context implementation can be
created. The policy of how an initial
context implementation is selected is
described in the documentation of the
InitialContext class.
And if you dutifully have a look at the javadocs for InitialContext, they describe quite well how the initial context is constructed, and what your options are for supplying the address/credentials/etc.
If you have a go at creating the context and get stuck somewhere else, please post back explaining what you've done so far and where you're running aground.
NoInitialContextException Error Tomcat
You need an initial context factory. For Tomcat it is org.apache.naming.java.javaURLContextFactory
:
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.naming.java.javaURLContextFactory");
Tomcat embedded: NoInitialContextException when trying to get a DataSource
Evidently I just needed Tomcat.enableNaming(), which isn't enabled by default.
Hibernate: javax.naming.NoInitialContextException (Component Mapping via Annotations)
I guess it's caused by the fact that you specified name
attribute in <session-factory>
, therefore Hibernate tries to bind SessionFactory
to JNDI under that name, but JNDI is not available in your environment. So, remove name
attribute.
Related Topics
How to Retrieve Value from Jtextfield in Java Swing
Autocomplete with Java , Redis, Elastic Search , Mongo
Differencebetween I++ & ++I in a for Loop
Using Gzip Compression with Spring Boot/Mvc/Javaconfig with Restful
Java Error Opening Registry Key
How to Find a Whole Word in a String in Java
Docker: Combine Multiple Images
How Do Java Interfaces Simulate Multiple Inheritance
How to Convert a String to Double in Java Using a Specific Locale
Layering Multiple Glasspane's in a Root Container
Bytebuffer.Allocate() VS. Bytebuffer.Allocatedirect()
How to Extract a Tar File in Java
Jsf Convertdatetime Renders the Previous Day
What Is Difference Between Crudrepository and JPArepository Interfaces in Spring Data JPA