环境:tomcat5.0.18+mysql4.0.14+osworkflow例子。
1、导入etc\deployment\jdbc目录下mysql.sql(DB名字我定为osworkflow)
2、我的webapps下的目录名为oswfexmysql,则我在tomcat的conf\Catalina\localhost目录下新建文件oswfexmysql.xml即可
<?xml version=1.0 encoding=utf-8?>
<Context path="/oswfexmysql" docBase="oswfexmysql" debug="0" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_sessiontest_log." suffix=".txt" timestamp="true"/>
<Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
<Parameter name="context.param.name" value="context.param.value" override="false"/>
<Resource name="jdbc/oswf" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/oswf">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/osworkflow</value>
</parameter>
</ResourceParams>
</Context>
3、修改WEB-INF/classes目录下osworkflow.xml为:
<osworkflow>
<!--
<persistence class="com.opensymphony.workflow.spi.memory.MemoryWorkflowStore"/>
-->
<persistence class="com.opensymphony.workflow.spi.jdbc.MySQLWorkflowStore">
<property key="datasource" value="jdbc/oswf"/>
<property key="entry.sequence"
value="SELECT max(id)+1 FROM OS_WFENTRY"/>
<property key="entry.table" value="OS_WFENTRY"/>
<property key="entry.id" value="ID"/>
<property key="entry.name" value="NAME"/>
<property key="entry.state" value="STATE"/>
<property key="step.sequence"
value="SELECT max(ID)+1 FROM OS_STEPIDS"/>
<property key="step.sequence.increment"
value="INSERT INTO OS_STEPIDS (ID) values (null)"/>
<property key="step.sequence.retrieve"
value="SELECT max(ID) FROM OS_STEPIDS"/>
<property key="history.table" value="OS_HISTORYSTEP"/>
<property key="current.table" value="OS_CURRENTSTEP"/>
<property key="historyPrev.table" value="OS_HISTORYSTEP_PREV"/>
<property key="currentPrev.table" value="OS_CURRENTSTEP_PREV"/>
<property key="step.id" value="ID"/>
<property key="step.entryId" value="ENTRY_ID"/>
<property key="step.stepId" value="STEP_ID"/>
<property key="step.actionId" value="ACTION_ID"/>
<property key="step.owner" value="OWNER"/>
<property key="step.caller" value="CALLER"/>
<property key="step.startDate" value="START_DATE"/>
<property key="step.finishDate" value="FINISH_DATE"/>
<property key="step.dueDate" value="DUE_DATE"/>
<property key="step.status" value="STATUS"/>
<property key="step.previousId" value="PREVIOUS_ID"/>
</persistence>
<factory class="com.opensymphony.workflow.loader.XMLWorkflowFactory">
<property key="resource" value="workflows.xml" />
</factory>
</osworkflow>
4、修改osuer.xml为:
<opensymphony-user>
<provider class="com.opensymphony.user.provider.jdbc.JDBCAccessProvider">
<property name="user.table">OS_USER</property>
<property name="group.table">OS_GROUP</property>
<property name="membership.table">OS_MEMBERSHIP</property>
<property name="user.name">USERNAME</property>
<property name="user.password">PASSWORDHASH</property>
<property name="group.name">GROUPNAME</property>
<property name="membership.userName">USERNAME</property>
<property name="membership.groupName">GROUPNAME</property>
<property name="datasource">java:comp/env/jdbc/oswf</property>
</provider>
<provider class="com.opensymphony.user.provider.jdbc.JDBCCredentialsProvider">
<property name="user.table">OS_USER</property>
<property name="group.table">OS_GROUP</property>
<property name="membership.table">OS_MEMBERSHIP</property>
<property name="user.name">USERNAME</property>
<property name="user.password">PASSWORDHASH</property>
<property name="group.name">GROUPNAME</property>
<property name="membership.userName">USERNAME</property>
<property name="membership.groupName">GROUPNAME</property>
<property name="datasource">java:comp/env/jdbc/oswf</property>
</provider>
<provider class="com.opensymphony.user.provider.jdbc.JDBCProfileProvider">
<property name="user.table">OS_USER</property>
<property name="group.table">OS_GROUP</property>
<property name="membership.table">OS_MEMBERSHIP</property>
<property name="user.name">USERNAME</property>
<property name="user.password">PASSWORDHASH</property>
<property name="group.name">GROUPNAME</property>
<property name="membership.userName">USERNAME</property>
<property name="membership.groupName">GROUPNAME</property>
<property name="datasource">java:comp/env/jdbc/oswf</property>
</provider>
<!--
Authenticators can take properties just like providers.
This smart authenticator should work for "most" cases - it dynamically looks up
the most appropriate authenticator for the current server.
-->
<authenticator class="com.opensymphony.user.authenticator.SmartAuthenticator" />
</opensymphony-user>
5、在classes目录下加一文件propertyset.xml
<propertysets>
<propertyset name="jdbc"
class="com.opensymphony.module.propertyset.database.JDBCPropertySet">
<arg name="datasource" value="jdbc/oswf"/>
<arg name="table.name" value="OS_PROPERTYENTRY"/>
<arg name="col.globalKey" value="GLOBAL_KEY"/>
<arg name="col.itemKey" value="ITEM_KEY"/>
<arg name="col.itemType" value="ITEM_TYPE"/>
<arg name="col.string" value="STRING_VALUE"/>
<arg name="col.date" value="DATE_VALUE"/>
<arg name="col.data" value="DATA_VALUE"/>
<arg name="col.float" value="FLOAT_VALUE"/>
<arg name="col.number" value="NUMBER_VALUE"/>
</propertyset>
</propertysets>
6、确认自己的mysql驱动
7、run tomcat
8、over啦!!哈哈~~~
配置起来一路比较顺利,参考了几个大哥网上的例子。GOOD LUCK