在JBoss+MySQL环境下运行obe

**************************************************
*** 在JBoss+MySQL环境下运行obe             ***
**************************************************

 我按照obe文档的说明试着在JBoss+MySQL环境下运行obe程序,在部署obe程序后启动
JBoss,总是一堆的异常信息;我曾试过好几个版本的JBoss(3.2.3/3.2.5/4.0.0)都没有成功,
从cvs下载最新的源码后认真阅读了obe的文档,最后选择了JBoss 4.0.1,并对Configuration
Properties文件中使用的JBoss数据源配置进行了修改,当然我们也需要在JBoss中配置对应
的数据源信息。

##################################################
### obe文档中几个关键的说明部分
##################################################

1、关于运行obe的应用服务器(这是我们选择应用服务器的依据)
-----------------------------------------------------------------------------------------
Application Servers

The OBE build system is highly configurable and can easily be adapted to run on any J2EE
application server that is supported by XDoclet.  The OBE server runtime is known to work
with the following application servers:

JBoss 3.2.3+
JBoss 4.0.1+ (but not JBoss 4.0)
WebLogic 7.x
WebLogic 8.x
Note that of these, only JBoss 4.0.1 supports Servlet 1.3 as required by the OBE Web-based
Worklist Handler client
------------------------------------------------------------------------------------------

2、运行obe的应用服务器的资源配置(这段内容说明了运行obe所需要的数据源、JMS队列以及JAAS)
------------------------------------------------------------------------------------------
Configure the application server, to ensure that the resources required by OBE will be available.
The resources required include:

One DataSource, JNDI name (default 'MySQLDS') to match
Two JMS Queues, JNDI names 'OBEAsyncRequest' and 'OBEApplicationEvent'.
One JAAS Configuration, default name 'other'

------------------------------------------------------------------------------------------

3、关于运行obe的JBoss服务器的配置(这段内容说明了如何配置Jboss应用服务器)
------------------------------------------------------------------------------------------
OBE provides some preconfigured resources for use with JBoss, under ${staging.dir}/j2ee/jboss.
The conf and deploy directories can be copied to the ${as.dir}/server/default directory - you
will need to rename / edit the *-ds.xml data source definition file in the conf directory to
suit your database type and connection properties.  The 'default' server configuration should
be adequate for most purposes.  Do not use the 'minimal' server configuration - it does not provide
all the J2EE container functionality required by OBE.

Note that OBE provides a modified version of the Castor XML library that fixes certain critical bugs,
so it is necessary either to delete the one that comes with JBoss in ${jboss.home}/server/default/deploy/snmp-adaptor.sar,
or to replace it with the OBE version (castor-0.9.5.3.jar) if you wish to use the JBoss SNMP adaptor.
This incompatibility is the result of the JBoss UnifiedClassLoader3 merging the classpaths of the
various J2EE applications.
------------------------------------------------------------------------------------------


##################################################
### 运行环境说明
##################################################
1、操作系统:Windows2000 pro 
2、JBoss(4.0.1):(http://sourceforge.net/project/showfiles.phpgroup_id=22866&package_id=16942&release_id=305380)
3、MySQL(4.14):(http://www.mysql.com)
4、JDBC驱动程序:我使用的是mysql-connector-java-3.1.7-bin.jar,最新的驱动程序可以在(http://dev.mysql.com/downloads/connector/j)下载


##################################################
### 从cvs上下载的obe源程序
##################################################
1、cvs工具可以使用wincvs/TortoiseCVS

2、下载方法(转贴)
--------------------------------------------------
界面方式:
 认证方式:pserver
 路径:/cvsroot/obe
 主机地址:cvs.sourceforge.net
 用户名:anonymous
 登陆,密码为空,检出模块为 .(注意:一个点,表示下载当前目录下的所有东西)
 
命令方式:
$cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/obe login 
$cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/obe checkout .
--------------------------------------------------

##################################################
### 在MySQL中创建运行obe需要的数据库、用户名和密码
##################################################
mysql>create database obe;
mysql>grant all on *.* to obe@localhost identified by 'obe' with grant option;

##################################################
### 在JBoss中创建运行obe需要的数据源
##################################################
obe文档中指导我们在Jboss中配置的数据源名称为MySQLDS,我试着在Jboss中配置这个数据源,
但是配置后运行obe出现了其他的问题,所以我就参照Jboss的相关文档把obe使用MySQL的数据
源配置为DefaultDS,同时修改Jboss的相关配置让这个数据源可以正常使用。下面就如何在Jboss
中配置obe使用的DefaultDS数据源作详细说明。(注:在Jboss中,默认的DefaultDS数据源是hsql使用的)

1、首先把我们要使用的JDBC驱动程序拷贝到$JBOSS_HOME/server/default/lib目录下;
2、然后拷贝$JBOSS_HOME/docs/examples/jca/mysql-ds.xml到$JBOSS_HOME/server/default/deploy目录下;
3、用文本编辑器打开mysql-ds.xml文件,搜索找到配置项[<jndi-name>MySqlDS</jndi-name>],修改该配置
项为[<jndi-name>DefaultDS</jndi-name>],同时修改配置项[connection-url]、[driver-class]、[user-name]、
[password]以符合我们自己的环境。下面是我修改完成后的mysql-ds.xml配置文件内容:
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
<!--  Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/obe</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>obe</user-name>
    <password>obe</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <!-- sql to call when connection is created
    <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
    <!-- sql to call on an existing pooled connection when it is obtained from pool
    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->

    <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
    <metadata>
       <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>
------------------------------------------------------------------------------------------
4、由于$JBOSS_HOME/server/default/deploy目录下的hsqldb-ds.xml文件配置的数据源也为DefaultDS,
所以必须把这个文件删除掉
5、接下来配置Jboss的消息队列以可以使用我们配置的DefaultDS(for MySQL)数据源。
  A、拷贝$JBOSS_HOME/docs/examples/jms/mysql-jdbc2-service.xml到$JBOSS_HOME/server/default/deploy/jms
目录下;
  B、同样为了避免和hsqldb的冲突,需要把$JBOSS_HOME/server/default/deploy/jms目录下的hsqldb-jdbc2-service.xml删除掉;
  C、用文本编辑器打开mysql-jdbc2-service.xml文件,查找到配置项
[<depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=MySqlDS</depends>]后修改为
[<depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>]


至此,在Jboss+MySQL环境下运行obe的所有准备工作已经做完,接下来我们需要准确配置obe的编译选项。


##################################################
### 配置准确的obe properties文件
##################################################
在编译obe之前,首先需要准确配置obe所使用的AS环境和database环境,所有的这些配置模
板可以在obe文件夹的custom子文件夹中找到,如文件linux-mysql-jboss-4.0.properties
即为使用jboss作为AS,使MySQL数据库的配置模板。我们只需要根据自己的实际环境修改这个
文件即可。如我所配置的环境是jboss 4.0.1+mysql,那么我的.properties文件就如下所示
(加了中文注释的地方都需要修改):
--------------------------------------------------------------------------------
# Example settings for a Linux/MySQL-4.0/JBoss-4.0.1+ build.
# Copy mysql-ds.xml to $JBOSS_HOME/server/default/deploy
# Copy mysql-connector-java-3.0.15-ga-bin.jar to $JBOSS_HOME/server/default/lib

dist.zip=true
dist.tar=false
dist.tar.gz=false
dist.tar.bz2=false

# A convenience for defining the as.* properties.
# (这里指明Jboss的安装路径,Windows 下的'/'应替换为'/')
as.dir=D:/workflow_bin/jboss-4.0.1sp1-obe

# The name of the directory containing the app. server's start & stop commands.
#as.bin=${as.dir}/bin

# The name of the app. server's client jar file.
as.client.jar=${as.dir}/client/jbossall-client.jar

# The command to start the app. server (assumed to be in ${as.bin}).
# (Windows下的批处理文件是*.bat哦)
as.start=run.bat

# The command to stop the app. server (assumed to be in ${as.bin}).
as.stop=shutdown.bat --shutdown

# The URL under which Cactus runs the internal server tests.
cactus.contextURL=http://localhost:8080/obeserver-tests

# Path to the driver for use by the dbsetup task.
jdbc.classpath=${as.dir}/server/default/lib/mysql-connector-java-3.1.7-bin.jar

# JDBC driver class to use.
# (JDBC使用的class)
jdbc.driver=com.mysql.jdbc.Driver

# JDBC URL for database.
# (数据库连接url)
jdbc.url=jdbc:mysql://localhost:3306/obe

# Database user id.
# (访问数据库的用户名)
db.user=obe

# Database password.
# (访问数据库的用户所使用的密码)
db.password=obe

# Database schema.
db.type=mysql

# The class name of the JNDI initial context factory.
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

# The JAAS login configuration to use.
java.security.auth.login.config=${as.dir}/client/auth.conf

# The OBE client protocol to use in JUnit tests.
obe.client.protocol=rmi

# The URL of the app. server for RMI connections.
obe.server.host=jnp://localhost:1099

# The user ID under which JUnit tests connect to the app. server.
obe.client.principal=system

# The password under which JUnit tests connect to the app. server.
obe.client.credentials=password

# Required by JBossCMP.
xdoclet.jboss.typemapping=mySQL

# The JNDI name of the DataSource to use (defined in mysql-ds.xml). 
# (obe所使用的Jboss数据源)
xdoclet.jboss.datasource=java:/DefaultDS

# The JNDI name of the DataSource to use (this example matches the WebLogic-7.0 demo).
xdoclet.weblogic.datasource=examples-dataSource-demoXAPool

# The JNDI name of the JMS connection factory to use (this example matches the JBoss default).
xdoclet.jboss.ConnectionFactory=java:/ConnectionFactory

# The JNDI name of the JMS connection factory to use (this example matches the WebLogic-7.0 demo).
xdoclet.weblogic.ConnectionFactory=ConnectionFactory

# The JNDI name of the JavaMail Session to use (this example matches the JBoss default).
xdoclet.jboss.mail=java:/Mail

# The JNDI name of the JavaMail Session to use (WebLogic does not provide a default).
#xdoclet.weblogic.mail=

#weblogic.home=/usr/local/bea/weblogic81/server
weblogic.home=

#deploy.lib.dir=/home/adrian/obe/build/lib
#deploy.tests.war=${staging.j2ee.lib}/obeserver-tests.war
deploy.app.dir=${as.dir}/server/default/deploy
#deploy.app.ear=${as.dir}/server/default/deploy/obeserver.ear
--------------------------------------------------------------------------------
修改好上面的文件内容后,另存为windows-mysql-jboss-4.0.1.properties,存放在obe的根目录准备开始编译。

##################################################
### 编译obe源程序
##################################################
obe源程序的编译、部署分以下四个步骤:
1、利用prepare命令和上面的.properties文件生成本地化的local.properties文件,如下操作:
在命令行下进入到obe的根目录,执行如下命令prepare windows-mysql-jboss-4.0.1.properties

2、利用ant工具编译obe源程序,在obe根目录的命令行下,执行ant即可开始编译。

3、利用ant工具创建obe需要的数据表,在obe根目录的命令行下,执行ant createdb 即可.

4、执行ant deploy命令,ant会自动把生成的obeserver.ear文件部署到$JBOSS_HOME/server/default/deploy目录下。

至此,obe程序的编译、部署已经完成,接下来我们将启动Jboss服务器对我们的成果进行测试。

##################################################
### 启动Jboss服务器进行测试
##################################################
注意,在[obe文档中几个关键的说明部分]小节中,我们强调了obe运行时需要两个JMS消息队列
('OBEAsyncRequest' and 'OBEApplicationEvent'),那我们该如何在Jboss中配置这两个JMS消息队列呢?

在%OBE_HOME%/build/staging/j2ee/jboss-3.2/deploy/jms目录下有一个obe-jbossmq-destinations-service.xml文件,该文件配置了上面提到的JMS队列,拷贝该文件到$JBOSS_HOME/server/default/deploy/jms目录下,Jboss会在启动的时候自动读取该文件并创建指定的消息队列。obe-jbossmq-destinations-service.xml文件内容如下:
------------------------------------------------------------------------------------------
<server>
    <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=OBEAsyncRequest">
        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    </mbean>
    <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=OBEApplicationEvent">
        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    </mbean>
</server>
------------------------------------------------------------------------------------------

哈哈,一切准备工作就绪,在命令行下进入到$JBOSS_HOME/bin目录,执行run.bat文件启动Jboss,等启动Jboss后在浏览器中输入http://localhost:8080/obeworklist即可开始我们的测试了。使用用户名system、密码password登陆后即可看到obe的流程管理界面。

在测试obe工作流的时候,我们首先需要装载一个*.xpdl的流程定义文件,具体的操作过程就不在该文档中进行说明了,我将在我后续的学习笔记中进行详细的说明。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值