This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat Servlet class not found issue  RSS feed

 
Michael Portman
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.

I've setup a Tomcat file server on linux ubuntu and when I create a test servlet I get a class not found exception!

My servlet code:



I've created WEB-INF/classes/evo/net/ to where the servlet is stored.

My web.xml file (WEB-INF/web.xml):



I've tried using annotations and without and still doesnt work. I've restarted server many times with no joy. Help appreciated.
 
Tim Moores
Saloon Keeper
Posts: 3888
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a typo:

evo.net.testServlet


public class servletTest extends HttpServlet
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you have the servlet mapped using the WebServlet annotation you don't need it in the web.xml.
Indeed it might confuse matters (as here).
 
Michael Portman
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i sorted the typo now im getting a new error:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means you are using two different versions of Java. Your Tomcat instance should be running the same version you are compiling with.
 
Michael Portman
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That means you are using two different versions of Java. Your Tomcat instance should be running the same version you are compiling with.


OK. My project designer is linux literate as I dont know how to use it. he's gonna sort it hopefully, if not ill post back
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: on Linux and other Unix-like OS's (MacOS for example), the command "which javac" will tell you where the Java compiler that you are using is. If you're using Maven or Ant, the JAVA_HOME environment variable used to run Maven or Ant will specify it. The command "java -version" will tell you which version of Java your compiler outputs by default.

The JAVA_HOME environment variable is also one way to tell Tomcat which Java VM is to be used for executing Tomcat and its webapps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!