aspose file tools*
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
JavaRanch » Java Forums » Products » Websphere
Bookmark "Servlet cannot access bean/Servlet Not found" Watch "Servlet cannot access bean/Servlet Not found" New topic
Author

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
http://localhost/my/Login.jsp
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-name>Login</servlet-name>
<jsp-file>Login.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet id="Servlet_2">
<servlet-name>LoginCheck</servlet-name>
<jsp-file>LoginCheck.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet id="Servlet_3">
<servlet-name>Main_Menu</servlet-name>
<jsp-file>Main_Menu.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet id="Servlet_4">
<servlet-name>AddShow</servlet-name>
<jsp-file>AddShow.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet id="Servlet_5">
<servlet-name>Add_Ticket</servlet-name>
<servlet-class>VioSys.Add_Ticket</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping id="ServletMapping_1">
<servlet-name>Add_Ticket</servlet-name>
<url-pattern>/AddTicket</url-pattern>
</servlet-mapping>
</web-app>
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: http://aspose.com/file-tools
 
subject: Servlet cannot access bean/Servlet Not found