• Entries (RSS)
  • Comments (RSS)

Command to find out apache version

Posted by | Posted in Apache | Posted on 08-12-2008

Tagged Under :

Command to find out apache version

A small tip – how to find the version of apache web server? To find the version of Apache web server use -v switch ie,

/usr/local/apache/bin/httpd -v

Where /usr/local/apache/bin/ is your apache installation directory.


undefined symbol: apr_sockaddr_ip_get

Posted by | Posted in GlassFish | Posted on 13-11-2008

Tagged Under : , , ,

Yesterday I was trying to integrate GlassFish Application server with Apache in a Linux box. I was following my Integrating Apache with GlassFish tutorial which I tried in my local windows box. When I restarted my Apache web server, the server was throwing some error message and mod_jk did not work. This time the error was

	/usr/sbin/apachectl restart: configuration broken, ignoring restart
	/usr/sbin/apachectl restart: (run 'apachectl configtest' for details)
	[[email protected] mod_jk]# apachectl configtest
	Syntax error on line 735 of /etc/httpd/conf/httpd.conf:
	Cannot load /etc/httpd/modules/mod_jk.so into server: /etc/httpd/modules/mod_jk.so: undefined symbol: apr_sockaddr_ip_get

This time the problem was the version of mod_jk and Apache server. My local box’s Apache version was 2 and Linux box apache version was 1.3 and I was using the same mod_jk which is compiled for Apache 2. Yeah that was the problem. I was using a mod_jk which was compiled for a different version of Apache server. So anytime if you are getting the same error check your mod_jk version and Apache web server version.


Integrating GlassFish Application server with Apache web server

Posted by | Posted in GlassFish | Posted on 14-10-2008

Tagged Under : , , , ,

A typical production topology for GlassFish will be a front ending GlassFish with Apache for serving the static files. To integrate GlassFish Application Server with Apache web server follow the below steps. My Apache version was Apache/2.2.4 (Win32).

1. Download Mod JK from http://tomcat.apache.org/download-connectors.cgi. I downloaded mod_jk-1.2.26-httpd-2.2.4.so from there.

2. Rename mod_jk-1.2.26-httpd-2.2.4.so to mod_jk.so

3. Copy mod_jk.so file to modules directory of your Apache web server.

4. Create workers.properties file. I have attached my workers.properties file for reference. Most of the cases you need to change only workers.tomcat_home (Point to your GlassFish Application server installation directory) and workers.java_home (change it to your java home directory).

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# workers.properties -
# This file provides jk derived plugins with the needed information to
# connect to the different tomcat workers.  Note that the distributed
# version of this file requires modification before it is usable by a
# plugin.
# As a general note, the characters $( and ) are used internally to define
# macros. Do not use them in your own configuration!!!
# Whenever you see a set of lines such as:
# x=value
# y=$(x)\something
# the final value for y will be value\something
# Normaly all you will need to do is un-comment and modify the first three
# properties, i.e. workers.tomcat_home, workers.java_home and ps.
# Most of the configuration is derived from these.
# When you are done updating workers.tomcat_home, workers.java_home and ps
# you should have 3 workers configured:
# - An ajp12 worker that connects to localhost:8007
# - An ajp13 worker that connects to localhost:8009
# - A jni inprocess worker.
# - A load balancer worker
# However by default the plugins will only use the ajp12 worker. To have
# the plugins use other workers you should modify the worker.list property.
# OPTIONS ( very important for jni mode ) 
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#------ ADVANCED MODE ------------------------------------------------
#------ DEFAULT worker list ------------------------------------------
# The workers that your plugins should create and work with
# Add 'inprocess' if you want JNI connector
#worker.list=ajp12, ajp13
# , inprocess
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
#  ----> If a worker dies, the load balancer will check its state
#        once in a while. Until then all work is redirected to peer
#        workers.
#worker.loadbalancer.balance_workers=ajp12, ajp13
#------ DEFAULT JNI WORKER DEFINITION---------------------------------
# Defining a worker named inprocess and of type jni
# Note that the name and the type do not have to match.
# Define 1 real worker using ajp13
# Set properties for worker1 (ajp13)

5. Edit the Apache configuration file (httpd.conf).

6. Add the following entries to your httpd.conf file.

LoadModule jk_module modules/mod_jk.so
JkWorkersFile D:/Apache22/conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T %U %q" 
# Send all jsp requests to GlassFish
JkMount /*.jsp worker1
# Send all /TestWeb/ requests to GlassFish
JkMount /TestWeb/* worker1

Change line ‘LoadModule jk_module modules/mod_jk.so ‘ to point to your mod_jk.so path. If you have copied mod_jk.so to modules directory of Apache web server you don’t need to change this line. JkWorkersFile should point to the path where you have created your workers.properties file in step 4. JkLogFile will be the log file for mod_jk. JkLogLevel set to error for production environments.

JkMount /TestWeb/* worker1, here /TestWeb/ is the GlassFish context root of your GlassFish web application.

The documentation for the above options are :-
JkWorkersFile – the name of a worker file for the Tomcat servlet containers
JkLogFile – Full path to the Tomcat module log file
JkLogLevel – The Tomcat module log level, can be debug, info, error or emerg
JkLogStampFormat – The Tomcat module log format, follow strftime syntax
JkOptions – Set one of more options to configure the mod_jk module
JkRequestLogFormat – The mod_jk module request log format string
JkMount – A mount point from a context to a Tomcat worker

7. All the configurations required at Apache web server side is over. Now you can start your Apache web server.

8. Copy tomcat-ajp.jar from Tomcat version 5.5.23 to GlassFish installation directory/ lib folder. For me all other versions gave some kind of errors and tomcat-ajp-jar from Tomcat 5.5.23 worked fine.

9. Copy commons-logging.jar, commons-modeler.jar and log4j.jar to GlassFish installation directory/lib folder. I used commons-logging.jar, commons-modeler-2.0.1.jar and log4j-1.2.7.jar.

10. Now open you domain.xml file. The domain.xml file will be inside GlassFish_HOME\domains\domain1\config folder.

11. Search for <jvm-options> in your domain.xml file and add an entry there


12. That’s it. You are done with integrating Apache web server with GlassFish Application Server. Now access your jsp page through Apache web server.




Posted by | Posted in GlassFish | Posted on 10-10-2008

Tagged Under : , , ,

Today I was trying to integrate GlassFish Application Server with Apache 2.2. After making all the required configurations, both Apache and GlassFish server successfully started. However when I try to access a JSP using Mod JK I was getting the following exception in my GlassFish log file.

        at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:283)
        at org.apache.jk.core.MsgContext.action(MsgContext.java:267)
        at org.apache.coyote.Response.action(Response.java:221)
        at org.apache.coyote.Response.sendHeaders(Response.java:416)
        at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:355)
        at org.apache.coyote.tomcat5.OutputBuffer.close(OutputBuffer.java:321)
        at org.apache.coyote.tomcat5.CoyoteResponse.finishResponse(CoyoteResponse.java:578)
        at org.apache.coyote.tomcat5.CoyoteAdapter.afterService(CoyoteAdapter.java:318)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:301)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
        at java.lang.Thread.run(Thread.java:619)
PWC5752: Caught exception (java.lang.NoSuchFieldError: USE_CUSTOM_STATUS_MSG_IN_HEADER) executing org.apache.jk.common.ChannelSocket[email protected], terminating thread

After a little search I could resolve this issue. It was because the version of tomcat-ajp.jar I was using was wrong. So if you are getting the same error with your GlassFish Apache integration make sure that you are using tomcat-ajp.jar from apache-tomcat-5.5.23. Yes, take the tomcat-ajp.jar from Tomcat 5.5.23 and replace incorrect jar file. You are done.