• 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
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

classes directory

 
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using webappcabaret to learn servlets and I have created some servlets successfully when I place them directly under my context name in the directory WEB-INF/classes but when I try to put servlets in a directory under classes it won't work.
For example I created a TestServlet that just prints out a message and type this in the address bar: www.webappcabaret.com/amberw/servlet/Test.TestServlet. The error that I got was this:
Error: 500
Location: /amberw/servlet/Test.TestServlet
Internal Servlet Error:
java.lang.NoClassDefFoundError: Test/TestServlet (wrong name: TestServlet)
...plus a bunch more junk
I don't know what I am doing wrong. I am not sure if I need to put something in web.xml or not.
Any Help is appreciated
Thanks - Amber
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amber:
From what I understand using hints from the terms Test.TestServlet, you have a package structure for your
TestServlet.
Hence you should not put your class file in the WEB-INF/classes
folder. You need to create a Test folder under classes and then
copy your TestServlet.class file into the newly created Test folder.
Correct me if I am wrong, meaning if you don't have a package structure in your TestServlet.
regds.
- satya
 
Amber Woods
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, Satya, I don't have TestServlet as part of a package but if that is the way to get it to work I will make it part of a package.
All I really want to do is be able to keep my class files separate and neat. I have two servlets with the same name but different contents (for an assignment). I just wanted to keep them separate (putting them in different folders under classes directory) instead of having to rewrite over the previous version any time I wanted to see if that servlet works correctly.
This is something like where my files are:
WEB-INF/classes/Test/TestServlet.class
WEB-INF/classes/Test2/TestServlet.class
and the TestServlet.class files are different. The way I called them in the location bar has been like this:
www.webappcabaret.com/amberw/servlet/Test.TestServlet www.webappcabaret.com/amberw/servlet/Test/TestServlet www.webappcabaret.com/amberw/servlet/TestServlet www.webappcabaret.com/amberw/servlet/Test2.TestServlet www.webappcabaret.com/amberw/servlet/Test2/TestServlet
and none of them work but maybe I will try to put them in a package. I just thought it would be something else.
Thanks - Amber
[This message has been edited by Amber Woods (edited June 26, 2001).]
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic