The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomcat 7, servlet not found

Discussion in 'EasyApache' started by Héctor Espí, Jul 13, 2015.

  1. Héctor Espí

    Héctor Espí Registered

    Joined:
    Jul 13, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Alicante
    cPanel Access Level:
    Website Owner
    I know this thread is similar to others in the forum, but none of them give me the clue to solve this issue:

    I have a JAVA application developed using JSP and servlets. This app works properly when deployed to my local Tomcat 7 instance, but a 404 (not found) is returned every time I try to access the servlets.

    .class files are properly stored under the public_html/WEB_INF/classes folder, and JSPs as well as JAVA tags and the rewriting module are working as expected.

    In other threads I have seen that I have to store the servlets under "public_html/servlets" folder, but the question is: what do I have to save?: .class files, web.xml,...

    This is the web.xml content regarding servlet mappings:

    Code:
    <servlet>
            <servlet-name>Login</servlet-name>
            <servlet-class>com.hmz.web.xhr.Login</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>LoginFacebook</servlet-name>
            <servlet-class>com.hmz.web.xhr.LoginFacebook</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>LoginGoogle</servlet-name>
            <servlet-class>com.hmz.web.xhr.LoginGoogle</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>RecoverPassword</servlet-name>
            <servlet-class>com.hmz.web.xhr.RecoverPassword</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>Register</servlet-name>
            <servlet-class>com.hmz.web.xhr.Register</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>UpdatePassword</servlet-name>
            <servlet-class>com.hmz.web.xhr.UpdatePassword</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>UpdateProfile</servlet-name>
            <servlet-class>com.hmz.web.xhr.UpdateProfile</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Login</servlet-name>
            <url-pattern>/xhr/login</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>LoginFacebook</servlet-name>
            <url-pattern>/xhr/login-facebook</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>LoginGoogle</servlet-name>
            <url-pattern>/xhr/login-google</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>RecoverPassword</servlet-name>
            <url-pattern>/xhr/recover-password</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>Register</servlet-name>
            <url-pattern>/xhr/register</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>UpdatePassword</servlet-name>
            <url-pattern>/xhr/update-password</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>UpdateProfile</servlet-name>
            <url-pattern>/xhr/update-profile</url-pattern>
        </servlet-mapping>
    
    
    I appreciate any help before considering another server options.
     
    #1 Héctor Espí, Jul 13, 2015
    Last edited by a moderator: Aug 6, 2015
  2. 24x7ss

    24x7ss Well-Known Member

    Joined:
    Sep 30, 2014
    Messages:
    271
    Likes Received:
    16
    Trophy Points:
    18
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Did you check the catalina error logs when the URL returns 404 error ? May be you have not deployed the app to proper location ?
     
  3. Héctor Espí

    Héctor Espí Registered

    Joined:
    Jul 13, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Alicante
    cPanel Access Level:
    Website Owner
    It's difficult for me to see the logs because I have no access to the apache/tomcat path, just to my app folder (I have to ask the reseller to send that file to me). I'm going to enumerate the steps I have done to publish the application for you to see if there's something wrong/missing:

    1.- Deploy the WAR to my local tomcat installation inside the "webapps" folder. I have checked out that all servlets and JSPs are working properly.
    2.- Remove all the content under the "public_html" folder.
    3.- Upload the contents of my application folder under my local tomcat to the FTP (directly to the public_html).
    4.- Create a .htaccess (I HAVE ONLY ONE .htaccess FILE) file with the following content, in order to have JSP and Rewrite module working:

    SetHandler jakarta-servlet
    SetEnv JK_WORKER_NAME ajp13


    Is there anything I have missed?, do I need another .htaccess inside the WEB_INF folder, and what are its contents?.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    The following document describes how to deploy Java WAR packages:

    How to deploy Java WAR packages

    You may need to consult with your hosting provider if you have followed these steps and your application fails to work.

    Thank you.
     
Loading...

Share This Page