WhiteWeedow

Registered
Oct 16, 2013
3
0
1
cPanel Access Level
Reseller Owner
We have users which need tomcat and they need to develop java applications through Java Servlets and we have problem with mapping servlets.

I use one account for testing.
I try run servlet on cpanel tomcat 7 but seems it doesn't work. When i run servlet in jsp file that is ok but mapping servlet doesn't work.

So setup is ok I put web.xml in web-inf folder and all other stuffs are in correct place
Here is web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
<servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.i_do2.java.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>indexp.jsp</welcome-file>
</welcome-file-list>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
When i open url domain.com/TestServlet
I got error page is not found.

Here is example where I run servlet from JSP file and that is ok.
domain.com/jsps.jsp
Code:
<%@page contentType="text/html" pageEncoding="UTF-8" import="com.i_do2.java.TestServlet"%> <% TestServlet ts = new TestServlet(); ts.service(request, response); %>
What is problem with mapping? It's seems that cpanel dont read web.xml file?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

Your access level is listed as "Reseller". Do you have root access to this system? This information will help us better determine which troubleshooting steps to provide.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
To confirm, have you installed servlets for the domain name via the "WHM Home >> Account Functions >> Install Servlets" option?

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Feel free to open a support ticket so we can take a closer look:

Submit A Ticket

While our support team can not directly troubleshoot scripting issues, we can upload an example and make sure it's working as intended. You can post the ticket number here so we can update this thread with the outcome.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Could you clarify what in particular is not working properly, and what steps you have taken thus far?

Thank you.
 

roll-on

Registered
Mar 25, 2013
3
0
1
cPanel Access Level
Root Administrator
We're trying to migrate a site from a tomcat4 (Ensim) box to a current testing cPanel/Tomcat7 instalation. Our JSP sites seem to go fine but we can´t get servlets working.

Here's a xml example on one of the servlets no working.

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

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

    <session-config>
        <session-timeout>840</session-timeout>
    </session-config>

    <servlet>
        <servlet-name>OnlineBarChart</servlet-name>
        <servlet-class>OnlineBarChart</servlet-class>
    </servlet>

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

    <servlet>
        <servlet-name>customerexp</servlet-name>
        <servlet-class>CustomersExport</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>customerexp</servlet-name>
        <url-pattern>/CustomersExport.jsp</url-pattern>
    </servlet-mapping>

</web-app>
Could you give us any hint on this?

Thanks in advance!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Have you tried installing servlets on a domain name via WHM and setting up a test JSP page to rule out any issues with the scripts you are copying over?

Thank you.
 

roll-on

Registered
Mar 25, 2013
3
0
1
cPanel Access Level
Root Administrator
Yes I did.

I installed servlets using command line (/usr/local/cpanel/scripts/addservlets2) and the test page worked ok. Actually the site works fine, the problem seems to be related with the servlet mapping as it's working ok in my ensim box running tomcat4.

Please let me know if more information is needed to troubleshoot this issue
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Could you elaborate more on how we can reproduce this issue? Please note that the scope of support that cPanel offers with Tomcat is to ensure it's running well and that test pages function as expected. Problems related to the script itself fall outside our scope of support.

Thank you.
 

KurtN.

Well-Known Member
Jan 29, 2013
95
1
83
cPanel Access Level
Root Administrator
You should be able to access your servlets in two ways:
  1. Apache (standard ports 80 or 443)
  2. Tomcat (port 8080)

If you want to access these servlets through Apache, then they must be stored in one of the following directories:
  • /home/user/public_html/servlet
  • /home/user/public_html/servlets

Hope this helps.