You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hugo Kotsubo <hu...@tendencies.com.br> on 2004/02/16 22:16:34 UTC
how to store sessions in a database with jboss and tomcat
Hi!
I'm using Jboss 3.2.1 with Tomcat 4.1.24, and Tomcat is running as a
Jboss MBean.
I want to control the number of sessions each application can have. To
do this, I'm trying to store
sessions in a postgresql database, and use the Tomcat PersistentManager
Implementation.
The tomcat configuration is under the Jboss deploy directory, at the
following path:
/opt/jboss/server/default/deploy/jbossweb-tomcat.sar/
In this directory I have all the jar files needed by tomcat, a web.xml
file and a META-INF directory, with a manifest file and a
jboss-service.xml file (shown below)
I guess that something is wrong with jboss-service.xml file, because
almost everything works fine (the sessions are not being
stored in my database)
Can anyone help me?
thanks
Hugo Kotsubo
----------------------------------------------------------------------------------------------------------------
jboss-service.xml contents:
<?xml version="1.0" encoding="UTF-8"?>
<!-- The service configuration for the embedded Tomcat4.1.x web
container-->
<server>
<mbean code="org.jboss.web.catalina.EmbeddedCatalinaService41"
name="jboss.web:service=WebServer">
<attribute name="Java2ClassLoadingCompliance">true</attribute>
<!--
*******************************************************
****************** CLUSTERING *************************
*******************************************************
In order to activate HTTP Session clustering for Tomcat
make sure you run JBoss's "all" configuration i.e.
"run -c all"
(the default configuration doesn't contain clustering)
Furthermore, you may change SnapshotMode and
SnapshotInterval attributes below to indicate when to
synchronize changes with the other node(s).
If you use Apache+mod_jk(2) you will most probably use
the AJP1.3 connector below. Thus, if you so wish,
you may comment (i.e. deactivate) the HTTP connector
as it won't be used anymore.
*******************************************************
*******************************************************
*******************************************************
-->
<!--
If you are using clustering, the following two attributes
define when the sessions are replicated to the other nodes.
The default value, "instant", synchronously replicates changes
to the other nodes. In this case, the "SnapshotInterval" attribute
is not used.
The "interval" mode, in association with the "SnapshotInterval"
attribute, indicates that Tomcat will only replicates modified
sessions every "SnapshotInterval" miliseconds at most.
-->
<attribute name="SnapshotMode">instant</attribute> <!-- you may switch
to "interval" -->
<attribute name="SnapshotInterval">2000</attribute>
<attribute name="Config">
<Server>
<Service name = "JBoss-Tomcat">
<Engine name="MainEngine" defaultHost="localhost">
<Logger className = "org.jboss.web.catalina.Log4jLogger"
verbosityLevel = "debug" category =
"org.jboss.web.localhost.Engine"/>
<Host name="localhost">
<!-- Access logger -->
<Valve className =
"org.apache.catalina.valves.AccessLogValve"
prefix = "localhost_access" suffix = ".log"
pattern = "common" directory =
"${jboss.server.home.dir}/log" />
<!-- Default context parameters -->
<DefaultContext cookies = "true" crossContext = "true"
override = "true">
<Manager
className="org.apache.catalina.session.PersistentManager"
debug="0" saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="-1" maxIdleSwap="-1"
maxIdleBackup="-1">
<Store
className="org.apache.catalina.session.JDBCStore"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://localhost:5432/hugo-bi?user=hugo&password=hugo"
sessionTable="tomcatsessions" sessionIdCol="id"
sessionDataCol="data" sessionValidCol="valid"
sessionAppCol="appname"
sessionMaxInactiveCol="maxinactive"
sessionLastAccessedCol="lastaccess"
checkInterval="60" debug="99" />
</Manager>
</DefaultContext>
</Host>
</Engine>
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="3" maxProcessors="10"
enableLookups="true" acceptCount="10" debug="0"
connectionTimeout="20000" useURIValidationHack="false" />
<!-- A AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
</Service>
</Server>
</attribute>
</mbean>
</server>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org