The Meaning of Noinitialcontextexception Error

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



Leave a reply



Submit