Skip to content

Issue of Loading Invoker Servlet in Tomcat 6.0

April 22, 2011

I did some reading on Tomcat Invoker Servlet documentation and usage; and this all started when trying to fix an issue that I encountered when running a web application on tomcat from Eclipse IDE.

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(
at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.lang.SecurityException: Servlet of class org.apache.catalina.servlets.InvokerServlet is privileged and cannot be loaded by this web application
at org.apache.catalina.core.StandardWrapper.loadServlet(
at org.apache.catalina.core.StandardWrapper.load(
at org.apache.catalina.core.StandardContext.loadOnStartup(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardHost.start(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardEngine.start(
at org.apache.catalina.core.StandardService.start(
at org.apache.catalina.core.StandardServer.start(
at org.apache.catalina.startup.Catalina.start(
… 6 more

I spent a good amount of time figuring out this exception by checking CATALINA_HOME/conf/server.xml and CATALINA_HOME/conf/web.xml configuration files in tomcat. But the real culprit lies in CATALINA_HOME/conf/context.xml where the problem comes when privelges of Context is undefined.
1. context.xml: Context privileged=”true” reloadable=”true” and
2. Also this file may need to be copied to {Eclipse_Workspace}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf directory.

After making these changes the web app can be started on tomcat server from Eclipse IDE; and this time Invoker Servlet Exception should disappear.
Taken from Apache documentation: The default servlet-invoking servlet for most web applications, used to serve requests to servlets that have not been registered in the web application deployment descriptor.
So an invoker servlet can be used for teaching or testing purposes esp used to perform quick testing of servlet class by copying into the /classes directory of the web app.

In a nut shell, it is a dirty way of deploying servlets in mass. The proper way to deploy servlets is to configure each and every servlet in the application’s configuration file. This is tedious and problematic esp when developing or testing of servlets on fly.
Suppose that we have a context “test” with document base of “/home/xxx/workspace”, and we have created a servlet called “ServletTest.class”. With the Invoker Servlet enabled, we could simply drop our servlet into the application’s “WEB-INF/classes” (i.e., “/home/xxx/workspace/WEB-INF/classes/ServletTest.class”). Users can request this servlet via URL http://hostname:8080/test/servlet/ServletTest. In other words, the URL path “servlet” is mapped to “WEB-INF\classes”.
So the quick fix is to check the Context priveleges in context.xml and if that doesn’t work then copy the $CATALINA_HOME/conf/context.xml to the above specified location.


From → tech

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: