• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to put my Java project in production server VPS CentOS 8.

 
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I finished my project java web and I wanna load to production I do this simply transferring  my .war file by FileZilla client but when I call the page the browser load the test page of apache. What more I must todo to solve this problem? This is my first time that I do transfer to production environment.

Thanks in advance.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say "test page of apache", do you mean the actual Apache page with the feather on it, or the Apache Tomcat page?

If it's Apache httpd, then you need to have it define a virtual host that will cause Apache to proxy to the Tomcat webapp.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you by return, yes is the test page of my virtual host hosted in my vps.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry by delay, I initiated this contact with error of interpret.
I have an vps domain hosted on Locaweb with CentOS 8, in my domain I created an subdomain called "demonstracao.itcmedbr.com", in centos 8 I created in "/etc/httpd/sites-available/demonstracao.itcmedbr.com" that contain " <VirtualHost *:80>
       ServerName www.demonstracao.itcmedbr.com
       ServerAlias demonstracao.itcmedbr.com
       DocumentRoot /var/www/demonstracao.itcmedbr.com/html
       ErrorLog /var/www/demonstracao.itcmedbr.com/log/error.log
       CustomLog /var/www/demonstracao.itcmedbr.com/log/requests.log combined
</VirtualHost>". When I call in the browser demonstracao.itcmedbr.com the browser load the apache test page, I saw that if this page is loaded signify that is ok. Then when I go to deploy my war in tomcat but after long time I receiving: "http://IP Address:8080/manager/html/upload;jsessionid=07B9AAA03A2885D999EE4107D7D39C1B?org.apache.catalina.filters.CSRF_NONCE=6DE72379C89865072AC7B358AE687101". Where I am wronging?
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want URLs for demonstracao.itcmedbr.com to be handled by tomcat, you need to define a reverse proxy in the demonstracao.itcmedbr.com VirtualHost. Use either Apache mod_proxy or mod_jk to indicate where the tomcat server is, and how the URLs are to be routed to it.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed my virtual host to include proxy parameter, now I receiving "Is not possible to access this site".
"<VirtualHost *:80>
       ServerName www.demonstracao.itcmedbr.com
       ServerAlias demonstracao.itcmedbr.com
       DocumentRoot /var/www/demonstracao.itcmedbr.com/html
       ErrorLog /var/www/demonstracao.itcmedbr.com/log/error.log
       CustomLog /var/www/demonstracao.itcmedbr.com/log/requests.log combined
       ProxyRequests off
       ProxyPreserveHost On
       ProxyPass / http://localhost:8080/
       ProxyPassReverse / http://localhost:8080/
</VirtualHost>".
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After include the IP and site name in /etc/hosts I am receiving:
"Request Timeout
Server timeout waiting for the HTTP request from the client.

Additionally, a 502 Bad Gateway error was encountered while trying to use an ErrorDocument to handle the request."
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An HTTP 502 Bad Gateway error means that the Apache server received a request to proxy, but the  backend server being proxied did not respond.

That can happen when the backend server (Tomcat) is down or when it does not respond to the requests being proxied from apache because the requests are being sent to the wrong server or the wrong port. So Tomcat has to be running on the same host as Apache and listening on port 8080.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I change proxy to 80 I gain error when call tomcat to deploy.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I change proxy to 80 I gain error when call tomcat to deploy and if I change httpd.conf I receive error too.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache listens on port 80. Tomcat listens on port 8080. Only one application can run on a port at a time. So Tomcat cannot listen on port 80. Even if Apache was not running, Tomcat could not listen on port 80 unless it was running as a privileged user, and that's a bad idea.

Your proxy must therefore forward to the tomcat server address, port 8080.

For details (Tomcat 9) see https://tomcat.apache.org/tomcat-9.0-doc/proxy-howto.html

Note that they added port 8081 to the server.xml Connectors so that Tomcat could handle direct requests on port 8080, but also understand that proxy requests would come in on port 8081.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a connector in my server.xml but the problem still the same.
" <Connector port="8081" protocol="HTTP/1.1"
               proxyPort="80"/>"
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If by "still the same", you mean "502 error" then either Tomcat is not running on the same machine as the Apache server is or it could not open the connector port.

If it's a connector problem, you can use the netstat command to determine if port 8081 was opened and look at the Tomcat logs to see if it had a problem opening port 8081.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim, I did the deploy of my .war file with configuration below.
httpd.conf:
ProxyPass               /       http://localhost:8081/
ProxyPassReverse        /       http://localhost:8081/

server.xml:
<Connector port="8081" protocol="HTTP/1.1"
               proxyName="www.demonstracao.itcmedbr.com"
               proxyport="80"/>

sites-available:
<VirtualHost *:80>
       ServerName www.demonstracao.itcmedbr.com
       ServerAlias demonstracao.itcmedbr.com
       DocumentRoot /var/www/demonstracao.itcmedbr.com/html
       ErrorLog /var/www/demonstracao.itcmedbr.com/log/error.log
       CustomLog /var/www/demonstracao.itcmedbr.com/log/requests.log combined
       ProxyRequests off
       ProxyPreserveHost On
       ProxyPass / http://localhost:8081/
       ProxyPassReverse / http://localhost:8081/
</VirtualHost>

But the problem is that when I call my page "demonstracao.itcmedbr.com" the tomcat page is loaded.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you mean "tomcat page" is the default Tomcat home page with the cat picture on it, that means that you are proxying successfully. However, you are proxying to the root webapp for that Tomcat server.

If you have deployed your webapp under the context path "/mywebapp" (your WAR is named mywebapp.war and thus the exploded WAR directory is TOMCAT_HOME/webapps/mywebapp) then your Apache proxy statements need to look like this:
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes is  default Tomcat home page with the cat picture on it.
After made change the problem is the same.
"<VirtualHost *:80>
       ServerName www.demonstracao.itcmedbr.com
       ServerAlias demonstracao.itcmedbr.com
       DocumentRoot /var/www/demonstracao.itcmedbr.com/html
       ErrorLog /var/www/demonstracao.itcmedbr.com/log/error.log
       CustomLog /var/www/demonstracao.itcmedbr.com/log/requests.log combined
       ProxyRequests off
       ProxyPreserveHost On
       ProxyPass / http://localhost:8081/demonstracao.itcmedbr.com/
       ProxyPassReverse / http://localhost:8081/demonstracao.itcmedbr.com/
</VirtualHost>"
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am receiving this error when click "start" on my .war file deployed in Tomcat Web Application Manager page.
"FAIL - Application at context path [/demonstracao] could not be started
FAIL - Encountered exception [org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demonstracao]]]"
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, you have a Tomcat problem and there should be a stack trace in the catalina.out log that indicates why the webapp at /demonstracao did not deploy.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I saw the catalina.log but I don't see problem.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:
FAIL - Encountered exception [org.apache.catalina.LifecycleException: Failed to start component


Look again. An exception should have output a stack trace. If it isn't there, look in the Tomcat localhost log file(s).
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim sorry by delay, I uninstall Tomcat 10 and installed Tomcat 9 but don't solved the problem. If I enter with http://Ip address:80 to be load only apache test page the default Tomcat home page is loaded if I enter demonstracao.itcmedbr.com default Tomcat home page is loaded. Below is result of

"/var/www/demonstracao.itcmedbr.com/log/error.log

[Sat Aug 27 06:31:26.012683 2022] [proxy:error] [pid 88599:tid 140003887789824] (32)Broken pipe: [client 152.232.222.108:52232] AH01084: pass request body failed to [::1]:8081 (localhost), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:31:26.012775 2022] [proxy_http:error] [pid 88599:tid 140003887789824] [client 152.232.222.108:52232] AH01097: pass request body failed to [::1]:8081 (localhost) from 152.232.222.108 (), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:35:11.218686 2022] [proxy:error] [pid 88903:tid 140004203874048] (32)Broken pipe: [client 152.232.222.108:52342] AH01084: pass request body failed to [::1]:8081 (localhost), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:35:11.218779 2022] [proxy_http:error] [pid 88903:tid 140004203874048] [client 152.232.222.108:52342] AH01097: pass request body failed to [::1]:8081 (localhost) from 152.232.222.108 (), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:47:15.570543 2022] [proxy:error] [pid 89545:tid 140443828324096] (32)Broken pipe: [client 152.232.222.108:52597] AH01084: pass request body failed to [::1]:8081 (localhost), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:47:15.570618 2022] [proxy_http:error] [pid 89545:tid 140443828324096] [client 152.232.222.108:52597] AH01097: pass request body failed to [::1]:8081 (localhost) from 152.232.222.108 (), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:48:56.602050 2022] [proxy:error] [pid 90009:tid 140443968554752] (32)Broken pipe: [client 152.232.222.108:52623] AH01084: pass request body failed to [::1]:8081 (localhost), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 06:48:56.602114 2022] [proxy_http:error] [pid 90009:tid 140443968554752] [client 152.232.222.108:52623] AH01097: pass request body failed to [::1]:8081 (localhost) from 152.232.222.108 (), referer: http://demonstracao.itcmedbr.com/manager/html
[Sat Aug 27 07:16:58.378654 2022] [proxy:warn] [pid 90009:tid 140443887073024] [client 118.126.82.157:52352] AH01092: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be www.demonstracao.itcmedbr.com for uri /mysql/scripts/setup.php
[Sat Aug 27 07:16:58.404213 2022] [proxy:warn] [pid 89545:tid 140443819931392] [client 118.126.82.157:52356] AH01092: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be www.demonstracao.itcmedbr.com for uri /pma/scripts/setup.php
@@@"
Thanks.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing that caught my attention is that on all the tomcat installation instruction sites the path of Environment of java on all sites of install Tomcat is the path in tomcat.service for Environmet=JAVA_HOME, these sites use /usr/lib/jvm/jre but in my CentOS 8 I don't have jvm directory in /usr/lib, I installed jdk 17.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are like a person attempting to stop a flood by building a dam in the wrong river.

There was nothing wrong with Tomcat. If there had been, you would not have gotten the Tomcat main page.

The fault is in your proxypass definitions for demonstracao.itcmedbr.com. You cannot simply proxy to Tomcat, you must proxy to the specific application in Tomcat that you want the proxy to represent. Tomcat can host multiple webapps and generally hosts at least 2: the management (default) app and your own app.

Also, I see PHP URLs in your error log. I think you've managed to mix together 2 separate webapp definitions in Apache.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have installed php.



 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That VirtualHost definition will route EVERY URL request made to the Apache machine to the ROOT application in the Tomcat server on that machine.

A VirtualHost should normally have a hostname, not "*" and I've already shown you what you need to put in the ProxyPass definitions for it.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My configuration.
httpd.conf:

server.xml:

sites-available:

When I call my page demonstracao.itcmedbr.com in the browser the tomcat page is loaded but if I call "demonstracao.itcmedbr.com/demonstracao/" my correct page is loaded. "itcmedbr.com" is my domain I trying to create a subdomain in that case is "demonstracao".
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I repeat:

Tim Holloway wrote: You cannot simply proxy to Tomcat, you must proxy to the specific application in Tomcat that you want the proxy to represent.


 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understood you, this is the proxy definition for my webapp "demonstracao.itcmedbr.com".
httpd.conf:

Here is the error of deply of my webapp. I increased the value of max-file-size and max-request-size in web.xml but the problem persist.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:If I understood you, this is the proxy definition for my webapp "demonstracao.itcmedbr.com".
httpd.conf:

Here is the error of deply of my webapp. I increased the value of max-file-size and max-request-size in web.xml but the problem persist.



No, you didn't understand me.

Every Tomcat web application has a URL Context path corresponding (usually) to the name of the WAR that was used to deploy it. So if my WAR is named "mywebapp", then the URL context would be "http://localhost:8080/mywebapp".

To get Apache to proxy to mywebapp, the Proxy definitions are as follows:

You proxy to the URL context not the URL's virtual domain.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After change problem still the same.
httpd.conf:

result:

"demonstracao" is my war file to deploy.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally I did the deploy of my application but my page isn't load.
Summary:
httpd.conf:

server.xml:

sites-available:

 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have 2 different sets of ProxyPass statements. One in the master Apache config file (httpd.conf) and one in a file under the sites-available directory.

Why???
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I remove from httpd.conf and leave in sites-available page is not loaded, if I remove from sites-available and leave in httpd.conf page is not loaded too.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:If I remove from httpd.conf and leave in sites-available page is not loaded, if I remove from sites-available and leave in httpd.conf page is not loaded too.



They are TWO DIFFERENT defintions and you aren't putting the right one in the right place.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I transferred demonstracao.war to my /var/www/demonstracao.itcmedbr.com/html with ftp and I did Deploy directory or WAR file located on server. I have an doubt  Context path must be demonstracao or demonstracao.itcmedbr.com?
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:I transferred demonstracao.war to my /var/www/demonstracao.itcmedbr.com/html with ftp and I did Deploy directory or WAR file located on server. I have an doubt  Context path must be demonstracao or demonstracao.itcmedbr.com?



Neither. Using VirtualHost demonstracao.itcmedbr.com:80 and ProxyPass to http://127.0.0.1:8081/demonstracao/ then your URL would be http://demonstracao.itcmedbr.com and there would be no application context path in the external URL.

It  would help if you read the Tomcat documentation with more care.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After include in server.xml:

now I am receiving in browser:
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And why did you put that in server.xml?

Did the instructions tell you to?
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing that I did solved my problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic