File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes servlet deployment issue on websphere server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "servlet deployment issue on websphere server." Watch "servlet deployment issue on websphere server." New topic
Author

servlet deployment issue on websphere server.

nitss bhavsar
Ranch Hand

Joined: Jan 09, 2012
Posts: 55
Hello,
I have written one servlet that i have to deploy on websphere server,when i enter the url then first html page is opening but when i click on a button i m getting error like Error 404: SRVE0200E: Servlet [webnew.WelCome]: Could not find required class - webnew.WelCome.
my servlet code is

package webnew;
import java.io.PrintWriter;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WelCome extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = 1L;

private ConnectionFactory cf;

private Queue queue;


@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);

}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException, NamingException
{
try
{ Context ctx=new InitialContext();
cf = (QueueConnectionFactory)ctx.lookup("MQConnectionFactory");
queue = (Queue)ctx.lookup("QIbm");
Connection connection =cf.createConnection();
Session session =connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer producer =session.createProducer(queue);
Message msg;
TextMessage message =session.createTextMessage();

String var=request.getParameter("msg");
message.setText(var);
producer.send(message);
producer.close();
session.close();
connection.close();
PrintWriter out=response.getWriter();
out.println("<html><head><title>The servlet example </title></head> <body><h1>A simple web application</h1><br/><br/>");
out.println("<input type='submit' value='Read the message from queue'/>");
out.println("</form></body></html>");
}
catch(Exception e)
{
e.printStackTrace();

}

}

protected void readMsgRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException, NamingException
{
try
{ Context ctx=new InitialContext();
cf = (QueueConnectionFactory)ctx.lookup("MQConnectionFactory");
queue = (Queue)ctx.lookup("QIbm");
Connection connection =cf.createConnection();
Session session =connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageConsumer Consumer =session.createConsumer(queue);


//TextMessage message =session.createTextMessage();
//message.setText("good morning");
Message msg = Consumer.receive();
Consumer.close();
session.close();
connection.close();
PrintWriter out=response.getWriter();
out.print("<html><head><title>The servlet example </title></head>");
out.print("<h1> "+msg+" </h1>");

}
catch(Exception e)
{
e.printStackTrace();

}

}

protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, java.io.IOException {
try {
if(request.getParameter("submitBtn").equals("Put the message into the queue"))
{
processRequest(request, response);
}
else
readMsgRequest(request, response);

} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
try {
if(request.getParameter("submitBtn").equals("Put the message into the queue"))
{
processRequest(request, response);
}
else
readMsgRequest(request, response);

} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void destroy() {

}
}



if possible help me out to get the solution to this problem...if require more infomation i will post it.
thanks in advance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

nitss bhavsar wrote:Hello,
I have written one servlet that i have to deploy on websphere server,when i enter the url then first html page is opening but when i click on a button i m getting error like Error 404: SRVE0200E: Servlet [webnew.WelCome]: Could not find required class - webnew.WelCome.
my servlet code is...


The code has nothing to do with the problem. You haven't deployed the class correctly. The compiled version of the class should be in the /WEB-INF/classes directory of the deployed application, as WelCome.class in directory /webnew. Or alternatively, it should be in a jar file which is in the /WEB-INF/lib directory.
nitss bhavsar
Ranch Hand

Joined: Jan 09, 2012
Posts: 55
thanks for reply ,
You are right,i have problem in deployment...now i have created war file in which web-inf contains compiled file of servlet and web.xml...but i m getting new problem while accessing application through html...i m getting error like Error 404: SRVE0190E: File not found: /...my war file contains WEB_INF in that class file ,web.xml ...do i have to include html page in that war??how to and where to include???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Not web-inf, and not WEB_INF, but WEB-INF.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
nitss bhavsar
Ranch Hand

Joined: Jan 09, 2012
Posts: 55
yup its WEB-INF...my html file is like
<html>
<head>
<title>The servlet example </title>
</head>
<body>
<h1>A simple web application</h1>
<form method="GET" action="WelCome">
<label for="name">enter your message here</label>
<input type="text" id="name" name="msg"/><br><br>
<input type="submit" name="submitBtn" value="Put the message into the queue"/>
</form>
</body>
</html>



and web.xml is

<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>welcome</servlet-name>
<servlet-class>webnew.WelCome</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>welcome</servlet-name>
<url-pattern>/WelCome</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>form.html</welcome-file>
</welcome-file-list>
</web-app>


can you please tell me is there any problem with these files?
Larsen Raja
Ranch Hand

Joined: Nov 28, 2011
Posts: 58
The class files looks to have not generated properly. Stop the server. Remove the EAR. Now clean and build the project. Start the server. Add the EARs. Do a maual publish. This should mostly resolve the issue.

Additionally, take a look at the http/jvm logs or ffdc logs as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet deployment issue on websphere server.
 
Similar Threads
A simple JNDI question....
jms queue fetching of message as and when it is posted in asynchronous communication
not able to insert values in ms access database
client or consumer register listner?
can I integrate JMS with Servlets???