use multiple CATALINA_BASE to setup tomcat 6 instances on windows - windows

The RUNNING.txt that comes with tomcat distribution indicates the use of CATALINA_BASE variable to enable multiple tomcat instance. But how can I set the CATALINA_BASE environment variable for each tomcat instance directory?

Having multiple Tomcat instances on your development machine is great. Here's how I usually do it for Windows (the important parts for setup are in steps 2, 3, 4 and 5):
Install a copy of Tomcat 6 to a directory (like C:\apache-tomcat-6.0.20).
Copy the conf directory to another directory (like C:\tomcat-1)
Under C:\tomcat-1, create a bin directory
In the C:\tomcat-1\bin directory, create a file called startup.bat that reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\startup.bat
In the C:\tomcat-1\bin directory, create a file called shutdown.bat that reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\shutdown.bat
OPTIONAL: create a file called setenv.bat in the C:\tomcat-1\bin directory to set any environment variables mentioned in C:\apache-tomcat-6.0.20\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.
Create the logs, temp, webapps and work directories under C:\tomcat-1
From the C:\tomcat-1 directory, run bin\startup.bat
Repeat for your other installs from step 2 for as many tomcat instances as you need.
Try not to install Tomcat in a directory that has spaces in its name. It should work, but you'll experience fewer problems that way. I do not know how this would work if you were using the "tomcat as a service" option for Windows.
From here, you should be able to isolate tomcat instances. Just be sure to edit your conf\server.xml file so that the shutdown ports and HTTP connector ports don't interfere with other Tomcat instances that may be running. I usually assign values like 8005, 8006, 8007, etc. for the shutdown port and 8080, 8081, 8082, etc. for the HTTP connector port.

There is an easier way. Simply don't define the CATALINA_HOME as a Environment variable on your machine. startup.bat and shutdown.bat already come with the following code:
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
You should be all set.
PS: Remember to edit server.xml and put a new port number though. :)

This link has an answer that worked well for me. One thing some of the other answers seems to ignore is that there are multiple places in the server.xml file that must be modified. Before stumbling on this answer mu tomcat servers were competing with each other for certain ports. I had changed the HTTP/1.1 connector port to 8081, but neglected to change some other ports that apparently mattered for my tomcat (version 7). FWIW I had one tomcat service version and one non-service version.
First server.xml file
<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8005" shutdown="SHUTDOWN"/>
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Second server.xml file
<connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8006" shutdown="SHUTDOWN"/>
<connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8101" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
http://www.ansoncheunghk.info/article/5-steps-install-multiple-apache-tomcat-instance-windows

Related

Changing Default Ports in Moqui

Moqui Framework Version : 2.1.3
The Framework runs on the default port 8080 just fine, i would like to change the default ports and i did read https://www.moqui.org/m/docs/framework/Run+and+Deploy#a2.RuntimeDirectoryandMoquiConfigurationXMLFile
which states > "Each of these can be system environment variables (with underscores) or Java properties (with underscores or dots) using the -D command-line argument.
i did find the webapp_ variables are referenced in MoquiDefaultConf.xml as mentioned in the above material and tried using the below start command >
$sudo nohup java -Dwebapp_http_host=localhost -Dwebapp_http_port=9080 -Dwebapp_https_port=9443 -jar moqui.war conf=conf/MoquiDevConf.xml &
However the above command does not seem to change the port, Moqui is still running on default port 8080, What could i be missing?
I also tried the solution to update the webapp tag in MoquiDevConf.xml as mentioned in Running Moqui on Tomcat over SSL (setting http-port and htts-port) - return code 302 with no joy,
Appreciate any pointers, i'm really stuck
The environment variables or Java properties you mention are for setting the ports to use when building URLs. These are the external ports used for accessing your server and if a load balancer or reverse proxy is used may be different from the ports the servlet container is running on. For more information see:
https://moqui.org/m/docs/framework/Run+and+Deploy#EnvironmentVariables
If you are running Moqui with the embedded Jetty server you can specify the port it listens on using the port argument as described in the Executable WAR File section of the Run and Deploy document:
https://moqui.org/m/docs/framework/Run+and+Deploy#a3.ExecutableWARFile
Note that the embedded Jetty server can be used in production but it does not support https and is meant to be used behind a reverse proxy like nginx or Apache httpd that forwards requests to the embedded Jetty server.
If you deploy the WAR file by dropping it in a Servlet Container (ie as an actual WAR file, not treating it as an executable JAR file) then the port configuration would be done with the Servlet Container (Tomcat, Jetty, etc).

How to install mod_jk (Apache Tomcat Connectors) on Windows Server?

I'm a new technical. My problem is, I have the web application that running on tomcat7. now i want to install and configure mod_jk on windows server to connect apache and tomcat.
Please tell me, how to do that?
Thanks
First of all you must download the correct mod_jk connector binaries depending on your apache httpd version from here:
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/
If your apache is a 2.2 version, choose this:
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-i386-httpd-2.2.x.zip
If it is a 2.4, choose one of them depending if you prefer 64 or 32 bit version:
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-i386-httpd-2.4.x.zip
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-x86_64-httpd-2.4.x.zip
Download and unzip correct one. Then, extract mod_jk.so from the zip and place it in your apache httpd modules folder, typically [APACHE_HOME]/modules
Once done it, you must create a workers.properties file, typically in apache conf directory or any other inside it (conf.d, extra, etc).
Usually workers.properties file has following content:
worker.list=worker1,jkstatus
#Set properties for worker19 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.ping_timeout=1000
worker.worker1.connect_timeout=10000
worker.worker1.prepost_timeout=10000
worker.worker1.socket_timeout=10
worker.worker1.connection_pool_timeout=60
worker.worker1.connection_pool_size=90
worker.worker1.retries=2
worker.worker1.reply_timeout=300000
# status worker
worker.jkstatus.type=status
You must check that worker.worker1.host and worker.worker1.port have correct values to reach your tomcat's ajp connector. 8009 port is the commonly used, but better check that in your tomcat's server.xml and set the correct one in workers.properties.
Then, in httpd.conf or any other external conf file, add the following:
# Load mod_jk module
LoadModule jk_module modules/tomcat-connector/mod_jk.so
# Add the module (activate this lne for Apache 1.3)
# AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile conf/extra/workers.properties # Check the path is correct to your workers.properties
# Where to put jk shared memory
JkShmFile logs/mod_jk.shm
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
Once done this, you could try restarting Apache httpd to see if everything already done is correct. If apache starts correctly, now you can start planning how you would redirect matching requests from httpd to tomcat. The easiest way is to redirect every request which matches the context path of your Tomcat webapp.
If your application listens in http://localhost:8080/app-context/ then you could simply add this in httpd.conf or the file where you set the load_module sentences, just after JKLogLevel:
JkMount /app-context/* worker1
Note here that worker1 must match the name you gave to the worker in workers.properties file.
Now, just restart apache httpd, make sure that Tomcat is running and then try in a browser next url:
http://localhost/app-context/
And if you reach your Tomcat webapp, everything is done.

Container doesn't use UTF-8 to decode URLs

Now, I am trying to use Jenkins. So, I deploy Jenkins.war file in JBoss 7.1.1. And the call from browser using 8080 port. When I click "Manage Jenkins" link, the following warning message is shown.
"Your container doesn't use UTF-8 to decode URLs.
If you use non-ASCII characters as a job name etc,
this will cause problems. See Containers and Tomcat i18n for more details."
I tried to solve it and Find from internet about this problem. I not see any answer to solve.I don't know how to solve it. Please help me! Thanks!
I had the same problem in JBoss 4.2.2. I solved it by editing $JBOSS_HOME/deploy/jboss-web.deployer/server.xml and adding URIEncoding="UTF-8" in the Connector.
<Connector port="9443" protocol="HTTP/1.1" URIEncoding="UTF-8" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

Connecting to a weblogic cluster via JPDA

I have a weblogic cluster set up across two machines in a staging environment. I'd like to set up JPDA on at least one of the weblogic instances so I can debug remotely. Generally I use wlst.sh and jython scripts to startup the cluster via:
startNodeManager(...)
nmConnect(...)
nmStart(MyAdminServer)
connect(...) #connect to the admin server
start(...) #start the cluster
Where should I put the -Xdebug Xrunjdwp:transport... incantation so that I can attach to one of the weblogic instances? I had no problem setting this up on a single instance through my domain's startWebLogic.sh, but it doesn't seem to work with the cluster.
From here: https://forums.oracle.com/forums/thread.jspa?threadID=2233816 it looks like I want to put the debug string in startManagedWeblogic.sh but that doesn't seem to work with my jython script either.
Figured it out, from http://docs.oracle.com/cd/E13222_01/wls/docs90/server_start/nodemgr.html#1081870:
4. The Administration Server obtains the domain configuration from its config directory
I checked out the config directory under my domain and there was a suspicious file called config.xml. Within this file is the configuration for the weblogic nodes and where you want to put your JDPA config:
<server>
<name>my-target-machine</name>
...
<server-start>
...
<arguments>(your other config stuff) -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n</arguments>

Allowing access based on hostname for Manager application in Tomcat

I can't get the configuration for Tomcat right to allow access to the Manager Webapp. We have configured tomcat-users.xml, manager.xml etc. When we allow access based on the IP address it works, but based on the hostname it doesn't. This is the configuration we use:
<Context privileged="true"
docBase="/path/to/tomcat_home/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteHostValve"
allow="localhost|otherhostname" deny="" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="172\.30\.\d+\.\d+|127\.0\.0\.1"/>
</Context>
When I remove the RemoteHostValve we can access the manager app (jmxproxy).
Any ideas?
Regards,
Johan-Kees
Check for the exact hostname that host is sending via http (for example with Wireshark), put the hostname with a prefix . into the config and make sure that the hostname is resolvable (i.e. via DNS and/or hosts)...
For reference see:
http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Remote%20Host%20Filter
http://tomcat.apache.org/tomcat-7.0-doc/config/engine.html
http://tomcat.apache.org/migration.html#Manager_application

Resources