Results 1 to 11 of 11
Thread: Servlet Exception
- 02-24-2010, 09:51 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
Servlet Exception
Feb 24, 2010 2:25:30 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet firstservlet
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class ServletExample with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate( StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
- 02-24-2010, 10:39 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
If you really want to get help then you will describe what you are doing and explain how you come to get the output you are getting. Really, you should not be too lazy todescribe your problem.
- 02-24-2010, 10:41 AM #3
Member
- Join Date
- Feb 2010
- Posts
- 29
- Rep Power
- 0
Hi Bhanu Priya!I think You r getting this problem due to the member(function or a Variable) of your "ServletExample" class has an access modifier Private.It is better to post the source code of your "ServletExample" class then It is easy to
debug and find the root cause.
- 02-24-2010, 11:08 AM #4
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
servletexception
///Source code
i am new to java servlets so that not able to trace the exception why it is coming
import java.io.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import javax.servlet.http.*;
import javax.servlet.*;
class ServletExample
{
public void doPost(HttpServletRequest req, HttpServletResponse response)throws ServletException, IOException
{
try
{
String fileName="hello.doc";
String docPath="c:\\hello.doc";
response.setContentType("application/vnd.ms-word");
response.setHeader("Content-Disposition","inline; filename="+fileName);
OutputStream os = response.getOutputStream();
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(docPath));
fs.writeFilesystem(os);
os.flush();
os.close();
}
catch ( Exception ex )
{
System.out.println("exception" +ex);
}
}
}
- 02-24-2010, 11:16 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You need to read a tutorial on servlets first then.
HttpServlets should extend HttpServlet.
- 02-24-2010, 11:30 AM #6
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
say you said ServletExample should extend HttpServlet
i tried and compile the program again it is coming
import java.io.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import javax.servlet.http.*;
import javax.servlet.*;
class ServletExample extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse response)throws ServletException, IOException
{
..........
}
}
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Error instantiating servlet class ServletExample
org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class ServletExample with modifiers ""
sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
- 02-24-2010, 11:41 AM #7
Member
- Join Date
- Feb 2010
- Posts
- 29
- Rep Power
- 0
As said above by Mr.rxxxxx, first let your class being extends "javax.servlet.http.HttpServlet"
- 02-24-2010, 11:43 AM #8
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Make the class public.
Putting your classes into packages is also a good idea. The best advice for you though is to stop all this and read a tutorial from the start. You are just trying to guess what the correct things should be when they are clearly documented in tutorials.
- 02-24-2010, 11:46 AM #9
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
okay i will start reading servlet tutorial thanks for your suggestion sir
- 02-24-2010, 12:13 PM #10
Member
- Join Date
- Feb 2010
- Posts
- 29
- Rep Power
- 0
Where from you get that example Bhanu_Priya?You said that you are new to servlets then dont go for such a subtle examples.First learn the Syntax and types of classes exist like GenericServlets,HttpServlets,methods in it and their purpose,and go for Cookies,Sessions,RequestDispathching techniques etc...
Dont be frustrate on me just take it as an advice thats it!What i'm saying is as a beginner you go through such an examples like POIFSFilesystem etc..then you feel the difficulty and obviously you lost the interest there by you may change your attitude towards some other Technologies.Indeed,we loose one great aspirant from the world of Servlets.
- 03-05-2010, 06:05 PM #11
Member
- Join Date
- Mar 2010
- Location
- beijing
- Posts
- 2
- Rep Power
- 0
The whole Servlet like this:
Java Code:package com.demo.pagination; import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspFactory; import javax.servlet.jsp.PageContext; public class Page extends HttpServlet { private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JspFactory jspFactory = JspFactory.getDefaultFactory(); PageContext pageContext = jspFactory.getPageContext(this, request, response, null, true, 8192, true); ServletContext application = pageContext.getServletContext(); System.out.println("================>"+application.getAttribute("aaa")); //当前页数 String pageNum = request.getParameter("pageNum"); //每页多少行 String totalPerPage = request.getParameter("totalPerPage"); //数据总数 String totalNum = request.getParameter("totalNum"); if (pageNum == null || "".equals(pageNum)) { pageNum = "1"; } if (totalNum == null || "".equals(totalNum)) { totalNum = "22"; } if (totalPerPage == null || "".equals(totalPerPage)) { totalPerPage = "5"; } request.setAttribute("pageNum", pageNum); request.setAttribute("totalPerPage", totalPerPage); request.setAttribute("totalNum", totalNum); request.getRequestDispatcher("index.jsp").forward(request, response); } }
this is just a example...
Similar Threads
-
SQL exception error in JDBC conection with servlet+ jsp
By morya123 in forum New To JavaReplies: 2Last Post: 12-09-2009, 09:58 AM -
Servlet - apache tomcat/glassfish server shuts down on servlet usage
By StewS in forum Java ServletReplies: 1Last Post: 12-02-2008, 12:23 AM -
Exception Report:annot allocate servlet instance for path
By mary in forum Java ServletReplies: 4Last Post: 11-05-2007, 05:14 PM -
javax.servlet.ServletException: Wrapper cannot find servlet class util.t2
By osval in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 03:47 PM -
A Servlet Exception Has Occurred
By gabriel in forum JDBCReplies: 1Last Post: 08-07-2007, 02:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks