分享
 
 
 

通过ant+jBoss学习MasteringEJB,部署HelloWorld

王朝java/jsp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

所需的软件:

ant,j2sdk,j2ee.

我的环境变量设置(我定义在用户变量中):

J2EE_HOME=f:\j2sdkee1.3.1 JAVA_HOME=f:\j2sdk1.4.1_01 JBOSS_HOME=f:\jboss

Path=.;f:\j2sdk1.4.1_01\bin;f:\j2sdkee1.3.1\bin;f:\ant1.5.2\bin

CLASSPATH=.;f:\j2sdk1.4.1_01\lib\dt.jar;f:\j2sdk1.4.1_01\lib\tools.jar;f:\j2sdkee1.3.1\lib\j2ee.jar

我的模板项目的结构和文件内容,便于以后拷贝。

build.xml

<?xml version="1.0"?>

<!-- ======================================================================= -->

<!-- Template build file -->

<!-- ======================================================================= -->

<project name="template" default="main" basedir=".">

<!--

Give user a chance to override without editing this file

(and without typing -D each time they run it)

-->

<property file=".ant.properties" />

<property file="${user.home}/.ant.properties" />

<property name="Name" value="Template"/>

<property name="version" value="1.1"/>

<target name="check-jboss" unless="jboss.home">

<fail>

Property "jboss.home" is not set. Please use the file

".ant.properties" in this directory ${basedir} to

set this property. It must point to the directory which

contains the following directory: "deploy", "conf", "tmp"

etc.

</fail>

</target>

<target name="wrong-jboss" unless="jboss.present">

<fail>

Property "jboss.home" is set but it does not seem

to point to the right directory. The file "run.jar"

must be available at ${jboss.home}/bin.

</fail>

</target>

<target name="check-environment">

<antcall target="check-jboss"/>

<available property="jboss.present" file="${jboss.home}/bin/run.jar"/>

<antcall target="wrong-jboss"/>

</target>

<target name="init" depends="check-environment">

<echo message="build.compiler = ${build.compiler}"/>

<echo message="user.home = ${user.home}"/>

<echo message="java.home = ${java.home}"/>

<echo message="ant.home = ${ant.home}"/>

<echo message="jboss.home = ${jboss.home}"/>

<echo message="java.class.path = ${java.class.path}"/>

<echo message=""/>

</target>

<property name="jboss.lib" value="${jboss.home}/lib" />

<property name="jboss.client" value="${jboss.home}/client" />

<!-- Configuration used on JBoss 3 to run your server. There must be

a directory with the same name under "${jboss.home}/server" -->

<property name="jboss.configuration" value="default" />

<property name="jboss.deploy" value="${jboss.home}/server/${jboss.configuration}/deploy" />

<property name="src.dir" value="${basedir}/src"/>

<property name="src.main.dir" value="${src.dir}/main"/>

<property name="src.client.dir" value="${src.main.dir}/client"/>

<property name="src.ejb.dir" value="${src.main.dir}/ejb"/>

<property name="src.etc.dir" value="${src.dir}/etc"/>

<property name="src.resources" value="${src.dir}/resources"/>

<property name="resources" value="${basedir}/resources"/>

<property name="build.dir" value="${basedir}/build"/>

<property name="build.tmp.dir" value="${build.dir}/tmp"/>

<property name="build.deploy.dir" value="${build.dir}/deploy"/>

<property name="build.generate.dir" value="${build.dir}/generate"/>

<property name="build.classes.dir" value="${build.dir}/classes"/>

<property name="build.war.dir" value="${build.dir}/war"/>

<property name="build.client.dir" value="${build.dir}/client"/>

<property name="build.bin.dir" value="${build.dir}/bin"/>

<property name="build.javadocs.dir" value="${build.dir}/docs/api"/>

<path id="base.path">

<pathelement location="${jboss.client}/jboss-j2ee.jar" />

<pathelement location="${jboss.client}/jnp-client.jar" />

<pathelement location="${jboss.client}/jbossmq-client.jar" />

<pathelement location="${jboss.client}/jbosssx-client.jar" />

<pathelement location="${jboss.client}/concurrent.jar" />

<pathelement location="${jboss.client}/jaas.jar" />

<pathelement location="${jboss.lib}/jboss-jmx.jar" />

<pathelement location="${jboss.home}/server/${jboss.configuration}/lib/jbosssx.jar" />

<pathelement location="${jboss.home}/server/${jboss.configuration}/lib/mail.jar" />

<pathelement location="${build.classes.dir}" />

</path>

<!-- =================================================================== -->

<!-- Generates the necessary EJB classes and deployment descriptors -->

<!-- =================================================================== -->

<!-- =================================================================== -->

<!-- Compiles the source code -->

<!-- =================================================================== -->

<target name="compile" depends="init">

<mkdir dir="${build.classes.dir}"/>

<javac

srcdir="${src.ejb.dir}"

destdir="${build.classes.dir}"

debug="on"

deprecation="off"

optimize="on"

classpathref="base.path"

>

</javac>

<javac

srcdir="${src.client.dir}"

destdir="${build.classes.dir}"

debug="on"

deprecation="off"

optimize="on"

classpathref="base.path"

>

</javac>

</target>

<!-- =================================================================== -->

<!-- Creates the jar archives -->

<!-- =================================================================== -->

<target name="jar" depends="compile">

<mkdir dir="${build.deploy.dir}"/>

<mkdir dir="${build.bin.dir}"/>

<mkdir dir="${build.client.dir}"/>

<jar

jarfile="${build.deploy.dir}/ejb-test.jar"

>

<fileset

dir="${build.classes.dir}"

excludes="*Client.*"

>

</fileset>

<fileset

dir="${resources}/ejb-jar"

includes="META-INF/**"

>

</fileset>

</jar>

<jar

jarfile="${build.client.dir}/client-test.jar"

>

<fileset

dir="${build.classes.dir}"

excludes="*Bean.*"

>

</fileset>

</jar>

</target>

<!-- =================================================================== -->

<!-- Creates the client binary -->

<!-- =================================================================== -->

<target name="deploy-server" depends="jar">

<copy todir="${jboss.deploy}">

<fileset dir="${build.deploy.dir}" includes="*.jar,*.war,*.ear">

</fileset>

</copy>

</target>

<!-- =================================================================== -->

<!-- Creates the client binary -->

<!-- =================================================================== -->

<target name="create-client" depends="jar">

<!-- Convert the given paths to Windows -->

<pathconvert targetos="windows" property="jboss.home.on.windows" >

<path>

<pathelement location="${jboss.home}" />

</path>

</pathconvert>

<pathconvert targetos="windows" property="java.home.on.windows" >

<path>

<pathelement location="${java.home}" />

</path>

</pathconvert>

<filter token="jboss.home" value="${jboss.home.on.windows}"/>

<filter token="java.home" value="${java.home.on.windows}"/>

<copy todir="${build.bin.dir}" filtering="yes">

<fileset dir="${src.etc.dir}/bin" includes="run-*client.bat">

</fileset>

</copy>

<copy file="${src.etc.dir}/bin/lcp.bat" todir="${build.bin.dir}"/>

<copy file="${src.etc.dir}/jndi.properties" todir="${build.bin.dir}"/>

</target>

<!-- =================================================================== -->

<!-- Creates the binary structure -->

<!-- =================================================================== -->

<target name="main" depends="deploy-server,create-client">

</target>

<!-- =================================================================== -->

<!-- Cleans up the current build -->

<!-- =================================================================== -->

<target name="clean" depends="init">

<delete dir="${build.dir}"/>

</target>

</project>

jboss.xml

<?xml version="1.0" encoding="UTF-8"?>

<jboss>

<enterprise-beans>

<session>

<ejb-name>Hello</ejb-name>

<jndi-name>HelloHomeRemote</jndi-name>

</session>

</enterprise-beans>

</jboss>

ejb-jar.xml

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar>

<enterprise-beans>

<session>

<ejb-name>Hello</ejb-name>

<home>HelloHome</home>

<remote>Hello</remote>

<ejb-class>HelloBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

</session>

</enterprise-beans>

</ejb-jar>

.ant.properties

# ATTENTION: this is an example file how to overwrite settings in this project

# Please rename it to ".ant.properties" and adjust the settings to your needs

# Set the path to the runtime JBoss directory containing the JBoss application server

# ATTENTION: the one containing directories like "bin", "client", "server" etc.

jboss.home=f:/jboss

ant.home=f:/ant1.5.2

# Set the configuration name that must have a corresponding directory under

# <jboss.home>/server

jboss.configuration=default

目录结构:

resources\ejb-jar\META-INF下:

src\etc\bin下:

src\etc\WEB-INF下:

template下:

备注:1.如果要在.xml文件中加中文注释,把encoding=”GB2312”.

2.关于ant的用法可参看《Java深度历险》

3.关于.xml文件中属性的意义可参看:《MasteringEJB 2》

4. JBoss的模板http://sourceforge.net/project/showfiles.php?group_id=22866&release_id=111113

5.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有