Results 1 to 11 of 11
  1. #1
    bhanupriya is offline Member
    Join Date
    Feb 2010
    Posts
    4
    Rep Power
    0

    Unhappy 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)

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    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.

  3. #3
    Anjaneyulu is offline Member
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Default

    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.

  4. #4
    bhanupriya is offline Member
    Join Date
    Feb 2010
    Posts
    4
    Rep Power
    0

    Default 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);
    }

    }
    }

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You need to read a tutorial on servlets first then.
    HttpServlets should extend HttpServlet.

  6. #6
    bhanupriya is offline Member
    Join Date
    Feb 2010
    Posts
    4
    Rep Power
    0

    Default

    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)

  7. #7
    Anjaneyulu is offline Member
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Default

    As said above by Mr.rxxxxx, first let your class being extends "javax.servlet.http.HttpServlet"

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    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.

  9. #9
    bhanupriya is offline Member
    Join Date
    Feb 2010
    Posts
    4
    Rep Power
    0

    Default

    okay i will start reading servlet tutorial thanks for your suggestion sir

  10. #10
    Anjaneyulu is offline Member
    Join Date
    Feb 2010
    Posts
    29
    Rep Power
    0

    Default

    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.

  11. #11
    NoGrief is offline Member
    Join Date
    Mar 2010
    Location
    beijing
    Posts
    2
    Rep Power
    0

    Default

    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

  1. Replies: 2
    Last Post: 12-09-2009, 09:58 AM
  2. Replies: 1
    Last Post: 12-02-2008, 12:23 AM
  3. Replies: 4
    Last Post: 11-05-2007, 05:14 PM
  4. Replies: 1
    Last Post: 08-07-2007, 03:47 PM
  5. A Servlet Exception Has Occurred
    By gabriel in forum JDBC
    Replies: 1
    Last Post: 08-07-2007, 02:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •