Question

About Deploying Java Application to Tomcat

Posted December 12, 2014 9k views

Hi
I tried to deploy my application file to tomcat and I have succeed to deploy them but only I can see my files under http://mydomain.com:8080/myproject/index
assume that my project folder is = myproject
my domain is = mydomain.com

Anyway Only I try to access to my domain like these

http://mydomain.com/index
http://www.mydomain.com/index

How can I do like that ?

Regards

1 comment
  • I just want to know how you deployed the java application in tomcat. I have written the below script.

    !/bin/bash

    apt-get -y update

    Install Java

    sudo apt-get -y install openjdk-7-jdk

    Install tomcat

    sudo apt-get -y install tomcat7

    Install apache

    sudo apt-get -y install apache2

    wget https://acmesanappstor0.blob.core.windows.net/javaproject/test.tar.gz
    tar -xzvf test.tar.gz -C /usr/share/tomcat7/webapps/

    sudo su
    sudo /etc/init.d/tomcat7 restart
    sudo /etc/init.d/apache2 restart

    But it’s not working. Please give me one idea.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

ok I have solved the problem.

in the default server.xml file host-tag like this,

<Host name="localhost" appBase="webapps"
     unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
     Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
     Documentation at: /docs/config/valve.html
     Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  </Host>

but I have removed that and changed like these

<Host appBase="webapps" name="mydomain.com" unPackWars="true" autoDeploy="true">             
    <Context path="" docBase="myproject" debug="0" reloadable="true"/>
  </Host>
  <Host appBase="webapps" name="www.mydomain.com" unPackWars="true" autoDeploy="true">            
    <Context path="" docBase="myproject" debug="0" reloadable="true"/>
  </Host>

and than I have changed

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

like this

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

now it works:)

Submit an Answer