aspose file tools*
The moose likes Tomcat and the fly likes Tomcat unable to find servlet in Shared linux java hosting Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat unable to find servlet in Shared linux java hosting Server" Watch "Tomcat unable to find servlet in Shared linux java hosting Server" New topic
Author

Tomcat unable to find servlet in Shared linux java hosting Server

Sumit Lole
Greenhorn

Joined: May 24, 2011
Posts: 5
Hi,
I have a problem trying to set up tomcat to run a simple servlet and hope someone can help out.

I am trying to deploy/upload a Java based web application on Linux based shared Java hosting server. For this I have uploaded the war file on Cpanel, also I have created same file structure as it was in Tomcat.

I have created following structure in public_html directory of Cpanel:

-css
-html
-js
-jsp
-META-INF
----classes
----lib
----web.xml
-WEB-INF
-index.html
-Model.war


*All the classes are kept in classes folder inside web-inf.

Tomcat is running and the index page is visible. I have redirected from index.html page to jlogin.jsp page inside the jsp folder. It working fine with complete effect of css & images and all scripting working fine on jlogin page.

But when I am calling Login servlet from jlogin.jsp page it gives 404 NOT FOUND error. I have tried all possible path to call servlet, still problem persist.

Login.class servlet is located in : WEB-INF/classes/com/org/model/servlets


ERROR is - 404
type Status report
message /Model/Login
description The requested resource (/Model/Login) is not available.


//web.xml follows (located in WEB-INF

<?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 http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5">

<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>com.org.model.servlets.Login</servlet-class>
</servlet>

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

</web-app>

Urgent help is required.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12788
    
    5
Login.class servlet is located in : WEB-INF/classes/com/org/Model/servlets


Is the package name really "com.org.Model.servlets" ???

Bill
Sumit Lole
Greenhorn

Joined: May 24, 2011
Posts: 5
ya I am doing aal thing right.
package is com.org.model.servlets placed inside the classes folder in the WEb-INF directory as mention.

Still getting the error. Is anything else need to do?
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 512
Hi,
Directory named "Model" should be "model". Package names are Case sensitive.

Regards,
Amit
Sumit Lole
Greenhorn

Joined: May 24, 2011
Posts: 5
@ Amit thnks
But here Model is the root directory & model is part of package hierarchy and I mentioned both correctly.

But problem is not in case.
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 512
Hello,
I am not talking about your root directory.

Check this

Login.class servlet is located in : WEB-INF/classes/com/org/Model/servlets


And the package structure in which you are keeping your servlet seems to be
<servlet-class>com.org.model.servlets.Login</servlet-class>


The case of "model" differs and that is the issue.

Hope this clears the doubt and issue.

Regards,
Amit
Sumit Lole
Greenhorn

Joined: May 24, 2011
Posts: 5
Dear Amit,

Problem is not with the case of Model, by mistake I have written that.

Problem is something else.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12788
    
    5
But when I am calling Login servlet from jlogin.jsp page it gives 404 NOT FOUND error.


If your index.html is displayed then we can be sure that Tomcat can recognize the web application. Therefore. the 404 error means something is wrong with your mapping from URL to the servlet.

What exactly is the URL being requested? Is it absolute or relative? Where does the jlogin.jsp page live?

Bill
Sumit Lole
Greenhorn

Joined: May 24, 2011
Posts: 5
Dear Williams and Amit,

Thanks for helping me out.

Here is the complete description of my application:

My application name is Model360, so as the mane of root directory.

In side the root directory, in the application I have different folders for jsp, html, css, js in web application. inside these folders respected files are placed.

In src folder of application i have package hierarchy as follow

com.org.model

Inside this package structure there are 3 sub-packages

beans, servlets and util



This was the structure when I have developed the application and deployed on window based local server.

Now while deploying on Java hosting Shared server, I follows these steps:



In the file manager of Cpanel, inside the public_html initially I have uploaded war file.

After uploading war file I have created jsp, html, css, js, META-INF, WEB-INF folders and uploaded all the files in respected folders.

Now in the WEB-INF folder I placed deployment descriptor (web.xml). Also created two folder lib & classes. In lib I have placed all the jar files.

In the classes folder I have created the same hierarchical structure & placed all the class files.

In public_html I have created index.html file which redirected to 'Model360/jsp/jlogin.jsp'. Now on login action, jlogin.jsp calling 'Model360/Login' servlet.

Now url www.model360feedback.com properly redirecting to jlogin.jsp, but while calling Login servlet it giving 404 error.

Note that for calling login servlet I have tried all possible path & url in jlogin.jsp.





Hopefully this description will clear my query.
nishant nair
Greenhorn

Joined: Apr 29, 2014
Posts: 1
Hi,

I am also facing same kind of error.

My website is deployed on CPanel. Any solution?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat unable to find servlet in Shared linux java hosting Server