How to configure Servlet on Tomcat Server and fix javax.naming.NameNotFoundException?

672 views Asked by At

Recently I deployed an app to Tomcat Server. It's not working because the app can't find the Servlet. I thought the servlet-class in web.xml was okay but apparently the syntax/mapping is wrong since they cant find it...

web.xml

<servlet>
        <servlet-name>ControllerServlet</servlet-name>
        <servlet-class>controller.ControllerServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

catalina.log

INFO myapp.com-startStop-2 org.apache.catalina.startup.HostConfig - Deployment of web application archive /home/username/tomcat/webapps/myapp.com/ROOT.war has finished in 442 ms
INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.startup.HostConfig - Reloading context []
INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.StandardContext - Reloading Context with name [] has started
INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.ContainerBase.[Catalina].[myapp.com].[/] - Marking servlet ControllerServlet as unavailable
ERROR ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.ContainerBase.[Catalina].[myapp.com].[/] - Servlet  threw load() exception
javax.naming.NameNotFoundException: Name [controller.ControllerServlet/categoryFacade] is not bound in this Context. Unable to find [controller.ControllerServlet].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
    at org.apache.catalina.core.DefaultInstanceManager.lookupFieldResource(DefaultInstanceManager.java:603)
    at org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:491)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:174)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4923)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5209)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3775)
    at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1307)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1290)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1474)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:280)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1141)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349)
    at java.lang.Thread.run(Thread.java:745)
1

There are 1 answers

2
user207421 On BEST ANSWER

It's not working because the app can't find the Servlet.

Wrong.

javax.naming.NameNotFoundException: Name [controller.ControllerServlet/categoryFacade] is not bound in this Context. Unable to find [controller.ControllerServlet].

It can't find the name controller.ControllerServlet in the naming resources Somewhere you are using java:comp/.../controller.ControllerServlet/categoryFacade.

I suggest you look into where you are using categoryFacade for a start.