Install Apache Tomcat on Mac using Brew

1)  –  Install Tomcat Server

Install tomcat with the brew install in terminal (as a normal user, not root):

$ brew install tomcat

This will take care of the downloading, installation and configuration of Tomcat and manage its dependencies as well. Take note of the output, brew commands are typically really good at displaying concise but useful info, error messages and help.

Homebrew keeps packages (known as kegs) in the Cellar, where you can check config and data files. It is a directory located at:

$ ls /usr/local/Cellar/

Verify the Tomcat installation using homebrew’s handy “services” utility:

$ brew services list

Tomcat should now be listed here. brew services are really useful for managing system services, type $ brew services --help for more info.

Note: to change port edit /usr/local/Cellar/tomcat/8.5.27/libexec/conf/server.xml 

2)  –  Run Tomcat Server

We are going to start the server by executing Tomcat’s Catalina command with the “run” parameter as such:

$ ls /usr/local/Cellar/tomcat/

$ /usr/local/Cellar/tomcat/8.5.3/bin/catalina run

or more generally:

$ /usr/local/Cellar/tomcat/[version]/bin/catalina run

With [version] replaced with your installed version.

The version number and installation directory will have been listed by homebrew at the end of the installation output (typically the last line with a beer symbol in front). Catalina can also be set to start on system launch – although for security reasons we prefer to only run when needed (either using this command or more commonly via an IDE plugin).

Once the server is running you can navigate to the host page at:



3)  –  Configure Tomcat Server

To add and manage applications running on the server you will also need to edit a configuration file:

$ vim /usr/local/Cellar/tomcat/[version]/libexec/conf/tomcat-users.xml

With [version] again replaced with your installed version.

Towards the bottom of this short config file you will see a selection of users – all commented out by default. You need to uncomment one of these and give it the extra role “manager-gui” (preferably also changing the username and password for security). The resultant user entry should look something like this:

<user username="admin" password="password" roles="tomcat,manager-gui" />

After this you can navigate to the page (or click the “Manager App” link on the main Tomcat Server page):


Here you can view or delete the included sample application and deploy your own. Usually, it’s easiest to deploy applications in a dev / testing environment using an IDE like PHPStorm or NetBeans however, Tomcat’s web interface is useful also. For reference, deployed applications are usually then located under the directory:



Loopback : How to create embedded document or create object type

Here is your Contact model and if you want embed another model called as Address inside it then you need to put relations as embedsOne.
Please note that if you are using mongodb then embeds document will be part of parent document which mean all child documents will not be part of different collections which are linked, rather they will all be part of single parent doc.

“relations”: {
“address”: {
“type”: “embedsOne”,
“model”: “Address”,
“property”: “address”,
“options”: {
“validate”: true,
“forceId”: false

Now Contacts.json would look like this

“name”: “Contact”,
“base”: “PersistedModel”,
“idInjection”: true,
“options”: {
“validateUpsert”: true
“properties”: {
“id”: {
“type”: “string”,
“id”: true,
“defaultFn”: “uuid”
“name”: {
“type”: “string”,
“required”: true
“phone”: {
“type”: “string”,
“required”: true
“email”: {
“type”: “string”
“relationship”: {
“type”: “string”
“validations”: [],
“relations”: {
“address”: {
“type”: “embedsOne”,
“model”: “Address”,
“property”: “address”,
“options”: {
“validate”: true,
“forceId”: false
“acls”: [],
“methods”: {}

Please note that default id creator or sub document is “defaultFn”: “uuid” which will add id.

Installing Nginx in Mac OS with home brew

Install with brew

Use brew to install the nginx with command:

$ brew install nginx 

After install run:

$ sudo nginx 


Test it by going to URL:



The default place of nginx.conf on Mac after installing with brew is:


Changing the default port

The nginx default port is 8080, we shall change it to 80. First stop the nginx server if it is running by:


$ sudo nginx -s stop 

Then open nginx.conf with:


$ vim /usr/local/etc/nginx/nginx.conf 

and change the:


server {  listen 8080;  server_name localhost;   #access_log logs/host.access.log main;   location / {  root html;  index index.html index.htm;  } 



server {  listen 80;  server_name localhost;   #access_log logs/host.access.log main;   location / {  root html;  index index.html index.htm;  } 

Save configuration and start nginx by

$ sudo nginx 

Changing the path of defualt web location

The nginx html folder (brew install only) is by the defult in:


Note: change 1.2.3 to your nginx version.

The defualt path configuration:


GIT : pull before you push

Before pushing the code to GIT it is necessary to pull the code.

Now when we pull, jRebell, does accommodate the new variables added in the last commits, so it starts giving exception when we run application.

So the desirable steps would be

1. Commit your changes

2. Pull the code.

3. Refresh the eclipse work space.

4. Restart the server.

5. Unit test you changes.

6. Push the code.

jboss – Error was: IP_ADD_MEMBERSHIP failed (out of hardware filters?)

I was trying to start the Jboss and was getting these error all of a sudden. I checked my code it was ok. Deleting temp folder and restarting jboss was not resolving the issue.

Work around – Check if you have multiple wireless network connected, if so close all the network connection just work with one, you will not get this error in your windows machine.

The error log are as below

12:02:34,022 INFO  [SessionFactoryImpl] building session factory
12:02:34,163 WARN  [CacheConfiguration] Cache ‘persistence.unit:unitName=cloudmatrix.ear/’ is set to eternal but also has TTI/TTL set.  To avoid this warning, clean up the config removing conflicting values of eternal, TTI and TTL. Effective configuration for Cache ‘persistence.unit:unitName=cloudmatrix.ear/’ will be eternal=’true’, timeToIdleSeconds=’0′, timeToLiveSeconds=’0′.
12:02:34,262 ERROR [MulticastRMICacheManagerPeerProvider] Error starting heartbeat. Error was: IP_ADD_MEMBERSHIP failed (out of hardware filters?) IP_ADD_MEMBERSHIP failed (out of hardware filters?)
    at Method)

Let me fix it

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756 How to back up and restore the registry in Windows

To prevent the network adapter from detecting a link state, follow these steps.
Note The NetBEUI protocol and the IPX protocol do not support Media Sensing.

  1. Start Registry Editor.
  2. Locate the following registry subkey:


  3. Add the following registry entry to the



    Name: DisableDHCPMediaSense
    Data type: REG_DWORD (Boolean)
    Value: 1

    Note This entry controls the behavior of Media Sensing. By default, Media Sensing events trigger a DHCP client to take an action. For example, when a connect event occurs, the client tries to obtain a lease. When a disconnect event occurs, the client may invalidate the interface and routes. If you set this value data to 1, DHCP clients and non-DHCP clients ignore Media Sensing events.

  4. Restart the computer.

Remote Debug : Java Application using JDWP

Debugging application is always a common topic for all developers and it may cover more than 60%+ of total development time if using traditional way like using debugging message.

After the release of Sun Java Development Kit 1.4.2, you can be benefited by the magic tool called JDWP (Java Debugging Wire Protocol), It provides sophisticated implementation for debugging your JAVA application in a modern way, especially when you want to debug server java application like Tomcat, JBoss, etc..

Okay, you may say you are happy using debug message for debugging remote application and thus let me list the summary of how JDWP can aid the development.

  1. Thread stepping execution: Suspend/Resume particular thread
  2. Breakpoints management: Insert/Remove breakpoint for investigate failure point
  3. Hotswap Bug Fixing: Recompile the classes on-the-fly for bug fixing without redeployment

I thought you may be interested with the features 3, which greatly reduces the re-deployment time for debugging an application.

This articles will focus how the setup for debugging remote java application. Tomcat5.5 and Eclipse Europa will be used for an example.

1. High Level View

Basically it is divided into two entities: Debuggee and Debugger. The Debuggee is the application that you want to debug and for our example it is Tomcat. The Debugger is the vendor of JDI (Java Debugging Interface) : Eclipse.



2. Enable JDWP in the Debuggee (Tomcat)

JDWP can be enabled out of the box by setting the appropriate system properties :


This enables JVM with JDWP at port 9002 using server mode with any suspension.


(“n” or “y”) If “y,” listen for a debugger application to attach; otherwise, attach to the debugger application at the specified address.


transport address for the connection. If server=n, attempt to attach to a debugger application at this address. If server=y, listen for a connection at this address.


If server=y, this specifies the timeout, in milliseconds, to wait for the debugger to attach. If server=n, this specifies the timeout, in milliseconds, to use when attaching to the debugger.


If “y,” JVM suspends the execution until a debugger connects to the debuggee JVM. Preferably set this option to “n” else the application will not start unless the debugger attaches the port on which debugee  application is lessoning.

Remote Debug : an insight


Some times you have to debug a application which is not running from it’s source code in a IDE. So to do it we use this remote debug concept. In the scenario which is shown above the application runs in a remote machine, but when it runs it will broadcast debug information via a socket deployed. The IDE running locally will capture those broadcast debug information through that socket and it will do the debug through the source code.
JAVA language provides this in its JVM. We can use commands like this to run a application in the remote debug mode in java.

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y -jar Name_of_Your_Jar.jar

Then it will broadcast some debug information and will wait until some IDE capture those debug information and start debugging the source code. When Some IDE connects to the Socket specified it will start the debugging process.
Configuring the IDEs will depend on them. The links given below will give you a good understanding about those concepts. Hope you learn some thing from this post. Following links are really interesting to learn about remote debugging.

  • Application to be debugged would attach a socket to itself and then would listen debug instructions on that socket.
  • Debugger would bind itself to that socket and then send instructions on that socket.

What is Remote Debugging :
Remote Debugging with Eclipse :
Remote Debugging with IntelliJ IDEA :
Remote Debugging Web Services, Apache Axis 2 :

Remote debug configuration for web apps

There are times when developers wants to debug unstable seha007 environment for bug fixes or investigation.

In order to debug server-side code you must start your (app) server in debug mode, and you must have your IDE connect to the remote JVM through a Remote Server Debug configuration (That’s what it is called in IDEA). Other IDE’s should have something very similar to this that will allow it to “hook” into the remote JVM and find out the calls that are being made, and to stop the code when it hits a breakpoint that you have set in the IDE.

For the same there are 2 requirements.

  1. Set up your server to start in debug mode and address a particular port
  2. Setup your IDE to lesson to a particular port and sense the break point.
  • Setup your server to start in debug mode to address a particular port

IPA and LMS are deployed on Tomcat at QA/DEV/Test/Production Environment.

There is one file located inside the $TOMCAT_HOME/bin/

You just need to add the below lines to the JAVA_OPTS variable in the file.

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,suspend=n,server=y

it will look like this 

JAVA_OPTS=”-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,suspend=n,server=y”

Save the file , and restart tomcat normally.

This time tomcat will run the debug mode at the port 8787.

You can also see in the tomcat logs a message like below.

Listening for transport dt_socket at address: 8787

  • Setup your IDE to lesson to a particular port and sense the break point.

Refer this screen shot for IDEA remote debug setting :


How To Change Tomcat Default Port ?

Steps Of Changing The Tomcat Port

1) Locate server.xml in {Tomcat installation folder}\ conf \

2) Find following similar statement

 <!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080

3) About Tomcat’s server.xml file cites it’s runs on port 8080. Change the Connector port=”8080″ port to any other port number.

For example

 <Connector port="8181" protocol="HTTP/1.1" 
               redirectPort="8443" />

Above statement instruct Tomcat server runs on port 8181.

4) Edit and save the server.xml file. Restart Tomcat. Done