views:

68

answers:

2

edit 10/8/10 @ 8:20am est - since I can't make this work in prod, I'll try to make it fail in test.

edit 10/8/10 @ 4:30pm est - having a great time!!! NOT. Ok, hell continues. I learned earlier today that we're also running Apache httpd as a separate process. So we're thinking maybe we're not forwarding the request to Tomcat somehow. I am not running httpd in my test environment.

Edit 10/8/10 @ 8:20pm - found out that the server also had httpd running on it. httpd was only forwarding jsp requests to Tomcat. Apache was eating the servlet requests, trying to serve static pages (?) and failing of course. I hacked the bajezus out of worker2.properties to make httpd forward the requests. Ouch.


Tomcat 5.5, RedHat linux.

I created a servlet which of course runs fine in our test environment. I moved it to production and I fail with a 404 error. According to the catalina log the servlet seems to load properly.

I'm at wits end - I don't know how to troubleshoot this. It's almost like I have misspelled the servlet name somewhere.

Here's my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
    <display-name>Pdf Servlet</display-name>
    <servlet>
        <servlet-name>pdf</servlet-name>
        <servlet-class>com.thop.exp.PdfServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>pdf</servlet-name>
        <url-pattern>/pdf</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>

I am browsing to www.myurl.net/PdfServlet/pdf. I believe I have this rooted correctly. and the name of the war file is PdfServlet.war.

Any ideas on a problem, or ideas on what I can do to get an idea?


Here's the log.

INFO: Installing web application at context path /PdfServlet from URL file:/mnt/san00/aaadata_root/ROOT/PdfServlet
Oct 7, 2010 11:32:50 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Oct 7, 2010 11:32:50 PM org.apache.catalina.startup.ContextConfig applicationConfig
INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[aaa.net].StandardContext[]
Oct 7, 2010 11:32:50 PM org.apache.catalina.core.StandardHost getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx )
Oct 7, 2010 11:32:50 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 7, 2010 11:32:50 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 7, 2010 11:32:50 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/25  config=/usr/share/tomcat5/conf/jk2.properties
Oct 7, 2010 11:32:50 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4325 ms
+1  A: 

Tomcat 5.5 is a servlet 2.4 container, and you have specified you have a 2.5 web.xml.

If the Tomcat version in test is newer than 5.5 (6 or 7) then try lowering web.xml to 2.4.


EDIT: Ok, then try removing /pdf from web.xml again and see if you can invoke the com.thop.exp.PdfServlet class from your index.jsp file.

Thorbjørn Ravn Andersen
Changes made, tomcat restarted, no change in behavior.
Tony Ennis
This is the only servlet on the system as far as I know. Do servlets have to be 'enabled' in a config somewhere?
Tony Ennis
I was able to _refer_ to the com.thop.exp.PdfServer class. I tried to invoke it using a form and got the same error, "Not Found,The requested URL /PdfServlet/pdf was not found on this server."
Tony Ennis
You can do `<%= new com.thop.exp.PdfServer %>` and have its toString output on the JSP page?
Thorbjørn Ravn Andersen
+2  A: 

I'd recommend trying to package your web app as a WAR file - name it PDFServlet.war.

Put that into your Tomcat /webapps directory.

The URL in question would be http://www.myurl.net:8080/PdfServlet/pdf.

I'm assuming that you've got Tomcat listening on port 8080; if not, add your own port number.

Is there no way to specify which PDF the user wants? Or is it always the same PDF?

duffymo
The PDF names are constructed based upon customer ID and the date. The servlet fetches the appropriate PDF from a server and streams it to the jsp.
Tony Ennis
So customer comes in via credentials? Or is it a REST query (e.g., ?custId=X)
duffymo
REST, charitably speaking.
Tony Ennis
How can I prove that the web.xml above is the one being used? One of my guys hypothesizes that the servlet isn't being recognized because Tomcat isn't using our web.xml.
Tony Ennis
I suppose I haven't thought of it too much, but we have the conf/web.xml under Tomcat with all the MIME mappings and so forth, and the spartan web.xml that's in my servlet. Does Tomcat slam them together?
Tony Ennis
You ought to have a /WEB-INF/web.xml in your project. I never touch the server configuration.
duffymo
Thank goodness. I just found this. <!-- This document defines default values for *all* web applications --> <!-- loaded into this instance of Tomcat. As each application is --> <!-- deployed, this file is processed, followed by the --> <!-- "/WEB-INF/web.xml" deployment descriptor from your own --> <!-- applications.
Tony Ennis