I package up a file, gg.war, as follows: (note, the same directory structure I have running in Tomcat 5x with no problems)
MANIFEST.MF (in META-INF\ )
IsItWorking.class ( in WEB-INF\classes\ )
web.xml (in WEB-INF\ )
My web.xml appears as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
When I put this gg.war into my deployment directory, JBoss seems to correctly deploy it as:
21:14:27,615 INFO [TomcatDeployer] deploy, ctxPath=/gg, warUrl=.../tmp/deploy/tmp30484gg-exp.war/
(though, I do not see a directory called /gg anywhere where this thing should be unpacked to!)
However, when I go to call this servlet:
I get a 404 error (The requested resource (/gg/servlets/IsItWorking/IsItWorking) is not available.)
Why can't see the results of this servlet, which works fine in Tomcat (I am using JBoss 4.2.3.GA). My servlet source code is simply:
public class IsItWorking extends HttpServlet
public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
PrintWriter printwriter = httpservletresponse.getWriter();
String s = getServletConfig().getServletContext().getServerInfo();
printwriter.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\"> Yes, It's working! <META NAME=\"Author\" CONTENT=\"" + s + "\">" + "" + "<BODY BGCOLOR=\"#FFFFFF\">" + " " + " <IMG " + "ALT=\"[ Picture broken ? Access this from localhost ]\" " + "SRC=\"/jserv/status?image\" BORDER=\"0\">" + " <H1>" + "Yes, It's working!" + "</H1>" + " <H2>Congratulations, " + s + " is working!</H2>" + " <H3>[ local time is " + new Date() + " ]</H3>" + " <FONT SIZE=\"-1\">Copyright (c) 1997-99" + " <A HREF=\"http://java.apache.org/\">The Java Apache Project" + " All rights reserved." + " " + "" + "");
public static final String TITLE = "Yes, It's working!";
As stated, this works fine when installed on Tomcat (4 and 5) but for whatever reason, I can;t make it fly in JBoss. Please help this newbie -- I've been at this for a few hours and can;t seem to get past this. Thanks!
<servlet-mapping> <servlet-name>IsItWorking</servlet-name> <url-pattern>/gg/servlets</url-pattern> </servlet-mapping>
So shouldn't you just be using http://localhost:8080/gg/servlets instead of http://localhost:8080/gg/servlets/IsItWorking in the browser?
When I try that URL, I get the same 440 error:
The requested resource (/gg/servlets/) is not available.
When it deploys, shouldn;t it unpack the war somewhere (I see it unpacks things to:
but shouldn;t it unpack it all under:
Lastly, if put a standard html page at the root level of my war, I can access it after deploying with:
but not the servlet. I must be doing something stupid - I'm not the first guy to try to deploy a simple servlet on JBoss -- it has to be something I am missing that is right in front of my eyes in terms of how I have things configured -- but I cannot seem to find it.
Restarted the server, it redoployed on startup, and runs fine now. Hmmmm.
One other thing to consider - some web app containers have issues with deploying servlets that do not have a package name. Assigning a package name will help. I recall having a discussion about this in this forum quite some time ago with the solution being to add a package. Example:
Add this to the servlet's source:
package foo; // rest of servlet source as you posted
Change servlet stanza in the web.xml to:
<servlet> <servlet-name>IsItWorking</servlet-name> <servlet-class>foo.IsItWorking</servlet-class> </servlet>
Change your ww.war to contain: