新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论Java, J2SE, J2ME, J2EE, 以及Eclipse, NetBeans, JBuilder等Java开发环境,还有JSP, JavaServlet, JavaBean, EJB以及struts, hibernate, spring, webwork2, Java 3D, JOGL等相关技术。
    [返回] 中文XML论坛 - 专业的XML技术讨论区计算机技术与应用『 Java/Eclipse 』 → (转贴)JBoss3学习笔记 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 13135 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: (转贴)JBoss3学习笔记 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     mfc42d 帅哥哟,离线,有人找我吗?
      
      
      等级:大三暑假(ITELS考了6.5分!)(版主)
      文章:65
      积分:882
      门派:XML.ORG.CN
      注册:2004/6/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给mfc42d发送一个短消息 把mfc42d加入好友 查看mfc42d的个人资料 搜索mfc42d在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看mfc42d的博客楼主
    发贴心情 (转贴)JBoss3学习笔记

    作者: Thatway (mailto:outhatway (at) hotmail (dot) com)
    来自: http://www.hibernate.org.cn

    修订记录: 2003.9.30 JBoss MQ 报错。主要原因为前版本把 DefaultDS 数据源去掉了。

    目 录

    一. 运行环境
    二. 准备工作
    三. 安装
    四. 配置实例xPetStore
    1. 创建JBOSS“xpetstore”服务
    2. 配置JMS
    3. 配置JDBC
    4. 配置JavaMail
    5. 启动JBOSS
    6. 指定xPetStore的应用服务器
    7. 指定数据库
    8. Build源代码
    9. 发布应用
    10. 初始化数据库
    11. 运行应用
    12. 意外错误排除
    五. 结束语

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

    一. 运行环境
    操作系统:Windows 2000

    应用服务器:Jboss3.x

    数据库:MySQL4.x

    虚拟机: SUN JDK1.4.x


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

    二. 准备工作
    1.请安装JDK1.4.x版本,设置JAVA_HOME变量,并把 “{%JAVA_HOME%}\bin” 加入Path中。

    2.请下载Jboss3.x。主站地址 http://www.jboss.org/ 。

    3.请下载并安装MySQL4.x。主站地址 http://www.mysql.org/ 。

    4. 请下载xpetstore3.x。主页地址 http://xpetstore.sourceforge.net/ 。


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

    三. 安装
    1. 把压JBOSS下载文件解压。本文假设解压后路径为 C:\Work\jboss-3.2.2RC2。

    2. 设置JBOSS_HOME变量。进行命令窗口,运行bin目录下的run.bat命令。请注意后台有没有抛出异常。

    3. 约半分钟后启动完毕,请访问 http://localhost:8080/jmx-console/ 。如果成功显示页面,说明安装成功。

    4. 进行命令窗口,运行bin目录下的 shutdown.bat -S 命令可以停止JBOSS。


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

    四. 配置实例xPetStore
    1. 创建JBOSS“xpetstore”服务
    在JBOSS_HOME/server/下新建目录xpetstore,并把JBOSS_HOME/server/default下的内容拷贝到xpetstore下。

    2. 配置JMS
    Create JBOSS_HOME\server\xpetstore\deploy\jms\jbossmq-destinations-xpetstore-service.xml to create JMS queues queue/order and queue/mail.

    This xml file should look like this:

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

    <!-- $Id: jbossmq-destinations-xpetstore-service.xml,v 1.0 2003-8-11 15:47 et Exp $ -->

    <server>
      <!-- Destination without a configured SecurityManager or without a
           a SecurityConf will default to role guest with read=true, write=true,
           create=false.
      -->

      <mbean code="org.jboss.mq.server.jmx.Queue"
         name="jboss.mq.destination:service=Queue,name=order">
        <attribute name="JNDIName">queue/order</attribute>
        <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=mail">
        <attribute name="JNDIName">queue/mail</attribute>
        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
      </mbean>

    </server>

    3. 配置JDBC
    Copy the JDBC driver to JBOSS_HOME/server/xpetstore/lib。

    Create JBOSS_HOME/server/xpetstore/deploy/mysql-ds.xml. (Do NOT change the hsqldb-ds.xml, keep it.)

    Edit mysql-ds.xml to create the datasource java:/xpetstoreDS。

    JBOSS_HOME/server/xpetstore/deploy/mysql-ds.xml should look like this:

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

    <!-- $Id: mysql-ds.xml,v 1.0 2003-8-11 15:56 et Exp $ -->


    <datasources>
      <local-tx-datasource>
        <jndi-name>xpetstoreDS</jndi-name>
        <connection-url>jdbc:mysql://localhost/xpetstore</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>thatway</user-name>
        <password>thatway</password>
        <min-pool-size>5</min-pool-size>
        <security-domain>HsqlDbRealm</security-domain>
      </local-tx-datasource>
      
    </datasources>

    4. 配置JavaMail
    Create the Mail-Sesion java/:Mail.

    Make sure that JBOSS_HOME/server/xpetstore/deploy/mail-service.xml look like this:

    <server>
      <classpath codebase="lib"
                 archives="mail.jar, activation.jar, mail-plugin.jar"/>

      <mbean code="org.jboss.mail.MailService"
             name="jboss:service=Mail">
        <attribute name="JNDIName">Mail</attribute>
        <attribute name="User">your-user-name</attribute>
        <attribute name="Password">your-password</attribute>
        <attribute name="Configuration">
           <configuration>
              <property name="mail.store.protocol" value="pop3"/>
              <property name="mail.transport.protocol" value="smtp"/>
              <property name="mail.user" value="your-username"/>
              <property name="mail.pop3.host" value="your-pop3-host"/>
              <property name="mail.smtp.host" value="your-smtp-host"/>
              <property name="mail.from" value="noreply@xpetstore.sourceforge.net"/>
              <property name="mail.debug" value="false"/>
           </configuration>
        </attribute>
      </mbean>
    </server>

    5. 启动JBOSS
    cd JBOSS_HOME/bin
    run.bat -c xpetstore

    6. 指定xPetStore的应用服务器
    Download and unzip the xpetstore3.1.x file.

    Edit the file XPETSTORE_HOME/conf/as/appserver.properties and set the property app.server=jboss. You may want to review XPETSTORE_HOME/conf/as/jboss.properties to make sure that all the properties are properly set.

    7. 指定数据库
    Edit the file XPETSTORE_HOME/conf/db/database.properties and set the property db.name=mysql.

    Edit the file XPETSTORE_HOME/conf/db/mysql.properties to configure the database.You must set the following properties:

    db.driver
    db.url
    db.user
    db.password
    db.classpath

    PS: Don't change the hibernate properties.

    8. Build源代码
    cd XPETSTORE_HOME/xpetstore-servlet , run build.bat :

    build.bat

    This command will :

    Generate Java code in XPETSTORE_HOME/xpetstore-servlet/build/java

    Generate the deployment descriptors at XPETSTORE_HOME/xpetstore- servlet/build/META-INF and XPETSTORE_HOME/xpetstore- servlet/build/WEB-INF

    Compile the source code and build .jar, .war and .ear files at XPETSTORE_HOME/dist

    经测试,事实上这样build是不足够的,在发布运行的过程中会出错。但考虑到官方文件是这样说的,并且这些的确是正确的主要步骤。之所以不能运行,完全是“意外”问题。因此,我们暂且跳过,到运行时再把步骤补全。

    9. 发布应用
    build.bat deploy

    10. 初始化数据库
    build.bat db

    11. 运行应用
    http://localhost:8080/xpetstore-servlet/

    12. 意外错误排除
    第一次build的过程会抛出xpetstore-servlet\build\META-INF not found的错误。此时,可以手工在相应目录建立META-INF文件夹。再运行build。

    再发布时会抛出错误:Exception processing TLD at resource path /META-INF/taglib.tld。此时,可以手工将XPETSTORE_HOME\lib\main\com.opensymphony.module.webwork\webword.jar\META-INF中的taglib.tld 拷贝到XPETSTORE_HOME\xpetstore-servlet\web\META-INF目录下。(META-INF是手工建立的)。再编辑XPETSTORE_HOME\xpetstore-servlet\build.xml,在“WAR”栏加入以下语句把taglib.tld拷贝进war中。再运行build。

                <!-- Added by thatway 2003-8-5 13:40-->
                  <metainf dir="${web.dir}/META-INF">
                      <include name="**/*" />
                  </metainf>
                <!-- END -->

    发布时还会提出错误,主要原因是Hibernate getConnection时不能通过JBOSS的安全验证。此时,要修改JBOSS_HOME/server/xpetstore/conf/login_config.xml和JBOSS_HOME/server/xpetstore/deploy/mydql_ds.xml。

    先说login_config.xml。参照HsqlDbRealm段,添加如下代码。

        <application-policy name = "MysqlDbRealm">
           <authentication>
              <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
                 flag = "required">
                 <module-option name = "principal"></module-option>
                 <module-option name = "userName"></module-option>
                 <module-option name = "password"></module-option>
                 <module-option name = "managedConnectionFactoryName">
                     jboss.jca:service=LocalTxCM,name=xpetstoreDS
                 </module-option>
              </login-module>
           </authentication>
        </application-policy>

    再到mysql_ds.xml。修改security-domain值。

    <security-domain>MysqlDbRealm</security-domain>


    注意1:修改login-config.xml需要重启JBOSS才生效;修改mysql.xml则不必。


    注意2:调试的过程中必然会多次重启JBOSS,如果xpetstore还没有发布成功的话,重启前请删除deploy目录下的xpetstore发布文件。

    五. 结束语
    至此,我们的痛苦就结束了。请访问 http://localhost:8080/xpetstore-servlet/ 看一看自己辛劳的成果。如果还运行失败,请联系我 mailto:outhatway (at) hotmail (dot) com 。

    此番配置有两个目的,一是熟悉JBOSS,二是便于学习xpetstore源代码。第一个目标我们是达到了,但第二个目标现在才开始,所以让我们一起共勉,继续努力。

    Last update 03 3月 04, 15:51, up to 9523 views.

    [此贴子已经被作者于2004-10-19 20:19:35编辑过]

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/18 14:35:00
     
     xmzhy 帅哥哟,离线,有人找我吗?狮子座1978-8-18
      
      
      威望:5
      等级:计算机学士学位
      文章:385
      积分:2003
      门派:XML.ORG.CN
      注册:2003/10/22

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xmzhy发送一个短消息 把xmzhy加入好友 查看xmzhy的个人资料 搜索xmzhy在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xmzhy的博客2
    发贴心情 
    ding
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/3/10 11:28:00
     
     GoogleAdSense狮子座1978-8-18
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Java/Eclipse 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/28 20:55:25

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    4,476.563ms