Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat Servlet class not found issue  RSS feed

 
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.
 
Saloon Keeper
Posts: 4476
112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a typo:

evo.net.testServlet



public class servletTest extends HttpServlet

 
Rancher
Posts: 3493
39
  • 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:

 
Author and ninkuma
Marshal
Posts: 66678
167
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
 
Bartender
Posts: 19454
88
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.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!