This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I am having a big problem with IBM websphere... I am using jsp,servlets and java beans.. I have no problem with my code which works fine when I deploy it using j2ee server in my local machine.. I have also installed IBM websphere on server and local machine.. I am testing the same servlets,jsp and java beans(not ejb) on websphere and they are not able to access the bean? I tried butting the java bean in classes folder as well as created a sub-directory under which I kept the bean.. but none of the jsps or servlets can access the bean... this bean gives the database connection to the jsp and servlets.. can some one please tell me what I should do ? I am struggling since past week but now I give up and ask your advice from those who are more experienced... Please advise...
Joined: Feb 28, 2003
Then here is what I did now.. I created a fresh war.. (by adding just 2 jsp files which are in C:\viosys and added them). I added the bean to the war as a class file and the path for it is WEB-INF/classes/VioSys. I saved the war in c:\viosys. Imported the war to the ear and saved it in c:\viosys. Using administrative console I installed the application I generate code for deployment and start and stop server and run it... same problem This is the error org.apache.jasper.JasperException: JSPG0059E: Unable to compile class for JSPC:\WebSphere\AppServer\temp\ucl31-wcsu\Default_Server\VioSys.ear\VioSys.war\Main_0005fMenu_jsp_0.java:90: Class ConnectDB not found. ConnectDB conBean = null; ^ C:\WebSphere\AppServer\temp\ucl31-wcsu\Default_Server\VioSys.ear\VioSys.war\Main_0005fMenu_jsp_0.java:93: Class ConnectDB not found. conBean= (ConnectDB) ^ C:\WebSphere\AppServer\temp\ucl31-wcsu\Default_Server\VioSys.ear\VioSys.war\Main_0005fMenu_jsp_0.java:98: Class ConnectDB not found. conBean = (ConnectDB) Beans.instantiate(getClassLoader(), "ConnectDB"); ^ Note: C:\WebSphere\AppServer\temp\ucl31-wcsu\Default_Server\VioSys.ear\VioSys.war\Main_0005fMenu_jsp_0.java uses or overrides a deprecated API. Recompile with "-deprecation" for details. 3 errors, 1 warning
Can you show us the EXACT structure of your WAR file (e.g. what you put in what directories inside the WAR?) Also, is the bean you are referring to the "ConnectDB" that is listed in the stack trace? Kyle
Hi Kyle ! Thanks for the reply .. It has been days and I just cannot figure this one out... Please help.. 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 <jsp:useBean id="conBean" scope="request" class="VioSys.ConnectDB"/> 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... Please Please help...