Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Class org.mortbay.jetty.servlet.Holder can not access a member of c

  Asked By: Claude    Date: Mar 12    Category: Java    Views: 2570
  

I have the following servlet code in a file myServlet.java:

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

class myServlet extends HttpServlet
{
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
try {
PrintWriter out = response.getWriter();
out.print("Hello World!");
}
catch (Exception e) {
}
}

public void doPost( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
try {
doGet(request, response);
}
catch (Exception e) {
}
}
}


I have the following web.xml file located in the WEB-INF/ directory.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>servlet1</servlet-name>
<servlet-class>myServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet1</servlet-name>
<url-pattern>/myServlet</url-pattern>
</servlet-mapping>
</web-app>


I run the following batch file:

javac myServlet.java
move myServlet.class WEB-INF\classes
jar -cvf myServlet.war *
move myServlet.war D:\java\jboss-3.2.1\server\default\deploy

I then browse to:

http://localhost:8080/myServlet/myServlet

And I get the following error message:

HTTP ERROR: 503 java.lang.IllegalAccessException: Class
org.mortbay.jetty.servlet.Holder can not access a member of class
myServlet with modifiers "" RequestURI=/myServlet/myServlet


Does anyone know what I've done wrong? I am using jboss-3.2.1 as my
application server. I've been tearing my hair out for hours on this
one, but can't see what is wrong with the code.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Jimmy Abp     Answered On: Mar 12

The problem was that I had neglected to make the class  public.

So, by changing:

class myServlet extends HttpServlet

to:

public class myServlet extends HttpServlet

the problem goes away.

 




Tagged: