• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat Servlet class not found issue

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a typo:

evo.net.testServlet



public class servletTest extends HttpServlet

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok i sorted the typo now im getting a new error:

 
Sheriff
Posts: 67747
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic