2005年8月28日

               摘要: 本文介紹了一個簡單Stateless Session Bean的開發,及其在Jboss下的部署;并分別用java,jsp和servlet做為客戶端,測試了這個EJB。 2.1 創建目錄結構 ?= 1 \* GB3 ① 在D:\下新建一個myprojects目錄,用于存放自己開發的項目; ?= 2 \* GB3 ② 在myprojects目錄下新建1個helloworl...  閱讀全文
          posted @ 2005-08-28 10:26 neptune| 編輯 收藏
           

          本文介紹在Win2k環境下,用modjk1.2.x集成JbossTomcatApache;文章最后用一jsp文件測試了該集成環境。

          1.1 主要步驟

          下載集成TomcatJbossApachemodjk1.2.x

          修改Apache中的配置文件httpd.conf

          Apache中創建新文件workers.properties

          Apache中創建新文件uriworkermap.properties

          重新啟動Apache

          修改Jboss中的server.xmljboss-service.xml文件。

          啟動Jboss Application Server

          1.2 詳細說明

          1.2.1 軟件的下載和安裝

          本文所用的軟件版本為:j2sdk1.4Jboss3.2.7Apache2.0mod_jk-1.2.14jdk的下載,安裝和配置本文不再多說,用過java語言的人肯定都知道。

          集成TomcatJboss的下載

          http://www.jboss.com/downloads/index下載Jboss。將Jboss安裝到c:\javaApp目錄下。

          Apache的下載

          http://httpd.apache.org/下載Apache2.0。將Apache安裝到c:\javaApp目錄下。

          modjk的下載

          http://www.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/win32/

          下載mod_jk。把mod_jk-1.2.x.so文件拷貝到Apache2\modules目錄下。

          1.2.2 httpd.conf文件的修改

          打開Apache2\conf目錄下的httpd.conf文件,找到其中的LoadModule,然后在LoadModule的最后一行,加上下面的代碼:

          # Load mod_jk module

          # Specify the filename of the mod_jk lib

          LoadModule jk_module modules/mod_jk-1.2.14.so

          再在httpd.conf文件的最后,加上下面的代碼:

          # Where to find workers.properties

          JKWorkersFile conf/workers.properties

          # Where to put jk logs

          JKLogFile logs/jk.log

          # Set the jk log level [debug/error/info]

          JKLogLevel normal

          # Select the log format

          JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"

          # JkOptions indicates to send SSK KEY SIZE

          JkOptions+ForwardKeySize+ForwardURICompat-ForwardDirectories

          # JkRequestLogFormat

          JkRequestLogFormat "%w %V %T"

          # Mount your applications

          JKMount /web_application/* node1

          JkMount /web-console/* node1

          JkMount /jmx-console/* node1

          # You can use external file for mount points.

          # It will be checked for updates each 60 seconds.

          # The format of the file is: /url=worker

          # /examples/*=loadbalancer

          JkMountFile conf/uriworkermap.properties

          # Add shared memory.

          # This directive is present with 1.2.10 and

          # later versions of mod_jk, and is needed for

          # for load balancing to work properly

          # If there’s no this file under logs directory, create it manually.

          JkShmFile logs/jk.shm

          # Add jkstatus for managing runtime data

          <Location /jkstatus/>

          JkMount status

          Order deny,allow

          Deny from all

          Allow from 127.0.0.1

          </Location>   

          1.2.3 創建workers.properties文件

          Apache2\conf目錄下創建一新文件workers.properties,文件包含下面的內容:

          # Define list of workers that will be used

          # for mapping requests

          worker.list=loadbalancer,status

          # Define Node1

          worker.node1.port=8009

          # You can modify the Ip address to the actual Ip address

          worker.node1.host=127.0.0.1

          worker.node1.type=ajp13

          worker.node1.lbfactor=1

          #worker.node1.local_worker=1 (1)

          worker.node1.cachesize=10

          # Define Node2

          worker.node2.port=8009

          # You can modify the Ip address to the actual Ip address

          worker.node2.host= 127.0.0.1

          worker.node2.type=ajp13

          worker.node2.lbfactor=1

          #worker.node2.local_worker=1 (1)

          worker.node2.cachesize=10

          # Load-balancing behavior

          worker.loadbalancer.type=lb

          worker.loadbalancer.balance_workers=node1, node2

          worker.loadbalancer.sticky_session=1

          worker.loadbalancer.local_worker_only=1

          worker.list=loadbalancer

          # Status worker for managing load balancer

          worker.status.type=status

          1.2.4 創建uriworkermap.properties文件

          Apache2\conf目錄下創建一新文件uriworkermap.properties,文件包含下面的內容:

          # Simple worker configuration file

          # Mount the Servlet context to the ajp13 worker

          /jmx-console=loadbalancer

          /jmx-console/*=loadbalancer

          /web-console=loadbalancer

          /web-console/*=loadbalancer

          # You should modify the “web_application” to

          # the real name of the web application

          / web_application =loadbalancer

          / web_application /*=loadbalancer

          做完上面的所有步驟后,重新啟動Apache

          1.2.5 修改Jboss中的server.xml和jboss-service.xml文件

          打開jboss-3.2.7\server\default\deploy\jbossweb-tomcat50.sar目錄下的server.xml文件。

          <Engine name="jboss.web" defaultHost="localhost">修改為:

          <Engine name="jboss.web" defaultHost="localhost"

          jvmRoute="node1">

          因為集成Apache后,由Apache來處理Http請求,所以可以把下面的代碼注釋掉:

          <Connector port="8080" address="${jboss.bind.address}"

          maxThreads="150" minSpareThreads="25" maxSpareThreads="75"

          enableLookups="false" redirectPort="8443" acceptCount="100"

          connectionTimeout="20000" disableUploadTimeout="true"/>

          打開jboss-3.2.7\server\default\deploy\jbossweb-tomcat50.sar\

          META-INF目錄下的jboss-service.xml文件。

          <attribute name="UseJK">false</attribute>修改為:

          <attribute name="UseJK">true</attribute>

          啟動Jboss,在IE瀏覽器中輸入http://127.0.0.1/web-console,如果配置成功,將顯示Jbossweb管理頁面。

          1.3 測試jsp文件

          jboss-3.2.7\server\default\deploy目錄下新建一個helloworld目錄,然后在helloworld目錄下新建一個hello.war目錄。在hello.war目錄下創建一個test.jsp文件,文件代碼如下:

          <HEAD>

          <TITLE>test.jsp</TITLE>

          </HEAD>

          <BODY topMargin=0 marginheight="0">

          <DIV align=center>

          <%

          String helloworld = "Hello world!";

          out.println(helloworld);

          %>

          </DIV>

          </BODY>

          </HTML>

          修改uriworkermap.properties文件,添加下面的代碼:

          /hello=loadbalancer

          /hello/*=loadbalancer

          修改httpd.conf文件,添加下面的代碼:

          JKMount /hello/* node1

          打開IE,輸入http://127.0.0.1/hello/test.jsp,頁面將顯示出
          Hello world!

          作者:蔡曉均

          E-mail地址:neptunecai@yahoo.com.cn

          版權所有,轉摘請注明:摘自www.aygfsteel.com/neptune

          posted @ 2005-08-28 09:40 neptune 閱讀(1619) | 評論 (0)編輯 收藏
           
          主站蜘蛛池模板: 宁津县| 基隆市| 石阡县| 迁安市| 丹东市| 略阳县| 临汾市| 英山县| 盘山县| 高州市| 凤翔县| 阜新市| 呼伦贝尔市| 沿河| 泰顺县| 大英县| 从江县| 民勤县| 巫溪县| 万州区| 夏邑县| 方城县| 沭阳县| 若羌县| 罗定市| 信阳市| 出国| 得荣县| 驻马店市| 镶黄旗| 海晏县| 南雄市| 伊金霍洛旗| 柯坪县| 公主岭市| 龙南县| 云安县| 大邑县| 克拉玛依市| 盘山县| 松阳县|