**************************************************
*** 准确编译 obe 的 cvs源程序 ***
**************************************************
##################################################
### 从cvs上下载的obe源程序
##################################################
1、cvs工具可以使用wincvs/TortoiseCVS
2、下载方法(转贴)
--------------------------------------------------
界面方式:
认证方式:pserver
路径:/cvsroot/obe
主机地址:cvs.sourceforge.net
用户名:anonymous
anonymous@cvs.sourceforge.net:/cvsroot/obe
登陆,密码为空,检出模块为 .(注意:一个点,表示下载当前目录下的所有东西)
命令方式:
$cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/obe login
$cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/obe checkout .
--------------------------------------------------
##################################################
### 准备准确的obe properties文件
##################################################
在编译obe之前,首先需要准确配置obe所使用的AS环境和database环境,所有的这些配置模
板可以在obe文件夹的custom子文件夹中找到,如文件linux-mysql-jboss-3.2.3.properties
即为使用jboss作为AS,使MySQL数据库的配置模板。我们只需要根据自己的实际环境修改这个
文件即可。如我所配置的环境是jboss3.2.3+mysql+obe,其中jboss安装目录为D:\cvs_down\obe\jboss-3.2.3,
mysql的驱动程序为D:\cvs_down\obe\lib\mysql-connector-java-3.1.7-bin.jar,那么我的
.properties文件就如下所示:
--------------------------------------------------------------------------------
# Example settings for a Linux/MySQL-4.0/JBoss-3.2.3+ build.
# Copy mysql-ds.xml to $JBOSS_HOME/server/default/deploy
# Copy mysql-connector-java-3.0.8-stable-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.
as.dir=D:/cvs_down/obe/jboss-3.2.3(###as的安装目录,注意把windows的'/'替换为'\'###)
# 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}).
as.start=run.bat(###windows下启动as时是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=D:/cvs_down/obe/lib/mysql-connector-java-3.1.7-bin.jar
# JDBC driver class to use.
jdbc.driver=com.mysql.jdbc.Driver
# JDBC URL for database.(###注意修改为你自己的数据库名、用户名、密码###)
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).
xdoclet.jboss.datasource=java:/MySQLDS
# 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
--------------------------------------------------------------------------------
准备好上面说到的文件后,保存为.properties,存放在obe的根目录准备开始编译。
##################################################
### 编译obe源程序
##################################################
obe源程序的编译、部署分以下三个步骤:
1、利用prepare命令和上面的.properties文件生成本地化的local.properties文件,如下操作:
在命令行下进入到obe的根目录,执行如下命令prepare windows-mysql-jboss-3.2.3.properties
2、利用ant工具编译obe源程序。
在obe根目录下执行ant命令后,ant根据build.xml指定的规则编译obe程序,在编译过程中提示如下
错误信息:
--------------------------------------------------------------------------------
compile:
[mkdir] Created dir: E:\Asir_CVS\obe\build\obe\obeengine\classes
[javac] Compiling 209 source files to E:\Asir_CVS\obe\build\obe\obeengine\cl
asses
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:54: package org.exolab.castor.mapping does not exist
[javac] import org.exolab.castor.mapping.Mapping;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:55: package org.exolab.castor.xml does not exist
[javac] import org.exolab.castor.xml.MarshalListener;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:56: package org.exolab.castor.xml does not exist
[javac] import org.exolab.castor.xml.Marshaller;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:57: package org.exolab.castor.xml does not exist
[javac] import org.exolab.castor.xml.UnmarshalListener;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:58: package org.exolab.castor.xml does not exist
[javac] import org.exolab.castor.xml.Unmarshaller;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:78: cannot resolve symbol
[javac] symbol : class Mapping
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] private static final Mapping _mapping;
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:86: cannot resolve symbol
[javac] symbol : class Mapping
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] _mapping = new Mapping(AbstractRepository.class.getClassLoad
er());
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:161: cannot resolve symbol
[javac] symbol : class Unmarshaller
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] Unmarshaller unmarshaller = new Unmarshaller(
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:164: cannot resolve symbol
[javac] symbol : class UnmarshalListener
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] unmarshaller.setUnmarshalListener(new UnmarshalL
istener() {
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:252: cannot resolve symbol
[javac] symbol : class Marshaller
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] Marshaller marshaller = new Marshaller(writer);
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:252: cannot resolve symbol
[javac] symbol : class Marshaller
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] Marshaller marshaller = new Marshaller(writer);
[javac] ^
[javac] E:\Asir_CVS\obe\obe\obeengine\src\org\obe\engine\repository\Abstract
Repository.java:255: cannot resolve symbol
[javac] symbol : class MarshalListener
[javac] location: class org.obe.engine.repository.AbstractRepository
[javac] marshaller.setMarshalListener(new MarshalListener()
{
[javac] ^
[javac] Note: E:\Asir_CVS\obe\obe\obeengine\src\org\obe\convert\ConverterReg
istry.java uses or overrides a deprecated API.
[javac] Note: Recompile with -deprecation for details.
[javac] 13 errors
BUILD FAILED
file:E:/Asir_CVS/obe/obe/obeengine/build.xml:140: Compile failed; see the compil
er error output for details.
Total time: 38 seconds
--------------------------------------------------------------------------------
为什么cvs上面的代码在编译是会提示错误呢?这正是本文要解决的问题。
在错误的开始处可以看到这样的提示“package org.exolab.castor.mapping does not exist”,
这也就是说我们编译的时候有某些jar包没有在classpath中,那么到底是那个jar包呢?
通过google可以知道,我们所缺少的是castor这个jar包(Castor是ExoLab Group下面的一个
开放源代码的项目,它主要实现的是O/R映射功能。它主要API和数据接口为:JDO-like, SQL,
OQL, JDBC, LDAP, XML, DSML。它支持分布式目录事务处理和时间;提供处理XML、Directory、
XADirectory的类库,提供从XML到JAVA类的转换机制。其中最重要的就是其XML映射机制和其
独创的Castor JDO的机制了);但是在obe源码的lib目录下明明有一个castor-0.9.5.3-xml.jar
的文件存在啊,那为什么还会出错呢?
上面我们提到了通过prepare windows-mysql-jboss-3.2.3.properties命令来生成适合自己环境
的local.properties文件,那么这个local.properties文件是否真的适合我们自己的环境呢?
打开local.properties文件,搜索castor关键字,我们会发现这样一行:
--------------------------------------------------------------------------------
castor.jar=castor-0.9.9-xml.jar
--------------------------------------------------------------------------------
而obe源码的lib目录下的castor包是castor-0.9.5.3-xml.jar,很明显,问题就是jar包的版本
不对引起的,可以在http://www.castor.org/下载castor-0.9.9-xml.jar文件,放到obe源码的
lib目录下即可。
OK,重新输入ant命令进行编译,编译成功!
3、把obe程序部署到AS服务器上
在命令行输入ant deploy后,ant会自动把生成的obeserver.ear文件部署到AS上。
希望本文能给大家一点帮助,少走一些弯路,谢谢......
另外,我还有个问题,就是obeserver.ear部署到AS上以后,启动AS(jboss)后总是提示部署这个
文件错误。如果那位有这方面的资料,请回复。