Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlets w/ packages...  RSS feed

Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Java CLASSPATH business can be absolutely maddening sometimes.

I simply want to write and display a servlet (with a package) using Resin. I get an error when using packages but it works fine w/o using them.

I *really* need to define packages, this could be a big site w/ many servlets.

My servlet "" in my vir. directory's WEB-INF/classes directory:

My web.xml file, in the WEB-INF directory:

The Resin log is showing me this:

[03:46:05.312] com.caucho.config.LineConfigException: WEB-INF/web.xml:2: `com.scientifik.web.Router' is not a known servlet. Servlets belong in the classpath, often in WEB-INF/classes.

However, my classpath is set to:


Which is exactly correct, echoing the CLASSPATH shows but Resin obviously does not see it.

It is not an issue w/ using Resin w/ IIS as I can get servlets WITHOUT packages to compile w/o a single problem. If I were to remove the "package ..." line from the code and change the "servlet-class" tag in the web.xml file to <servlet-class>Router</servlet-class>, it compiles automatically and runs!

Any ideas?

Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Resin is like Tomcat, it totally ignores the environment CLASSPATH and uses its own rules to find classes.
If your servlet class is com.scientifik.web.Router then the compiled class MUST BE PLACED ACCORDINGLY!!!
This is all laid out in the servlet API documentation which you really really really need to get, read, and understand.
Download the API from here.

If you are getting a servlet to run without a package it may be due to that accursed "invoker" servlet - (read this FAQ here at the ranch).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!