Héctor Espí

Registered
Jul 13, 2015
2
0
1
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.
 
Last edited by a moderator:

Héctor Espí

Registered
Jul 13, 2015
2
0
1
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?.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
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.