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 and Servlet mapping

Discussion in 'EasyApache' started by WhiteWeedow, Oct 16, 2013.

  1. WhiteWeedow

    WhiteWeedow Registered

    Joined:
    Oct 16, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    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?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  3. WhiteWeedow

    WhiteWeedow Registered

    Joined:
    Oct 16, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Yes I have root access to the system what I need to change in configuration to enable servlet mapping?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    To confirm, have you installed servlets for the domain name via the "WHM Home >> Account Functions >> Install Servlets" option?

    Thank you.
     
  5. WhiteWeedow

    WhiteWeedow Registered

    Joined:
    Oct 16, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Yes I installed servlet on that way and servlet works only through jsp page but mapping does not work.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  7. roll-on

    roll-on Registered

    Joined:
    Mar 25, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi!

    Have you managed to make it work? I´m struggling with servlets as well.

    Thanks in advance!
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  9. roll-on

    roll-on Registered

    Joined:
    Mar 25, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    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!
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  11. roll-on

    roll-on Registered

    Joined:
    Mar 25, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    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
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,682
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  13. cPanelKurtN

    cPanelKurtN Well-Known Member
    Staff Member

    Joined:
    Jan 29, 2013
    Messages:
    95
    Likes Received:
    1
    Trophy Points:
    8
    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.
     
Loading...

Share This Page