Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while testing InitParameter()

 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oi!

I got a following error on the page while accessing a servlet....

---------------------------------------------------------------------------

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class com.example.web.TestInitParams
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
java.lang.Thread.run(Unknown Source)


root cause

java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.example.web.TestInitParams 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:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
java.lang.Thread.run(Unknown Source)

---------------------------------------------------------------------------

here is the code of my servlet...

---------------------------------------------------------------------------

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

class TestInitParams extends HttpServlet
{

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();

out.println("test init parameters");

Enumeration e = getServletConfig().getInitParameterNames();
while(e.hasMoreElements())
{
out.println("The parameter name: " + e.nextElement() + "<br>");
}
out.println("main email is: " + getServletConfig().getInitParameter("mainemail")e);
out.println("admin email is: " + getServletConfig().getInitParameter("adminemail"));
}
}

-----------------------------------------------------------------------

please let me know if you need code from DD also and if the error is there.
 
Darren Weaver
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making your class TestInitParams public.
 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Atul,

There is a typo. Remove the "e" at the end of the println


HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic