• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Access servlet from subdirectory

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is my directory structure.

Tomcat home dir>webapps\lessons\WEB-INF \classes\examples\HelloClientServlet.class

and here is my web.xml
-------------------------------------------------------
<servlet>
<servlet-name>HelloClientServlet</servlet-name>
<servlet-class>examples.HelloClientServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloClientServlet</servlet-name>
<url-pattern>/servlet/examples.HelloClientServlet</url-pattern>
</servlet-mapping>
------------------------------------------------------------------
Now I run run Tomcat and try to access the URL
http://localhost:8083/lessons/servlet/examples.HelloClientServlet

It gives this ERROR:
-------------------------------------------------------------------------
javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)


root cause

java.lang.NoClassDefFoundError: examples/HelloClientServlet (wrong name: HelloClientServlet)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:539)

-------------------------------------------------------------------

Now here is the problem. I tried putting HelloClientServlet.class in classes directory and made appropriate changes to web.xml and it works.
But not in the subdirectory classes. I find it very strange. I feel there is no problem with my web.xml file. Am I am missing some configuration here.

Please give you inputs.

Thanks,
Rekha
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to use the invoker. It's probably (and properly) disabled.

Create a servlet mapping in your web.xml and use that mapping to activate the servlet.
 
rekha devan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By invoker do you mean in

tomcat_root>conf/web.xml

-----------------------------------------------------
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

==================

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>


-----------------------------------------------------------
These are uncommented only and also I have done Servlet-mapping in my web application specific web.xml. It is there in my previous posting.

But still does not work :-(
 
Bear Bibeault
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The invoker mapping and your mapping are in conflict since they both use the prefix servlet. Disable the invoker and use a prefix in your mapping other than /servlet.
[ February 08, 2006: Message edited by: Bear Bibeault ]
 
rekha devan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not follow what you are saying .

can you please write using those tags what you meant by prefix.

thanks,
Rekha
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic