JimmyD
JimmyD

Reputation: 2759

No naming context bound to this class loader

I have created a Dynamic web project in Eclipse. When I try to run it on a local Tomcat from in Eclipse we are getting error:

No naming context bound to this class loader

I tried everything: running the application on another Tomcat version, another Eclipe version, ...

Can someone help me with this? This is currently a blocker for further developments because of no debug capabilities.

The full error log is:

WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/PCT_TO_CPQ]] so no cleanup was performed for that container
javax.naming.NamingException: No naming context bound to this class loader
    at org.apache.naming.ContextBindings.getClassLoader(ContextBindings.java:268)
    at org.apache.catalina.deploy.NamingResourcesImpl.cleanUp(NamingResourcesImpl.java:993)
    at org.apache.catalina.deploy.NamingResourcesImpl.stopInternal(NamingResourcesImpl.java:976)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5492)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:264)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:856)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1038)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:856)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1038)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:585)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:883)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:685)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)

Upvotes: 6

Views: 22793

Answers (5)

Rits Pro
Rits Pro

Reputation: 1

In my case on the servlet page the name I mentioned in the @WebServlet("/ServletName") was not the same as the class name.

Class name was CreatePage, but I forgot to change the same in @WebServlet("/ServletName").

It should be changed to match the class name: @WebServlet("/CreatePage")

Upvotes: 0

Robert Fornesdale
Robert Fornesdale

Reputation: 80

In my case, it was that I had TWO restcontrollers with the same urlPattern... like:

@WebServlet(urlPatterns = { "/ws/user/login", "/ws/user/logout" })

in two different controllers. This has led to the above error message.

These utils and frameworks would be so much better, if the developers would implement less confusing error messages! Spring and many of it's modules are full of these misleading errors. This makes it pretty hard for beginners to get into it.

Upvotes: 1

Pado
Pado

Reputation: 1637

I had, in my tomcat configuration, two modules: the actual model I wanted to run and another one I accidentally add. The second model was referring to a project that was "closed" in my workspace, this was causing the issue for me.

Try:

  • double-click on your server under the "Servers" tab in Eclipse
  • on the window that opens up go to "Modules" in the lower left corner
  • Remove the module(s) that you do not need
  • save

eventually clean your server and restart

Upvotes: 0

Tushar Khutale
Tushar Khutale

Reputation: 1

You have to ensure that.. your Dynamic Web Module Version is proper.

Go to:

  1. right click on project
  2. click Build path
  3. select Project Facts
  4. select Dynamic Web Module (Checkbox) with proper version

Upvotes: 0

Alien
Alien

Reputation: 15878

1.Try removing server and add it again.

2.Clean the project.

Upvotes: 3

Related Questions