Apache Restart
sudo /etc/rc.d/init.d/httpd restart
All requests with port :8080 are caught by tomcat as apache is listening at port 80
requests without ports are heard by apache which listens at port 80 and later redirects through 8009
Directory Structure
etc/httpd/
conf/ conf.d/ logs/ modules/ run/
conf/
httpd.conf ssl.crl ssl.crt ssl.csr ssl.key ssl.prm workers.properties
conf.d/
authz_ldap.conf jk.conf perl.conf php.conf python.conf README ssl.conf webalizer.conf welcome.conf
1. etc/httpd/conf/httpd.conf
Attributes include
DocumentRoot "/home/partyaccount/website/htdocs"
DirectoryIndex index.jsp index.html inde
DefaultType text/plain
ErrorLog logs/error_log
AddEncoding x-compress Z
ErrorDocument 500 "The server made a boo boo."
2. worker/properties
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
[uri:/ws/*]
worker=ajp13:localhost:80
3. etc/httpd/conf.d/jk.conf
worker assighnments with respective .jsp,.html etc
4. etc/httpd/conf.d/ssl.conf
will have virtual hosts configured here ex:pa112 etc
document root
server admin
servername
Rewrite rules per vhost klike
RewriteEngine on
RewriteRule ^(.*)/.jsp$ $1.do [L]
Thursday, July 31, 2008
Apache Basics
Friday, July 25, 2008
Overwriting Struts Resouce Bundle Handling
Care needs to be taken when we overwrite the struts resource bundle handling,especially while overwriting the get text method in struts
This is because , if the customised gettext copies this statment
ResourceBundle bundle = LocalizedTextUtil.findResourceBundle(bundleName, resourceLocale);
where bundlename is the bundle in which property is expected
and if the property does not exist in that bundle, Struts internally looks for the entire set of bundles and searches the key. This is not what is expected
and it consumes a lot of time for each literal check and chokes the server.
A quick fix to this would be to search for the expected bundle and then check if the key which is expected is present.This can be done by using bundle.containskey() and later if it exists then by using the above statement. This reduces a lot of time wasted checking for the entire set of bundle for each property.
Your Kit : A CPU and memory Java Profiler
This is a simple kit with 15 day trial period licence which can be got from http://www.yourkit.com/.
It has both windows and linux versions.For the linux version just copy the
1. copy the libyjpagent.so into tomcat/bin
2. set the path by typing export LD_LIBRARY_PATH=/tomcat/bin
3. Add -agentlib:yjpagent to Tomcat JVM startup params as
JAVA_OPTS=" -agentlib:yjpagent -server -Xms512m -Xmx768m ......" in catalina.sh
To connect for the same from Windows
1 Install the windos version
2 Click on connect remotely . Enter the ip of the profiling machine
3 This gives most of the stats. For time wise distibution of thread on the running methods
click start profiling.
It also gives snapshots for the required time duration.
Wednesday, July 23, 2008
Adding Logger interceptor in Struts
When i had a requirement to add user name and session id to every logger statement for debugging purposes i did not think it would be so easy. I came across sites which suggested adding some extra modules and configurations into the log4j.
But i realized there was a much simpler way which was to modify the thread name appending application specific user name and session id into it. As anyways log4j will print the thread name at every logger statement . Thus with minimal changes my cause was served. I added this functionality into every request by making it as a interceptor and adding it into the basic stack.
I have attached the interceptor code for reference.
Tasks get easy when seen for different perspectives.