keeping same session via apache2 mod_jk2 and tomcat5
Hiya all tried to answer back to my last post but it kept timing out maybe it was too long - anyways I just wondered if there was anything else i can try :( If port 8180 keeps the sessions but port 80 keeps recycling sessions surely it must be an issue with mod_jk I have also tried mod_jk2 and had the same issues in the past - the mod_jk and mod_jk2 were both debian packages installed via dselect. Thanks vahid
Re: keeping same session via apache2 mod_jk2 and tomcat5
Hi all I had as a test used seperate engines for each virtual host but instead it loaded up one of the virtual hosts on both and the site that had the wrong virtual host loaded up seemed to keep the session ID . Anyhow here are the configs. The first 2 is what is currently running the last 2 are what i tried as seperate engines. __ current server.xml Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.jk.config.ApacheConfig modJk=/usr/lib/apache2/modules/mod_jk.so WorkersConfig=/etc/apache2/workers.properties / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className= org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved /Resource ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams /GlobalNamingResources !-- Define the Tomcat Stand-Alone Service -- Service name=Catalina !-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8180 -- Connector className=org.apache.coyote.tomcat5.CoyoteConnector port=8180 minProcessors=5 maxProcessors=75 enableLookups=false acceptCount=10 debug=0 connectionTimeout=2 useURIValidationHack=false / !-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -- Connector className=org.apache.coyote.tomcat5.CoyoteConnector port=8009 minProcessors=5 maxProcessors=75 protocol=AJP/1.3 enableLookups=false acceptCount=10 debug=0 connectionTimeout=2 useURIValidationHack=false protocolHandlerClassName= org.apache.jk.server.JkCoyoteHandler/ Engine name=Catalina defaultHost=localhost debug=0 jvmRoute=worker1 Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_ suffix=.log timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ DefaultContext reloadable=true debug=4/ Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_ suffix=.log timestamp=true/ /Host Host name=www.greenlightproductions.co.uk debug=0 appBase=/apache_sites/servlets/ unpackWARs=true autoDeploy=true Context path=/servlets docBase=greenlight debug=0 reloadable=true/ parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=green_log. suffix=.txt pattern=common resolveHosts=true/ /Host Host name=www.pro.org.uk debug=0 appBase=/apache_sites/servlets/ unpackWARs=true autoDeploy=true Context path=/vahidservlets docBase=vservlets debug=0 reloadable=true/ Context path=/servlets docBase=vservlets debug=0 reloadable=true/ parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=pro_log. suffix=.txt pattern=common resolveHosts=true/ /Host /Engine /Service /Server ___ current workers.properties. workers.tomcat_home=/var/lib/tomcat5 workers.java_home=/usr/bin/java ps=/ worker.list=worker1,worker2,worker3 # Definition for local worker using AJP 1.3 # #worker.foo.type=ajp13 #worker.foo.host=www.pro.org.uk #worker.foo.port=8009 #worker.foo.cachesize=20 worker.balancer.sticky_session=true [uri:www.pro.org.uk/servlets/*] worker.worker1.balancer.sticky_session=true worker.worker1.tomcatId=worker1 #worker.foo=ajp13:www.pro.org.uk:8009 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.reclycle_timeout=300 [uri:www.greenlightproductions.co.uk/servlets/*] worker.worker2.tomcatId=worker2 worker.worker2.balancer.sticky_session=true #worker.foo=ajp13:www.pro.org.uk:8009 worker.worker2.type=ajp13 worker.worker2.host=localhost worker.worker2.port=8009 worker.worker2.lbfactor=50 worker.worker2.cachesize=10
Re: keeping same session via apache2 mod_jk2 and tomcat5
ok this is where it starts to get bizzare... http://www.greenlightproductions.co.uk/servlets/SessionExample This now works (as in it is keeping the same session ID ) but it is showing the wrong servlets folder (as in for wrong virtual host and showing the tomcatid of that virtual host) Since below is a servlet for the host in question http://www.greenlightproductions.co.uk/servlets/GreenLight but it shows servlets setup for pro.org.uk http://www.greenlightproductions.co.uk/servlets/ContactMe http://www.pro.org.uk/servlets/ContactMe in server.xml i have setup unique engines. Engine name=Catalina3 defaultHost=www.greenlightproductions.co.uk debug=0 jvmRoute=worker2 Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_ suffix=.log timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ DefaultContext reloadable=true debug=4/ Host name=www.greenlightproductions.co.uk debug=0 appBase=/apache_sites/servlets/ unpackWARs=true autoDeploy=true Context path=/servlets docBase=greenlight debug=0 reloadable=true/ parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=green_log. suffix=.txt pattern=common resolveHosts=true/ /Host /Engine Engine name=Catalina2 defaultHost=www.pro.org.uk debug=0 jvmRoute=worker1 Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_ suffix=.log timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ DefaultContext reloadable=true debug=4/ Host name=www.pro.org.uk debug=0 appBase=/apache_sites/servlets/ unpackWARs=true autoDeploy=true Context path=/vahidservlets docBase=vservlets debug=0 reloadable=true/ Context path=/servlets docBase=vservlets debug=0 reloadable=true/ parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=pro_log. suffix=.txt pattern=common resolveHosts=true/ /Host /Engine workers.properties worker.list=worker1,worker2,worker3 # Definition for local worker using AJP 1.3 # #worker.foo.type=ajp13 #worker.foo.host=www.pro.org.uk #worker.foo.port=8009 #worker.foo.cachesize=20 [uri:www.pro.org.uk/servlets/*] worker.worker1.tomcatId=worker1 #worker.foo=ajp13:www.pro.org.uk:8009 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.reclycle_timeout=300 [uri:www.greenlightproductions.co.uk/servlets/*] worker.worker2.tomcatId=worker2 #worker.foo=ajp13:www.pro.org.uk:8009 worker.worker2.type=ajp13 worker.worker2.host=localhost worker.worker2.port=8009 worker.worker2.lbfactor=50 worker.worker2.cachesize=10 worker.worker2.cache_timeout=600 worker.worker2.socket_keepalive=1 worker.worker2.reclycle_timeout=300 virtual host for greenlight IfModule mod_jk.c JkLogFile /var/log/apache2/mod_jk.log JkMount /servlets/* worker2 /IfModule Virtual host for pro.org.uk IfModule mod_jk.c JkLogFile /var/log/apache2/mod_jk.log JkMount /servlets/* worker1 JkMount /vahidservlets/* worker1 /IfModule Why is tomcat doing this ? This now proves this has nothing to do with cookies since it can keep the same session ID for a servlet that it is not supposed to show lol Thanks vahid On 3/21/06, Reinhard Moosauer [EMAIL PROTECTED] wrote: Hi, please check your browser. I think you have cookies disabled for any reason. (or cookies are disabled in your tomcat app) yould check with ethereal or try using cookie-less mode with response.encodeURL(hyperlink) hope this helps R. Am Freitag, 17. März 2006 13:35 schrieb Vahid Hedayati: Hi All. Have been looking for a few days now for a fix for this one issue that I just cannot get around.. Basically If I run http://www.greenlightproductions.co.uk/servlets/SessionExample The session ID keeps changing if you refresh the page (same goes for all other servlet code I been using you login once logged in session info lost as in new session ID assigned) but if I go to port 8180 it works perfect http://www.greenlightproductions.co.uk:8180/servlets/SessionExample the session ID remains the same no matter how much i refresh. I have been looking all over google for an answer for this and most of it is to do with load balancing tomcat and getting same session ID :( I am sure others have hit this issue before and it must be a tom cat config issue (well for the apache listener) here is some of my config.
Re: keeping same session via apache2 mod_jk2 and tomcat5
Ok.. I am now using mo_jk rather than mod_jk2 and sessions still keeps changing It is running on: Apache/2.0.55 (Debian) mod_jk/1.2.14 mod_chroot/0.5 mod_perl/2.0.2 Perl/v5.8.8 _ more /etc/apache2/mods-enabled/jk.load LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so _ more /etc/apache2/mods-enabled/jk.conf IfModule mod_jk.c JkWorkersFile /etc/apache2/workers.properties JkLogFile /var/log/apache2/mod_jk.log JkLogLevel error /IfModule _ more /etc/apache2/sites-enabled/www. IfModule mod_jk.c JkLogFile /var/log/apache2/mod_jk.log JkLogFile /var/log/httpd/mod_jk.log JkLogLevelerror JkLogStampFormat [%a %b %d %H:%M:%S %Y] JkRequestLogFormat %w %V %T JkMount /servlets/* worker1 JkWorkersFile /etc/apache2/workers.properties /IfModule _ more /etc/apache2/workers.properties # Tomcat and Java configuration # workers.tomcat_home=/var/lib/tomcat5 workers.java_home=/usr/bin/java ps=/ worker.list=worker1 [uri:/servlets/*] #worker.foo=ajp13:www.pro.org.uk:8009 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.reclycle_timeout=300 _ http://www.greenlightproductions.co.uk/servlets/SessionExample This still changes session ID http://www.greenlightproductions.co.uk:8180/servlets/SessionExample This doesnt :( Can anyone tell me why this is happening ? Thanks vahid On 3/17/06, Steve Ochani [EMAIL PROTECTED] wrote: On 17 Mar 2006 at 14:41, Vahid Hedayati wrote: Hi Steve I have now installed mod_jk in virtualhost config it has.. IfModule mod_jk.c JkLogFile /var/log/apache2/mod_jk.log JkMount /servlets/* ajp13 /IfModule more /etc/apache2/mods-enabled/jk.load LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so [EMAIL PROTECTED]:/etc/apache2/mods-enabled# (there is no conf file) Apache/2.0.55 (Debian) mod_jk/1.2.14 mod_chroot/0.5 mod_perl/2.0.2 Perl/v5.8.8 but my sessions still keep resetting.. http://www.greenlightproductions.co.uk/servlets/SessionExample :( Is there anything specific to the way modjk was configured on your apache ? This is what I have in my httpd.conf (before document root defination) - JkWorkersFile /jakarta-tomcat-5.5.9/conf/workers.properties JkLogFile /var/log/httpd/mod_jk.log JkLogLevelerror JkLogStampFormat [%a %b %d %H:%M:%S %Y] JkRequestLogFormat %w %V %T JkMount /jsp-examples/* worker1 JkMount /servlets-examples/* worker1 - And my workers.properties file is this --- # Set properties for worker1 (ajp13) worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.reclycle_timeout=300 --- Hope that helps FYI I'm using tomcat 5.5.9 and apache httpd 1.3.26 thanks vahid On 3/17/06, Steve Ochani [EMAIL PROTECTED] wrote: Hi, On 17 Mar 2006 at 12:35, Vahid Hedayati wrote: Hi All. Have been looking for a few days now for a fix for this one issue that I just cannot get around.. Basically If I run http://www.greenlightproductions.co.uk/servlets/SessionExample The session ID keeps changingif you refresh the page (same goes for all other servlet code I been using you login once logged in session info lost as in new session ID assigned) I know this isn't the exact answer you are looking for but I'm using mod_jk (mod_jk2 is no longer supported) and I do not have this problem. http://www.matcmp.ncc.edu/servlets-examples/servlet/SessionExample -Steve O. but if I goto port 8180 it works perfect http://www.greenlightproductions.co.uk:8180/servlets/SessionExampl e the session ID remains the same no matter how much i refresh.I have been looking all over google for an answer for this and most of it is to do with load balancing tomcat and getting same session ID :( I am sure others have hit this issue before and it must be a tom cat config issue (well for the apache listener) here is some of my config. ## # /etc/apache2/mods-enabled/jk2.load LoadModule jk2_module /usr/lib/apache2/modules/mod_jk2.so ## # /etc/apache2/mods-enabled/jk2.conf # To enable mod_jk2, customize
keeping same session via apache2 mod_jk2 and tomcat5
Hi All. Have been looking for a few days now for a fix for this one issue that I just cannot get around.. Basically If I run http://www.greenlightproductions.co.uk/servlets/SessionExample The session ID keeps changing if you refresh the page (same goes for all other servlet code I been using you login once logged in session info lost as in new session ID assigned) but if I go to port 8180 it works perfect http://www.greenlightproductions.co.uk:8180/servlets/SessionExample the session ID remains the same no matter how much i refresh. I have been looking all over google for an answer for this and most of it is to do with load balancing tomcat and getting same session ID :( I am sure others have hit this issue before and it must be a tom cat config issue (well for the apache listener) here is some of my config. ### /etc/apache2/mods-enabled/jk2.load LoadModule jk2_module /usr/lib/apache2/modules/mod_jk2.so ### /etc/apache2/mods-enabled/jk2.conf # To enable mod_jk2, customize workers2.properties* from # /usr/share/doc/libapache2-mod-jk2/examples and copy it to # /etc/apache2/workers2.properties. Then uncomment the following line: JkSet config.file /etc/apache2/workers2.properties # Where to put jk logs #JkLogFile /var/log/apache2/mod_jk.log # Set the jk log level [debug/error/info] #JkLogLevelinfo # 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 # Globally deny access to the WEB-INF directory LocationMatch '.*WEB-INF.*' AllowOverride None deny from all /LocationMatch ### /etc/apache2/workers2.properties # # This is the minimal JK2 connector configuration file. # [logger] info=Native logger level=ERROR [config:] file=${serverRoot}/workers2.properties debug=0 debugEnv=0 [uriMap:] info=Maps the requests. debug=0 [shm:] info=Scoreboard. Required for reconfiguration and status with multiprocess servers file=anonymous debug=0 [workerEnv:] info=Global server options timing=0 debug=0 [lb:lb] info=Default load balancer. debug=0 [channel.socket:localhost:8009] info=Ajp13 forwarding over socket debug=0 #tomcatId=tomcat1 tomcatId=localhost:8009 keepalive=1 [uri:/admin] info=Tomcat HTML based administration web application. debug=0 [uri:/manager] info=A scriptable management web application for the Tomcat Web Server. debug=0 [uri:/jsp-examples] info=JSP 2.0 Examples. debug=0 [uri:/servlets-examples] tomcatId = jvmRoute info=Servlet 2.4 Examples. debug=0 [uri:/*.jsp] info=JSP Extension mapping. debug=0 [uri:/servlets/*] worker=ajp13:localhost:8009 ### snippets of /etc/tomcat5/server.xml Server port=8005 shutdown=SHUTDOWN debug=0 !--apache listne added-- Listener className=org.apache.jk.config.ApacheConfig modJk=/usr/lib/apache2/modules/mod_jk2.so WorkersConfig=/etc/apache2/workers2.properties / Listener className=org.apache.jk.config.ApacheConfig append=true forwardAll=false modJk=/usr/lib/apache2/modules/mod_jk2.so WorkersConfig=/etc/apache2/workers2.properties / ... !-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8180 -- Connector className=org.apache.coyote.tomcat5.CoyoteConnector port=8180 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=2 useURIValidationHack=false / ... Host name=www.greenlightproductions.co.uk debug=0 appBase=//servlets/ unpackWARs=true autoDeploy=true Context path=/servlets docBase=greenlight debug=0 reloadable=true/ Manager className=org.apache.catalina.session.PersistentManager debug=0 saveOnRestart=true maxActiveSessions=30 minIdleSwap=60 maxIdleSwap=60 maxIdleBackup=60 Store className=org.apache.catalina.session.FileStore directory=/xxx//log// !--Store className=org.apache.catalina.session.JDBCStore driverName= org.gjt.mm.mysql.Driver connectionURL=jdbc:mysql://localhost/tomcat?user=amp;password=x sessionTable=tomcat$sessions sessionIdCol=id sessionDataCol=data sessionValidCol=valid sessionMaxInactiveCol=maxinact ive sessionLastAccessedCol=lastaccess checkInterval=60 debug=99 / -- /Manager parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=greenlight_log. suffix=.txt pa ttern=common resolveHosts=true/ /Host ###