• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Servlet cannot access bean/Servlet Not found

Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am posting my problem as a new topic again since its not jsp and bean problem but servlet cannot be found ! I have also added my web.xml file below in this posting.
I was using j2ee to initially create this project. Once I completed it I want to move it to production which is on websphere.. but it just doesnt work there..
Just to give you a background.. I am using JSP,Servlets and Java Beans(not EJB). I have a bean which gives database connection to all jsp,servlets.
My bean access problem from jsp works but when I call a servlet it gives me 404 Error.
I have tried to create a war in a million different ways but that just does not work.
Some of thie things I tried
1. I am putting all servlets and the java bean in the folder VioSys under classes folder. All the jsps are in MyApp.ear/MyApp.war
I did this because the first statement of my servlets I have
package VioSys;
and the Java Bean has
2. Tried to put all JSP in VioSys, All Servlets in clsses and bean in VioSys, bean in classes, jars etc ... nothing works... I have practicaly figured out every feature of websphere except how to do this...
Also I create a new war and new ear everytime I try anything different to avoid any mistakes..
Please help..
I am sending you the web.xml file.
Here are the steps I followed.
Directory where all files are C:\VioSys
Create new webmodule
1) Added all JSP files Login, LoginCheck, MainMenu,AddShow (selected them from C:\Viosys)
2) Added Servlet (selected as VioSys.Add_Ticket)
3) Servlet mapping for Servlet Add_Ticket
4)Added ConnectDB (THE JAVA BEAN) as a class file.
Save webmodule as myapp
New Application > myapp.ear .. Import myapp.war in the application..Give my as the context root.. Didnt specify any jar or classpath nothing.
Save myapp.ear and generate code. Install using console and save it in C:\WebSphere\AppServer\config\server-cfg.xml
and stop server. Start server.
I access it using URL
That works and when I write the username and password it uses the Bean to get connection. I reach the Main Menu where I can add a ticket. But now when I call AddTicket (by clicking submit button )which is the servlet it gives me a 404 Not Found error.
On the default_server_stdout everything else looks fine but it gives:
[03.03.17 14:40:23:336 EST] 49b1120 WebGroup X Servlet Error-[Add_Ticket]: Failed to load servlet: java.lang.NoClassDefFoundError: Add_Ticket (wrong name: VioSys/Add_Ticket)
Since my servlet name is Add_Ticket I have Servlet mapping /AddTicket because that is what is called when form is submitted.
I am not sure where I can place my servlet... Is it that the jsp files can call the bean from classes\viosys\ConnectDB.class
but my servlets cant do that ? I tried removing the package VioSys statement from the servlets as well but didnt work..
The above example the servlet is getting its own connection and has no dependency on the java bean to get the connection.. Inspite of this the servlet is not found and I get the 404 error...
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">;
<web-app id="WebApp_ID">
<servlet id="Servlet_1">
<servlet id="Servlet_2">
<servlet id="Servlet_3">
<servlet id="Servlet_4">
<servlet id="Servlet_5">
<servlet-mapping id="ServletMapping_1">
Please help.
riya s
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay since I am talking to myself here.. I might as well ask if there are any demos or examples I can look up on how to add java beans using websphere and what setting I need to make in classpath etc if any..
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic