Saturday, August 22, 2015

Solution: Error while Integrating Glassfish 4.1 with Apache 2.4 via mod_jk . Shows Blank Page


When you try to use Apache 2.4 as frontend to glassfish 4.1  via mod_jk, you may encounter an error  in a form of Blank page in browser. It may be due to default listener port setting to 8009. Simply... change this default listener port.

It is widely advisable to use Apache Front ending with Glassfish server. One of the reasons is not to expose web container directly in public hosted websites.

The Apache module mod_jk is used to connect Apache and Glassfish. A wide documentation is available on internet about it. One may prefer the link... http://goo.gl/5pE3rl

I have experienced a peculiar behavior of Glassfish 4.1 during setup. It had not started with its default port 8080 after fresh installation.It gave an error which indicates that port 8080 was in used.But the fact was, none of the application or service was using port 8080 in system.

In order to start the Glassfish 4.1 in  server, I changed the port in domain.xml file to 8090 & it started.But problems didn’t stop here. I spent hours to achieve Apache and Glassfish integration via mod_jk which I have done several times in past years. The connection to Glassfish via mod_jk appeared to be rejected and browser showed blank page. There was no relevant log entry in JK Log file as well no activity in Glassfish console window. A clear indication that connectivity of Apache and Glassfish was not established at all.

First I checked firewall related aspects but there was no such issue.I changed the "docroot"  path in Apache virtual host setting to investigate further, but in vain.I tried with different versions of mod_jk. I rebuilt the latest mod_jk too but it also didn't worked. Finally it appeared to me that like 8080, there might be problem in system with default port 8009 too, on which Glassfish listen for http requests from Apache via mod_jk.
 
I changed the mentioned port 8009  in “workers.properties” file to 48009 in Apache’s config folder. I also changed the port in JK listener setting of Glassfish via Admin GUI. And when I restarted the both the servers and tried to connect... Voila.... It worked in no time. It showed Glassfish's default welcome page when I simply put server host name in URI without port number of 8090.

Do inform me... If you faced the same problem and this solution worked for you too..

Happy  " Apache Front ending with Glassfish "

Write your comments....