File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Servlet cannot access bean/Servlet Not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Servlet cannot access bean/Servlet Not found" Watch "Servlet cannot access bean/Servlet Not found" New topic

Servlet cannot access bean/Servlet Not found

riya s
Ranch Hand

Joined: Feb 28, 2003
Posts: 110
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" "">
<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

Joined: Feb 28, 2003
Posts: 110
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..
I agree. Here's the link:
subject: Servlet cannot access bean/Servlet Not found
It's not a secret anymore!