Apache in front of Tomcat not working - java

I am using the following example file: https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/ and have deployed it on Tomcat.
I want to put Apache in front of Tomcat. I have the following config on my Tomcat's server.xml:
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
My Apache is running on port 80, and my workers.properties looks as follows:
worker.list=jboss,tomcat
worker.jboss.port=8009
worker.jboss.host=127.0.0.1
worker.jboss.type=ajp13
worker.tomcat.port=8010
worker.tomcat.host=127.0.0.1
worker.tomcat.type=ajp13
Note that I also have JBoss running. Then my uriworkermap.properties looks as follows:
/App/*=jboss
/sample/*=tomcat
/sample=tomcat
/sample/=tomcat
The JBoss config works fine. If I go to http://localhost:8081/sample/ my webpage is displayed. But if I go to http://localhost:80/sample/ I get a
The Webpage cannot be found error. What am I doing wrong?
This is what http://localhost:8081/sample/ looks like:

you can't run a java app on apache web server. you need a servlet container like tomcat to run a java app. If you want to use apache as a gateway to your app deployed at tomcat, you can have some static file or cgi script in your apache server and that script or html file could call your app deployed at tomcat. URL http://localhost:80/sample/ is not working because it's expecting a file name sample in your apache's www (usually) directory and your probably don't have that file in there.

Related

ajp/1.3 port no is not showing in apache tomcat

I was running my web program in eclipse ide using apache tomcat but while changing my port number I didn't find ajp/1.3 port, I think in past while solving an error I tried to change it and now it's not there, I tried to reinstall apache tomcat but still, it's not coming.
please help me
Go to the Tomcat server conf($Tomcat_Home/conf) directory and check the AJP connector available or not in server.xml. If not the add below entry in server.xml after HTTP connector.
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

How do I use http://example.com instead of http://example.com/Example/?

Here /Example is my .war file and all file in it in .jsp format.
I have access my .war via http://example.com:8080.
How can I access it via http://example.com?
You can find the anwser in the Tomcat documentation at: https://tomcat.apache.org/tomcat-6.0-doc/config/http.html
You can do one of the following:
1) Edit the conf/server.xml file in your tomcat installation folder. (I assume you are using tomcat, if not - look for an equivalent file for your web server). Here is a sample entry (edit the port here)
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
Restart tomcat.
2) The second way is to use re-directs or url-rewrites to forward traffic to port 8080 to port 80.
Change the http connector port from 8080 to 80 in your tomcat's server.xml. Look for <Connector tag and there you will see port attribute
Rename your WAR file to ROOT.war, the name ROOT for tomcat means that it is the root context (all capital letters) and the name is reserved for such this purpose. See https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
Next, change the listener port in conf/server.xml from 8080 to 80.

How to deploy a java application as root in tomcat without allow access to other webapps

I have a java application.war and I copied the file to tomcat7/webapps directory.
I'm able to access it with www.application.com/application (My domain points to ip 200.xyz.12.jk:8080) BUT
I want to access it through www.application.com (without the name of the folder inside webapps directory)
Also i dont want to allow access to other folders inside webapps.
I have tried some topics but didnt succeed.
Failed to help:
Deploying my application at the root in Tomcat
https://josefbetancourt.wordpress.com/2011/02/12/tomcat7-change-root-app/
Tomcat 6: How to change the ROOT application
Thank you so much
Place your tomcat under apache http server then point it to tomcat's AJP protocol.
Example of Apache httpd.conf configuration:
Listen 80
ProxyPass / ajp://application.com:8009/application
In tomcat server.xml file you should have below ajp connector:
<Connector port="8009" protocol="AJP/1.3" />
As a result www.application.com/ url points to the application entire directory over ajp protocol.
Hope this will help you.

Corrupted special characters using Jersey and Tomcat 7

I have a strange problem with special characters. They are corrupted but
when I run it on localhost (Tomcat 7.0.12) is everything ok, when I deploy it at remote server (Tomcat 7.0.34) the characters are corrupted. I am realy confused.
Does anybody have similiar problem?
localhost:
wikicategory_Languages_of_São_Tomé_and_Príncipe
wikicategory_Subject–verb–object_languages
remote server:
wikicategory_Languages_of_S��o_Tom��_and_Pr��ncipe
wikicategory_Subject���verb���object_languages,
note: I have set utf-8
in endpoint:
#Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
in server configuration:
server.xml
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="utf-8"
maxPostSize="0"
maxHttpHeaderSize="131072" />

Running Multiple Tomcat Instances on One Windows Machine

I downloaded apache-tomcat-6.0.35 & put it in tomcat folder.
I did accroding to to this:
http://builddeploy.blogspot.com/2010/02/running-multiple-tomcat-instances-on.html
My tomcat directory structure is
tomcat
apache-tomcat-6.0.35
bin,conf,lib,logs,temp,webapps,work //Folders name
tomcatclpl
bin,conf,logs,temp,webapps,work //Folders name
tomcatmass
bin,conf,logs,temp,webapps,work //Folders name
and apache-tomcat-6.0.35's server.xml file port is 8085
<Server port="8005" shutdown="SHUTDOWN">
and
<Connector port="8005" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
and tomcatclpl's conf - server.xml file I have changed following
<Server port="8205" shutdown="SHUTDOWN">
and
<Connector port="8282" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
and
<Connector port="8209" protocol="AJP/1.3" redirectPort="8443" />
same like tomcatmass also i have changed the port as 8383.
My starup.bat file is:
#echo off
#echo Tomcat CLPL Service
set "CATALINA_BASE = C:\Tomcat\tomcatclpl"
set "CATALINA_HOME=C:\Tomcat\apache-tomcat-6.0.35"
C:\Tomcat\tomcatclpl\bin\startup.bat
When I run in cmd line;
C:\Tomcat\tomcatclpl>startup.bat
Tomcat MASS Service
Using CATALINA_BASE: "C:\Tomcat\tomcatclpl"
Using CATALINA_HOME: "C:\Tomcat\tomcatclpl"
Using CATALINA_TMPDIR: "C:\Tomcat\tomcatclpl\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.6.0_01"
Using CLASSPATH: "C:\Tomcat\tomcatclpl\bin\bootstrap.jar"
C:\Tomcat\tomcatclpl>
This `bootstrap.jar file not started. Please help me out.
Because of the reason CATALINA_BASE & CATALINA_HOME taking same path
I couldn't to fixed this problem
I sort out the problem. First we should start the default tomcat server. Then only need to start instance servers
#echo off
#echo Tomcat CLPL Service
set "CATALINA_HOME=C:\Tomcat\apache-tomcat-6.0.35"
set "CATALINA_BASE=C:\Tomcat\tomcatclpl"
C:\Tomcat\apache-tomcat-6.0.35\bin\startup.bat
edit startup.bat
set CATALINA_BASE=..
set CATALINA_HOME=#catalina.home#
set CATALINA_OPTS=-server -Xms#jvm.minmemory#m -Xmx#jvm.maxmemory#m
"%CATALINA_HOME%\bin\catalina" run %1 %2 %3 %4 %5 %6 %7 %8 %9
More info can be found on Configuring Separate Instances Using CATALINA_BASE
#echo off
#echo Tomcat CLPL Service
set CATALINA_BASE="C:\Tomcat\tomcatclpl"
set CATALINA_HOME="C:\Tomcat\apache-tomcat-6.0.35"
C:\Tomcat\tomcatclpl\bin\startup.bat
This the way I normally sets the env variables
Let me fill this one out;
You unpack the tomcat zip twice, into two different folders
Go open commandpromt as administrator
navigate to 'tomcat1'\bin\
run service install tomcat1
navigate to 'tomcat2'\bin\
call on the commandline: set "CATALINA_HOME=C:\path\to\tomcat2\"
run service install tomcat2
Now you will see two services in your environment (the services.msc). Each called by the X being 1 or 2 as such: "Apache Tomcat tomcatX". They have the correct base/home variable and should point to the correct lib\ folder (thus bootstrap.jar is available to start the server with).
Problem is, the tool tomcat6w.exe with which you can control the service. It will only function (at least for me) with the default server, namely the first service installed. To bypass this and get the opportunity to define variables to the java environment, we need to find stuff with regedit.exe
Navigate the registry for: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\tomcat1\Parameters\Java
set Options / Xms / Xmx
figure out the rest (find tomcat2 in same tree)

Categories

Resources