• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet deployment issue on websphere server.

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not web-inf, and not WEB_INF, but WEB-INF.

 
nitss bhavsar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
please buy my thing and then I'll have more money:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic