This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Request not comming to Servletclass 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 » Java » Servlets
Bookmark "Request not comming to Servletclass" Watch "Request not comming to Servletclass" New topic
Author

Request not comming to Servletclass

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,
i am sending my code.My MailSenderServlet.java compiled.I kept this file
in proper path in web.xml.

Still i am these errors at the execution time.Could please suggest me what the mistake i did in my code.

[26/Dec/2008:21:02:10] warning ( 3908): for host 127.0.0.1 trying to POST /servlet/customerserviceServlet.MailSenderServlet, service-j2ee reports: StandardWrapper[:customerserviceServlet.MailSenderServlet]: WEB2795: Marking servlet customerserviceServlet.MailSenderServlet as unavailable
[26/Dec/2008:21:02:10] failure ( 3908): for host 127.0.0.1 trying to POST /servlet/customerserviceServlet.MailSenderServlet, service-j2ee reports: WEB2798: [] ServletContext.log(): invoker: WEB3314: Cannot allocate servlet instance for path /servlet/customerserviceServlet.MailSenderServlet
javax.servlet.ServletException: WEB2779: Error instantiating servlet class customerserviceServlet.MailSenderServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:898)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:658)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:413)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at RequestFilter.doFilter(RequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:280)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:579)
----- Root Cause -----
java.lang.NoClassDefFoundError: javax/mail/MessagingException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:889)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:658)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:413)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at RequestFilter.doFilter(RequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:280)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:579)

[26/Dec/2008:21:02:10] failure ( 3908): for host 127.0.0.1 trying to POST /servlet/customerserviceServlet.MailSenderServlet, service-j2ee reports: StandardWrapperValve[invoker]: WEB2792: Servlet.service() for servlet invoker threw exception
javax.servlet.ServletException: WEB3314: Cannot allocate servlet instance for path /servlet/customerserviceServlet.MailSenderServlet
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:438)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at RequestFilter.doFilter(RequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:280)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:579)
----- Root Cause -----
java.lang.NoClassDefFoundError: javax/mail/MessagingException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:889)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:658)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:413)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at RequestFilter.doFilter(RequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:280)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:579)




CustomerQuerie.jsp
function form_sub()
{
if (validateRequest())
{

CustomerQueries.action="<%=response.encodeURL("/servlet/customerserviceServlet.MailSenderServlet")%>";
CustomerQueries.method="post";
CustomerQueries.submit();
}
}

-------------------------------------------
MailSenderServlet.java
public class MailSenderServlet extends HttpServlet {
// private String strHost = null; // Mail Server name
// private String strDefaultFromUser = null; // From user name

public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
doPost(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
System.out.println("Hello1");
String strFromUser=null;
String strToUsers=null;
String strCcUsers=null;
String strSubject=null;
String strMessageBody=null;
String []strobjAttachments=null;
String errorMessage="";
HashMap result=null;
strFromUser=request.getParameter("txtFromMail");
strToUsers=request.getParameter("To");
strCcUsers=request.getParameter("To");
strSubject=request.getParameter("selIssue");
strMessageBody=request.getParameter("txtIssue");
System.out.println("Hello2");
try
{
sendTextMail(strFromUser, strToUsers, strCcUsers, strSubject, strMessageBody, strobjAttachments);
}
catch (IOException e) {
System.err.println("IOException: " + e);
}



}

/* public MailSenderServlet()
{
strHost = MailConfig.MAIL_HOST;
strDefaultFromUser = MailConfig.DEFAULT_FROM;
}*/


public void sendTextMail(String strFromUser, String strToUsers, String strCcUsers, String strSubject, String strMessageBody, String[] objAttachments) throws IOException
{
try
{
// Get a Properties object

java.util.Properties objProps = System.getProperties();
objProps.put("mailhub-ap.ap.ssmb.com","25");
//java.util.Properties objProps = System.getProperties();
//objProps.put("mail.smtp.host",strHost);

// Get a Session object
Session objSession = Session.getDefaultInstance(objProps, null);

// Construct a new message
MimeMessage objMessage=new MimeMessage(objSession);

// Set up the parameters for sending the message
if ( strFromUser != null )
objMessage.setFrom(new InternetAddress(strFromUser));
objMessage.setSubject(strSubject);

if (strToUsers == null)
throw new IOException("Email id of recipients not defined");
else
{
if (strToUsers != null)
objMessage.setRecipients(Message.RecipientType.TO,InternetAddress.parse(strToUsers));

}

if(objAttachments==null)
{
objMessage.setText(strMessageBody);
}
else
{
Multipart mpMainPart=new MimeMultipart();

//Creating multi-part message
BodyPart bpMessageBodyPart=new MimeBodyPart();//this is the Mail Message BodyPart
bpMessageBodyPart.setText(strMessageBody+"\n");

mpMainPart.addBodyPart(bpMessageBodyPart);

for(int intCount=0;intCount<objAttachments.length;intCount++)
{
BodyPart bpFileBodyPart=new MimeBodyPart();//this is the Attachment BodyPart
DataSource dsSource=new FileDataSource(new File(objAttachments[intCount]));
bpFileBodyPart.setDataHandler(new DataHandler(dsSource));
bpFileBodyPart.setFileName(objAttachments[intCount]);

mpMainPart.addBodyPart(bpFileBodyPart);
}

objMessage.setContent(mpMainPart);
}

// Send the message
Transport.send(objMessage);
}
catch(MessagingException ex)// Trap MessagingException
{throw new IOException();
}
catch (IOException e) {
System.err.println("IOException: " + e);
}
}
}
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by sumanta panda:
----- Root Cause -----
java.lang.NoClassDefFoundError: javax/mail/MessagingException

That's fairly self-explaining. The mentioned class is missing in the classpath. Add it (actually, the JAR file with the class) to the classpath and it should be fine.
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Bauke Scholtz Sir,
It means i will add this below class path in the envirment variable or
i will keep all the jar file in the lib folder.

Please guide me sir...

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="Config"/>
<classpathentry kind="lib" path="C:/workspace_certification/Mailing Component/Library/xmlparserv2.jar"/>
<classpathentry kind="lib" path="C:/workspace_certification/Mailing Component/Library/activation.jar"/>
<classpathentry kind="lib" path="C:/workspace_certification/Mailing Component/Library/mail.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Just place it in a folder which is covered by the classpath. In case of a webapplication the /WEB-INF/lib folder is by default covered by the classpath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request not comming to Servletclass
 
Similar Threads
cannot allocate servlet instance
If any exception happens in the server code error message would be displayed
What is HTTP server 500 error.
Why am I getting this error!!!!
How to run a servlet using Tomcat?