?
Solved

Going from tomcat 4.0 and 1.4.2JDK to tomcat 5.5.7 and 1.5JDK

Posted on 2005-03-06
76
Medium Priority
?
698 Views
Last Modified: 2013-11-24
Hello,

  I recently downloaded tomcat 5.5.7 and attempted to deploy a my web app to it using JDK 1.5. I had been using tomcat 4.0 with JDK 1.4.2 and that worked well. The new stuff gives a 404 error. I have done nothing special to tomcat just deployed my app and started it up.

-ec
0
Comment
Question by:entercite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 38
  • 33
  • 5
76 Comments
 

Author Comment

by:entercite
ID: 13472674
I use ant and compile the source code I will define all the paths and locations of the files.

Take a look and let me know if there are some errors in my deployment.

Development Structure
C:\
   |-main
      |-velocity
           |-ant
         |-build
             |-jsp
             |-lib
             |-WEB-INF (.class files)
         |-deploy (velocity.war)
         |-jsp
         |-lib
            |-mysql (mysql-connector.jar)
            |-api (servlet-2_3.jar)
            |-jfreechart(jcommon-0.9.5.jar, jfreechart-0.9.20.jar)
         |-WEB-INF (web.xml)
             |-classes (ControllerServlet.java)
                  |-com
                     |-xxx
                        |-common (.java files)
                        |-timetracker (.java files)

on compile:
compile:
    [javac] Compiling 70 source files to C:\Main\velocity\build\WEB-INF\classes
    [javac] Note: C:\Main\velocity\WEB-INF\classes\com\xxx\common\db\LoggableStatement.java
uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
dev:
      [jar] Building jar: C:\Main\velocity\deploy\velocity.war
     
BUILD SUCCESSFUL
Total time: 5 seconds
Press any key to continue . . .
                        
This LoggableStatement file I wrote to allow seeing DB errors in SQL statements.
public class LoggableStatement implements PreparedStatement {
- not sure what should be done here yet.

Deployment Structure
C:\
   |-program files
         |-Tomcat 5.5
           |-webapps
               (velocity.war) extracts into:
               |-velocity
                   |-jsp
                  |-lib
                  |-META-INF
                   |-WEB-INF (web.xml)
                        |-classes (ControllerServlet.java)
                              |-com
                                 |-xxx
                                    |-common (class files)
                                    |-timetracker (class files)


My web.xml
<?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>
  <!-- Define servlets that are included in the example application -->
  <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.mysite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.mysite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>dbPassword</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>source</param-name>
      <param-value>../webapps/velocity/WEB-INF/classes/com/xxx/timetracker</param-value>
    </init-param>
  </servlet>
</web-app>


Starting tomcat and going to my web app as I had using tomcat 4.0
url: http://www.mysite.com:8080/velocity/servlet/ControllerServlet?action=login

HTTP Status 404 - /velocity/servlet/ControllerServlet
type Status report
message /velocity/servlet/ControllerServlet
description The requested resource (/velocity/servlet/ControllerServlet) is not available.
Apache Tomcat/5.5.7
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13472678
You need to make sure that your web.xml is correct and that tomcat really is pointing towards your new JDK 1.5/5.0. This means that your classpath and the java_home system variable must have been pointing to the 1.5 JDK when you installed tomcat.

A couple of questions:
Do any of the examples work if you installed them, or failing that, a really simple webapp with a single "Hello world" jsp in it.
How are you deploying your webapp. Just as a directory or as a war file?
What's your OS?
0
 
LVL 28

Expert Comment

by:rrz
ID: 13472748
>My web.xml
<?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">

No, you need the 2.4 tag.

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 28

Expert Comment

by:rrz
ID: 13472754
Yes, please answer bloodredsun's questions.
0
 
LVL 28

Expert Comment

by:rrz
ID: 13472767
>url: http://www.mysite.com:8080/velocity/servlet/ControllerServlet?action=login 
You didn't show us your <servlet-mapping> tag.
Are you using the Invoker servlet ? Did you  uncomment it ?
0
 

Author Comment

by:entercite
ID: 13472865
bloodredsun
  1) my os is windows xp pro.
  2) I put the war file into the webapps folder
     then start tomcat then try the url.
     It unpacks but I get the 404
  3) I have a fresh install of the OS.
     I only installed JDK 1.5 no other version exists.
     Then I installed tomcat 5.5.7. In the  app for tomcat
     the configure screen of tomcat are two entries:
     Java virtual machine:
     C:\Program Files\Java\jre1.5.0_01\bin\client\jvm.dll
     Java classpath:
     C:\Program Files\Tomcat 5.5\bin\bootstrap.jar
     There is also an option section too:
     -Dcatalina.home=C:\Program Files\Tomcat 5.5
     -Djava.endorsed.dirs=C:\Program Files\Tomcat 5.5\common\endorsed
     -Djava.io.tmpdir=C:\Program Files\Tomcat 5.5\temp
  4) I have the sample app that came with tomcat but I was not sure how to hit it.
     http://www.xxx.com:8080/sample - 404 error
  5) I think my web.xml is the same as it was in tomcat 4.0

rzz--

The XML file. It should look like this?

<?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 xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
  <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.mysite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.mysite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>dbPassword</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>source</param-name>
      <param-value>../webapps/velocity/WEB-INF/classes/com/xxx/timetracker</param-value>
    </init-param>
  </servlet>
</web-app>

or do I simply drop the <?xml version heading section?

This is the web.xml that lives inside velocity\WEB-INF as indicated in the path mapping.

Where is the <servlet-mapping> tag?

Invoker servlet? I am not sure what the distiction of that means. It is a controller servlet used for mapping actions in my web app.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473410
You need to replace

<!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>

with

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
0
 

Author Comment

by:entercite
ID: 13473445
OK I made that change and still I get the 404 error when I go to:

http://www.mysite.com:8080/velocity/servlet/ControllerServlet?action=login
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473451
> had been using tomcat 4.0 with JDK 1.4.2 and that worked well    
So, I guess that you were using the Invoker Servlet.  But, it's use is not recommended. You should add  <servlet-mapping>  tag  to your context's web.xml.  

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
        <url-pattern>/servlet/ControllerServlet</url-pattern>
    </servlet-mapping>  

or  maybe use

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
        <url-pattern>controller</url-pattern>
    </servlet-mapping>  

and  http://www.mysite.com:8080/velocity/controller?action=login

0
 

Author Comment

by:entercite
ID: 13473488
that is working off the same xml with this in it?

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">

so it would continue like this???

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
        <url-pattern>controller</url-pattern>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.mysite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>   <param-value>http://www.mysite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>dbPassword</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>source</param-name>   <param-value>../webapps/velocity/WEB-INF/classes/com/xxx/timetracker</param-value>
    </init-param>
    </servlet-mapping>  

Correct?
0
 

Author Comment

by:entercite
ID: 13473513
Missed one detail...

    <url-pattern>ControllerServlet</url-pattern>

Changed it and deployed still 404.
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473524

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">

  <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.mysite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.mysite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.mysite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>dbPassword</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>source</param-name>
      <param-value>../webapps/velocity/WEB-INF/classes/com/xxx/timetracker</param-value>
    </init-param>
  </servlet>
    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
        <url-pattern>controller</url-pattern>
    </servlet-mapping>  
</web-app>
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473527
and
http://www.mysite.com:8080/velocity/controller?action=login
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473538
You should use IE browser to read web.xml file and display it's form.
0
 

Author Comment

by:entercite
ID: 13473561
I tried the new xml you gave and no dice... still getting the 404...

Antother idea I had was to try the sample from http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample/

I download it into the webapps and start tomcat then try using both
http://localhost:8080/sample
and
http://www.mysite.com:8080/sample 

404 error.
0
 

Author Comment

by:entercite
ID: 13473595
I used the IE browser to validate the xml too... looks valid according to it.

-ec
0
 

Author Comment

by:entercite
ID: 13473603
the weird things is that when I try and call the sample app from the url it never unpacks the war file and after about 30 seconds it disapears. Does tomcat clean out invalid war files automatically?
0
 

Author Comment

by:entercite
ID: 13473622
Is there anything in some config files I should set in order to call the sample app?

Another thing I am looking at is this:

http://localhost:8080/manager/html/list
in the List Applications I see my velocity app... I click on the start link and get an error:
Message:  FAIL - Application at context path /velocity could not be started
0
 
LVL 28

Expert Comment

by:rrz
ID: 13473954
>Message:  FAIL - Application at context path /velocity could not be started
Did you set up the logging ?  
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13474789
Yes, what do the tomcat log files say about why the webapps can't be started? You should be able to see them at <tomcat_home>/logs
Have you checked that tomcat is actually starting and able to bind to a port, ie check the firewall. Does the manager app work, eg http://localhost:8080/manager/html .
0
 

Author Comment

by:entercite
ID: 13475358
-rrz
just setup log4j now...


-bloodredsun

1) What does tomcat.log say when I try and start it... Well It dumps this:
To reduce the amount I have to show in ee I used some abreviations:

...ty]    = DEBUG ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.startup.HostConfig - Checking context[/velocity]

 ###docs] = DEBUG ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.startup.HostConfig - Checking context[/tomcat-docs]


...ty] redeploy resource C:\Program Files\Tomcat 5.5\webapps\velocity.war
...ty] redeploy resource C:\Program Files\Tomcat 5.5\webapps\velocity.war
...ty] redeploy resource C:\Program Files\Tomcat 5.5\webapps\velocity
...ty] redeploy resource C:\Program Files\Tomcat 5.5\webapps\velocity
...ty] reload resource C:\Program Files\Tomcat 5.5\webapps\velocity\META-INF\context.xml
...ty] reload resource C:\Program Files\Tomcat 5.5\webapps\velocity\META-INF\context.xml
...ty] reload resource C:\Program Files\Tomcat 5.5\conf\context.xml
...ty] reload resource C:\Program Files\Tomcat 5.5\conf\context.xml
...ty] reload resource C:\Program Files\Tomcat 5.5\conf\Catalina\localhost\context.xml.default
...ty] reload resource C:\Program Files\Tomcat 5.5\conf\Catalina\localhost\context.xml.default
...ty] reload resource C:\Program Files\Tomcat 5.5\webapps\velocity\WEB-INF\web.xml
...ty] reload resource C:\Program Files\Tomcat 5.5\webapps\velocity\WEB-INF\web.xml
 redeploy resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs
 ###docs] redeploy resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs
 ###docs] reload resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs\WEB-INF\web.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs\WEB-INF\web.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs\META-INF\context.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\webapps\tomcat-docs\META-INF\context.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\conf\context.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\conf\context.xml
 ###docs] reload resource C:\Program Files\Tomcat 5.5\conf\Catalina\localhost\context.xml.default
 ###docs] reload resource C:\Program Files\Tomcat 5.5\conf\Catalina\localhost\context.xml.default


2) Does the manager app work? yes... I can see it either way

http://www.mysite.com:8080/manager/html
http://localhost:8080/manager/html

3) Have you checked that tomcat is actually starting and able to bind to a port?

   I believe it is. XP Pro comes with a firewall built in. I turned it off that made no difference.
   I also added a tcp port in the xp firewall for port 8080 that did not help once turned back on.
   I can view my default home site which are jsp files placed into :
   C:\Program Files\Tomcat 5.5\webapps\ROOT\home
   How else can I check it is binding?

-ec
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13475863
It shouldn't be a problem but I've had issues in the past with tomcat and cannonical paths names, i.e. ones with spaces in. Since then I've always gone for c:\programs\tomcat5 as my install base.

Are there any error messages in the logs rather than "housekeeping" ones?

I'm also wondering whether your Controller servlet has to be in a package. I know that some web components (like javabeans) can no longer be in the default package (where they go when you don't declare a package). So try putting your servlet code in a package and change the web.xml accordingly.
0
 

Author Comment

by:entercite
ID: 13476046
-bloodredsun

 I can try that idea of repackaging... but the sample application should run too... should we try and get that running and see if there is a similar problem with the velocity app second? The same things are happening with both it appears so repackaging might not be the root cause.

-ec
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13476262
I agree, which is why I also mentioned spaces in the directory path.
0
 

Author Comment

by:entercite
ID: 13476377
-bloodredsun

I can try installing in just c:\tomcat later tonight. Do the people at jakarta say that tomcat 5.5.7 does not support spaces too? Are there any other ideas on what could be wrong?

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13477094
>I'm also wondering whether your Controller servlet has to be in a package  
Good spot, bloodredsun

You have package but you need to use instead of
><servlet-class>ControllerServlet</servlet-class>
use (from your initial post file structure)
<servlet-class>com.xxx.common.ControllerServlet</servlet-class>
0
 

Author Comment

by:entercite
ID: 13477127
-rrz

  OK that will be the first thing I try when I get back home!!! Still I am curious the sample.war is that packaged correctly? Should that be in the correct state to run out of the box on tomcat 5.5.7? That still does not run correctly either so I wonder what else is missing.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13477233
>Still I am curious the sample.war is that packaged correctly?  
Does Tomcat unpack it ?  
If so, does the file structure match the pre-installed contexts ?  
0
 

Author Comment

by:entercite
ID: 13478841
rrz-

Never unpacks it. I tried several times downloading the war and deploying with the manager and it fails just like velocity failed. try hitting it in a browser and it gets the 404 error.

0
 
LVL 28

Expert Comment

by:rrz
ID: 13479579
>Should that be in the correct state to run out of the box on tomcat 5.5.7?  
I am confused.
Can you browse to Tomcat's homepage ?
Can you run the pre-installed web apps ? Did you try the JSP 2.0 examples ?
If you just put a web app folder(no war) into Tomcat's webapps folder, then can you run it.                           rrz
0
 
LVL 28

Expert Comment

by:rrz
ID: 13479685
If you just put a web app folder(no war) into Tomcat's webapps folder, then can you run it  ?   Does Tomcat deploy it ?  Keep an eye on Tomcat's log.      rrz
0
 

Author Comment

by:entercite
ID: 13480143
rrz-

1)Can I browse to tomcats home page?
   http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/index.html  
     YES. I can see it. I can also run tomcat locally and view the default web pages it comes with.
     both work http://localhost:8080 and http://www.mysite.com:8080/manager/html

2)Can you run the pre-installed web apps?
  http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample/
  NO. there are no preinstalled app? I download the above one and try to run it but it does not work.

3) Did you try the JSP 2.0 examples ?
 No. where is it? It does not come with it that I can tell.

4) Have not tried to unpack the war file and run it yet. I will when I go home tonight if you think it will show something.

5) I have not tried upacking the velocity application that way. So far I've only placed the war file into webapps and hitting it from the url.
0
 
LVL 28

Expert Comment

by:rrz
ID: 13482117
> I download the above one and try to run it but it does not work.      
Me too, that war is invalid. I tried  to open with WinZip utility as well but no go.  
But, why didn't Tomcat's log tell you this ?    
My log says    
15:17:44,120 ERROR main org.apache.catalina.startup.ContextConfig - Cannot find message associated with key contextConfig.fixDocBase
 java.util.zip.ZipException: error in opening zip file
0
 

Author Comment

by:entercite
ID: 13482298
-rrz

I see the same error in a file called: stdout_20050305.log

Where is a legit version of the sample.war to down and test with?

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13482370
I don't know. I just use the pre-installed web apps that come with Tomcat. Aren't there any in Tomcat's "webapps"  folder
Which binary did you download from Apache ?
0
 

Author Comment

by:entercite
ID: 13482887
No I might have removed them but I dont recall.
The one I got was 5.5.7 exe

I can try removing and installing again.

-ec

0
 
LVL 28

Expert Comment

by:rrz
ID: 13482972
I  think if you download  5.5.7 zip   it  should include examples. I am using 5.5.4 zip.
0
 

Author Comment

by:entercite
ID: 13483080
-rrz

I have reinstalled it and I can now see the examples.

I have put tomcat into c:\tomcat.

I put my controller servelts into a package com.mysite.common and used ant to build the war file. I still get the 404 when i try and hit the url more like the examples version:

http://localhost:8080/velocity/servlet/controller?action=login

does it need the servlet directory? I am so confused as to why 5.5.7 is so much harder to use.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13483189
Please show us your context's web.xml .  
0
 
LVL 28

Expert Comment

by:rrz
ID: 13483207
0
 

Author Comment

by:entercite
ID: 13483391
I will look at the http://www.coreservlets.com/Apache-Tomcat-Tutorial

Here is my web.xml unedited:

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
   
  <!-- Define servlets that are included in the example application -->
  <servlet>  
    <servlet-name>controller</servlet-name>
    <servlet-class>com.entercite.common.ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.entercite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.entercite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.entercite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.entercite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
    <init-param>
      <param-name>source</param-name>
      <param-value>../webapps/velocity/WEB-INF/classes/com/entercite/timetracker</param-value>
    </init-param>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>controller</url-pattern>
  </servlet-mapping>
 
</web-app>
0
 
LVL 28

Expert Comment

by:rrz
ID: 13483451
Change  
  <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>controller</url-pattern>
  </servlet-mapping>
to    
  <servlet-mapping>
    <servlet-name>controller</servlet-name>
    <url-pattern>whatever</url-pattern>
  </servlet-mapping>
and use    
http://www.entercite.com:8080/velocity/whatever
0
 
LVL 28

Expert Comment

by:rrz
ID: 13483458
0
 

Author Comment

by:entercite
ID: 13483484
I made the change ran ant put the war file into wepapps and attempted the run it.

404 error..

also tried to start it via the manager and it gives the same error:

FAIL - Application at context path /velocity could not be started
0
 

Author Comment

by:entercite
ID: 13483487
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
   
  <!-- Define servlets that are included in the example application -->
  <servlet>  
    <servlet-name>controller</servlet-name>
    <servlet-class>com.entercite.common.ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.entercite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.entercite.com:8080/velocity/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
      <param-name>imageUrl</param-name>
      <param-value>http://www.entercite.com:8080/velocity/jsp/images/</param-value>
    </init-param>
    <init-param>
      <param-name>jspHome</param-name>
      <param-value>http://www.entercite.com:8080/velocity/jsp/</param-value>
    </init-param>
    <init-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:odbc:TimeTracker</param-value>
    </init-param>
    <init-param>
    <init-param>
      <param-name>source</param-name>
      <param-value>../webapps/velocity/WEB-INF/classes/com/entercite/timetracker</param-value>
    </init-param>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>controller</servlet-name>
    <url-pattern>whatever</url-pattern>
  </servlet-mapping>
 
</web-app>

in ie is complains... about the web.xml file.

</servlet>
----^
0
 

Author Comment

by:entercite
ID: 13483492
I fixed that...it had one extra </init-param>

still not working.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13483608
>FAIL - Application at context path /velocity could not be started  
Did you try without war, just try web app folder.  
0
 

Author Comment

by:entercite
ID: 13486422
-rrz

 Have not tried with just the web folder recently but I tried that before and that did not work. I am not very confident that it will make a difference this time. I will try it tonight though.

Are there any other ideas? Is tomcat 5.5.7 so much different and this difficult to setup for most people?

-ec
0
 

Author Comment

by:entercite
ID: 13486628
In your link you sent on configuring tomcat it has points:

4 Turn on servlet reloading. Edit install_dir/conf/context.xml  and change <Context> to <Context reloadable="true">.
5 Enable the invoker servlet. Go to install_dir/conf/web.xml and uncomment the servlet and servlet-mapping elements that map the invoker servlet to /servlet/*.

I dont believe I did either...

I always see paths like this now in 5.5.7:
http://www.xxx.com:8080/webAppName/servlet/ServletName

my old url was:
http://www.entercite.com:8080/velocity/ControllerServlet?action=login
0
 
LVL 28

Expert Comment

by:rrz
ID: 13486923
> Is tomcat 5.5.7 so much different and this difficult to setup for most people?
I don't think so. It is pretty much the same. The only difference is the logging has to be configured in Tomcat 5  where as 4 had default logging.  
>5 Enable the invoker servlet  
The use of the invoker is not recommended anymore.  That is why we use servlet mapping tags in context's web.xml file.       rrz
0
 

Author Comment

by:entercite
ID: 13492507
-rrz

Running out of ideas I came up with this plan...

I am trying to build a simple helloWorld servlet example similar to my velocity app but very simple to test building and deploying it.

Would it be possible to email this simple example and explore what I am doing wrong in my app?

-ec
0
 

Author Comment

by:entercite
ID: 13492684
Anyone interested in looking at this test package can email me at entercite@mail.com I can I will sent to you. I am experiencing the same problem with it as I am with the velocity app.

-ec

0
 
LVL 28

Expert Comment

by:rrz
ID: 13493002
>but very simple to test building and deploying it.
Ok, here is my basic "test" web app.  
1- make a folder named  test
2- make a file named  hello.jsp with the following contents
-----------------------------------------------------------
<%="hello from test"%>
------------------------------------------------------------
3- put  hello.jsp file into test folder
4- make a folder named WEB-INF
5- put WEB-INF folder into test folder
6- make a file named web.xml  
-----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">

</web-app>
---------------------------------------------------------------------------------------------
7- put  web/xml file into WEB-INF folder
8- Start Tomcat and browse to  http://localhost:8080/test/hello.jsp  

Next, if that works, then we can add a test servlet.            rrz
0
 

Author Comment

by:entercite
ID: 13494964
Your hello from test worked.

I tried to make a servlet version...

test
  |-ant (build.xml)
  |-lib
  |-deploy(test.war)
      |-api (servlet-2_3.jar)  <--- is this a problem?
  |-WEB-INF (web.xml)
        |-classes
             |-com
                 |-test
                     |-app (HelloWorld.java)


Here is my build.xml
called by
call ant.bat dev

<project name="test" default="test" basedir="..">

  <!-- Initialization -->
  <property name="app.name" value="HelloWorld"/>
  <property name="deploy.home" value="deploy"/>
  <property name="build.home" value="build"/>

 
  <!-- Builds Webapp, this is a fast step when developing -->
  <target name="dev" depends="compile">
    <property name="web.home" value="${build.home}/${app.name}"/>
   
    <jar destfile="${deploy.home}/test.war">
      <fileset dir="${build.home}"/>
    </jar>
   
  </target>
   
  <!-- Compile the all java source for web application -->
  <target name="compile" depends="prepare">
    <javac
      srcdir="WEB-INF"
      destdir="${build.home}/WEB-INF/classes/"
      classpathref="compile.classpath"
      debug="on"
      optimize="on"
      deprecation="off"
      includeAntRuntime="yes"
      failonerror="true"
    />
  </target>

  <!-- Cleanup the deployment directory -->
  <target name="clean">
    <delete dir="${deploy.home}"/>
    <delete dir="${build.home}"/>
  </target>


  <!-- Prepare a fresh deployment directory -->
  <target name="prepare" depends="clean">

    <!-- Build directory structure -->
    <mkdir dir="${deploy.home}"/>
    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.home}/WEB-INF/classes"/>
    <mkdir dir="${build.home}/lib"/>

    <copy todir="${build.home}/lib" flatten="yes">
      <fileset dir="lib" includes="**/*.jar, **/*.zip" />
    </copy>

    <copy file="WEB-INF/web.xml" todir="${build.home}/WEB-INF/" overwrite="yes" />
   
    </target>
 
  <!-- Set compile classpath -->
  <path id="compile.classpath">
    <fileset dir="${build.home}/lib">
      <include name="**/*.jar"/>
      <include name="**/*.zip"/>
    </fileset>
  </path>  

</project>

Here is my web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
   
  <!-- Define servlets that are included in the example application -->
  <servlet>  
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>com.test.app.HelloWorld</servlet-class>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>HelloWorld</url-pattern>
  </servlet-mapping>
 
</web-app>


here is my helloworld app:

package com.test.app;

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

public class HelloWorld extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Hello World!</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Hello World!</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

When i deploy it fails to 404 just like the other servlet apps.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13496307
>When i deploy it fails to 404 just like the other servlet apps.
What did you type in browser  address bar  ?  
Manwhile I will try to test your latest code.    rrz
0
 
LVL 28

Expert Comment

by:rrz
ID: 13498755
I am sorry. I posted the wrong syntex way up above here.  
><url-pattern>controller</url-pattern>
that should have been  
       <url-pattern>/controller</url-pattern>
><url-pattern>HelloWorld</url-pattern>

should be
<url-pattern>/HelloWorld</url-pattern>  

 I used your code(thanks for posting) and put the generated war file into my Tomcat. Upon start up I looked at Tomcat's manager. I saw that Tomcat didn't start the web app. But it was listed. So. I stopped Tomcat and found this in logs.

 09:07:45,930 ERROR main org.apache.commons.digester.Digester - End event threw exception
 java.lang.reflect.InvocationTargetException    .......
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> HelloWorld in servlet mapping         ...........
09:07:45,930 ERROR main org.apache.catalina.startup.ContextConfig - Parse error in application web.xml
 java.lang.IllegalArgumentException: Invalid <url-pattern> HelloWorld in servlet mapping    


Also, please look at your war file. The structure isn't right.

0
 
LVL 28

Expert Comment

by:rrz
ID: 13498766
> look at your war file  
I just use WinZip utility.
0
 
LVL 28

Expert Comment

by:rrz
ID: 13498809
Why didn't your logging work ?
0
 

Author Comment

by:entercite
ID: 13501375
-rrz

 so the problem is the <url-pattern>/HelloWorld</url-pattern>  
With that change it should work?

 Something in yours worked that did not on mine is that what happened? What is wrong with the structure? I believe I have made it just as I had shown above.

 Would you be willing to email the dev folder you used based on my structure so I could compare the two, if you got your version to work that is.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13501794
>With that change it should work?
I think so.
>What is wrong with the structure?  
The lib folder should be inside the WEB-INF folder.  If you don't have WinZip then you can use the command line to unpack a war. Or look at the app folder created by Tomcat when it deployed it.  
>Would you be willing to email    
That is not EE policy.  
I just ran your code. The only change is the /  
What about your Tomcat log ?           rrz
0
 

Author Comment

by:entercite
ID: 13502126
-rrz

OK. I got the heloWorld app to compile and deploy correctly. I tried to apply the same thing to my velocity app but it still is not working.

Do I have to place the jsp files in the web-inf too?

I simpliefied my web-xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
   
  <!-- Define servlets that are included in the example application -->
  <servlet>  
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>com.entercite.common.ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.entercite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.entercite.com:8080/velocity/servlet/controller/param-value>
    </init-param>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>controller</servlet-name>
    <url-pattern>/controller</url-pattern>
  </servlet-mapping>
 
</web-app>

the manager still complains when i try and start:

FAIL - Application at context path /velocity could not be started

I will try and look through the logs again.

-ec
0
 

Author Comment

by:entercite
ID: 13502170
Crap thought it might have been my xml that I just fiexed again but its not...
I just used ie and validated it.


<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
   
  <!-- Define servlets that are included in the example application -->
  <servlet>  
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>com.entercite.common.ControllerServlet</servlet-class>
    <init-param>
      <param-name>home</param-name>
      <param-value>http://www.entercite.com:8080/velocity/</param-value>
    </init-param>
    <init-param>
      <param-name>base</param-name>
      <param-value>http://www.entercite.com:8080/velocity/servlet/controller</param-value>
    </init-param>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>controller</servlet-name>
    <url-pattern>/controller</url-pattern>
  </servlet-mapping>
 
</web-app>
0
 

Author Comment

by:entercite
ID: 13502257
I have log4j on and its set to DEBUG...
There is so much in that file but I dont see any stack traces.

-ec
0
 

Author Comment

by:entercite
ID: 13502483
setting the log4j setting to ERROR

I get:

Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name controller
      at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2228)
      at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2208)
      ... 43 more

ERROR Thread-1 org.apache.catalina.startup.ContextConfig - Parse error in application web.xml
 java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name controller
0
 
LVL 28

Accepted Solution

by:
rrz earned 1000 total points
ID: 13502514
Ok, I found another error in your web.xml.  The <servlet-name> needs to match in the two tags. Any one name will do.
>Do I have to place the jsp files in the web-inf too  
No, don't put them in there. Browser could not access.  
>There is so much in that file but I dont see any stack traces  
I just set mine to  INFO.                rrz
0
 

Author Comment

by:entercite
ID: 13502711
-rrz

ok
Hmm it deploys now... but when i try and launch the app:

http://www.entercite.com:8080/velocity/servlet/ControllerServlet?action=login

type Status report

message /velocity/jsp/null

description The requested resource (/velocity/jsp/null) is not available.

I have two ideas on this.
1) I moved my ControllerServlet into
  velocity\WEB-INF\classes\com\entercite\common

It used to be in WEB-INF

2) In the controllerServlet I have it read my jsp mapping files... located in
  velocity\config\webActions.txt

In the controller I hard coded a path:

    String path =
        "../webapps/velocity/config/webActions.txt";

    actionConfig.load(path);

    /**Process the HTTP Post request*/
    public void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException
    {
        String base = "/jsp/";
        String url = base + "script/Scripting.jsp";
        String action = request.getParameter("action");
       
        this.getServletContext().setAttribute("english",resourceBundleENGLISH );
        this.getServletContext().setAttribute("france",resourceBundleFRANCE );

        if (action != null) {
            if(action.equals("reloadList") ) {
                 actionConfig.load(path);
            }
            if(action.equals("testlogin") ) {
                request.setAttribute("clientManager", this.clientManager );

            }
            url = base + actionConfig.getAction(action);
           
        }

        RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(url);
        requestDispatcher.forward(request, response);
    }

Could this be the cause of the current problem?

-ec
 
0
 

Author Comment

by:entercite
ID: 13502825
hmm moving the webactions did not matter it appears...

Starting the container in command I see this error or whatever it is...


Mar 9, 2005 9:27:06 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Tomcat\webapps\velocity\WEB-INF\lib\servlet-2_3.jar) - jar not loaded. See Servlet Spec 2.3, se
ction 9.7.2. Offending class: javax/servlet/Servlet.class
0
 
LVL 28

Expert Comment

by:rrz
ID: 13502853
>message /velocity/jsp/null
What part of your code is producing this ?  

>http://www.entercite.com:8080/velocity/servlet/ControllerServlet?action=login 
Are you using the invoker servlet or are you using  
<url-pattern>/servlet/ControllerServlet</url-pattern> in servlet mapping tag.

0
 
LVL 28

Expert Comment

by:rrz
ID: 13502891
>servlet-2_3.jar
What is this jar ?
0
 

Author Comment

by:entercite
ID: 13502990
-rrz

 servlet-2_3.jar it allows me to compile my servlets in ant. I need it I think to compile?

I am seeing my default page now at:

http://www.entercite.com:8080/velocity/ControllerServlet?action=login

There are some issues with it not finding my css file and the jdbc stuff I think but I have to take a break for a moment.

-ec
0
 
LVL 28

Expert Comment

by:rrz
ID: 13506437
>servlet-2_3.jar it allows me to compile my servlets in ant  
I just point to Tomcat's jar in my classpath.       rrz
0
 

Author Comment

by:entercite
ID: 13513230
Stupid question I installed mySQL but I am not sure where the stupid host_name is...
Is that the name of the computer in properties of My Computer?

Using this pattern jdbc:mysql://host_name:port/dbname

Like:
"jdbc:mysql://ComputerName/test?user=monty&password=greatsqldb");
0
 

Author Comment

by:entercite
ID: 13513444
This is the last problem then its finally switched over for everything.... Should I log this as a second question and close this one?

The MySql connection test. Never connects. I have MySql 4.1.10.
I put the mysql-connector.jar into my classpath that did not seem to help.
I tried downloading a new jdbc driver mysql-connector-java-3.0.16-ga-bin.jar and putting into C:\java\jre1.5.0_01\lib\ext

Not sure what the problem is for sure.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcExample {

  public static void main(String args[]) {
    Connection con = null;

    String url = "jdbc:mysql://entercite:3306/TimeTracker";
    String username = "?user=root";
    String password = "&password=blue1zone";

    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      //con = DriverManager.getConnection(url + username + password);

      con = DriverManager.getConnection("jdbc:mysql://entercite/test?user=root&password=test");

      if(!con.isClosed())
        System.out.println("Successfully connected to MySQL server using TCP/IP...");

    } catch(Exception e) {
      System.err.println("Exception: " + e.getMessage());
    } finally {
      try {
        if(con != null)
          con.close();
      } catch(SQLException e) {}
    }
  }
}
0
 
LVL 28

Expert Comment

by:rrz
ID: 13513581
I am weak on the db stuff, sorry. You should google this site for similar code.    rrz
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13524097
What's the error code?

(and technically this should be another question!!!)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
A solution for Fortify Path Manipulation.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question