程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> 新興開放源碼J2EE應用平台

新興開放源碼J2EE應用平台

編輯:關於JAVA
新興開放源碼J2EE(J2EE培訓 )應用平台注:這是兩年前寫的了,現在jbuilder已經用2005了,JBoss也用4。x了,mysql也用5.0了,新的功能所能實現的功能毫無疑問不止這些,有時間再補上!一.平台架構描述本平台由三部分組成,開發環境、應用服務器環境和數據存儲環境;1. J2EE開發環境JBuilder 7 企業版配合JBoss 3.0.0,開發環境配置如下:a) 配置數據庫連接驅動,我們使用MySql, 因此需要配置mysql_odbc或mysql_jdbc,其中如果使用jdbc的話,需要建立新的庫,此庫包含了MySQL_jdbc驅動,並把該庫加入到項目庫中;b) 配置JBoss的JBuider 7插件(配合插圖): i. 首先把插件打包文件拷貝到JBuider 7/lib/ext目錄中; ii. 啟動JBuilder, 在工具菜單中選擇配置服務器; iii. 從服務器列表中選擇JBoss 3x; iv. 然後選中“啟用服務器”復選框; v. 選擇JBoss的安裝目錄,此時切換到“定制頁”; vi. 選擇JBoss的起始目錄和工作目錄,最後確認提交; vii. 並重啟JBuilder,在項目屬性裡配置自己需要的服務器:其中,運行時服務器為Tomcat 4.0,項目服務器為不同模塊服務對應不同的服務器;2. J2EE應用服務器應用服務器有三個模塊組成:JBoss 3.0.0, Tomcat 4.0.3, Apache 2.0.4;c) JBoss主要提供EJB等企業級組件和其他相關服務,其配置如下: i. 首先,要配置java 1.4.1平台,即設置Java_home和classpath; ii. 其次,解壓JBoss(內嵌Tomcat 4)到特定文件夾;d) 配置阿帕奇到tomcat的連接: i. 修改apache的配置文件httpd.confListen *:80(在所有地址上監聽80端口)ServerName apacheDirectoryIndex index.html index.html.var index.html.en index.JSP(添加自己需要的目錄起始文件名)DefaultType application/octet-stream(使服務器可以處多種類型的文檔)AddDefaultCharset GB2312(自己需要的響應缺省字符集) ServerName apache DirectoryIndex index.PHP index.html index.htm index.shtml index.html.en index.jsp(目錄起始文件名) ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-Access_log common(虛擬主機)Include D:/Apache2/Apache2/conf/JK//mod_jk.conf(包含mod_jk的配置文件) ii.mod_jk.conf的內容如下實例 LoadModule jk_module D:/Apache2/Apache2/conf/JK//mod_jk.dll JkLogLevel info JkOptions +ForwardKeySize +ForwardURICompatJkWorkersFile D:/Apache2/Apache2/conf/JK/workers.propertIEsJkLogFile D:/Apache2/apache2/conf/JK//mod_jk.log JkMount /*.JSp ajp13JkMount /servlet/* ajp13 Alias /test "E:/Room/testonline2.5/defaultroot" Options Indexes FollowSymLinks MultiVIEws IncludesNoExec AddOutputFilter Includes html AllowOverride None Order allow,deny Allow from all JkMount /test/servlet/* ajp13JkMount /test/*.JSP ajp13 AllowOverride None deny from all Alias /account "E:/Room/wsopt/account" Options Indexes FollowSymLinks MultiVIEws IncludesNoExec AddOutputFilter Includes Html AllowOverride None Order allow,deny Allow from all JkMount /account/* ajp13JkMount /account/*.JSP ajp13 AllowOverride None deny from all iii.ajp13工作的配置文件workers.properties描述如下:workers.tomcat.home=%tomcat_home%workers.java.home=%java_home%ps=\worker.list=ajp13worker.ajp13.port=8009worker.ajp13.host=localhostworker.ajp13.type=ajp13worker.ajp13.1bfactor=1參考:# workers.properties -## This file provides jk derived plugins with the needed information to# connect to the different tomcat workers. Note that the distributed# version of this file requires modification before it is usable by a# plugin.## As a general note, the characters $( and ) are used internally to define# Macros. Do not use them in your own configuration!!!## Whenever you see a set of lines such as:# x=value# y=$(x) omething## the final value for y will be value omething## Normaly all you will need to do is un-comment and modify the first three# properties, i.e. workers.tomcat_home, workers.java_home and ps.# Most of the configuration is derived from these.## When you are done updating workers.tomcat_home, workers.java_home and ps# you should have 3 workers configured:## - An ajp12 worker that connects to localhost:8007# - An ajp13 worker that connects to localhost:8009# - A jni inprocess worker.# - A load balancer worker## However by default the plugins will only use the ajp12 worker. To have# the plugins use other workers you should modify the worker.list property.## # OPTIONS ( very important for jni mode ) ## workers.tomcat_home should point to the location where you# installed tomcat. This is where you have your conf, webaPPS and lib# directorIEs.#workers.tomcat_home=C:/apache Tomcat 4.0 ## workers.java_home should point to your Java installation. Normally# you should have a bin and lib directorIEs beneath it.#workers.java_home=c:/J2SE ## You should configure your environment slash... ps=\ on NT and / on UNIX# and maybe something different elsewhere.#ps=\ ##------ ADVANCED MODE ------------------------------------------------#---------------------------------------------------------------------# ##------ DEFAULT worket list ------------------------------------------#---------------------------------------------------------------------### The workers that your plugins should create and work with## Add 'inprocess' if you want JNI connector worker.list=ajp13,ajp12# , inprocess ##------ DEFAULT ajp12 WORKER DEFINITION ------------------------------#---------------------------------------------------------------------# ## Defining a worker named ajp12 and of type ajp12# Note that the name and the type do not have to match.#worker.ajp12.port=8007worker.ajp12.host=localhostworker.ajp12.type=ajp12## Specifies the load balance factor when used with# a load balancing worker.# Note:# ----> lbfactor must be > 0# ----> Low lbfactor means less work done by the worker.worker.ajp12.lbfactor=1 ##------ DEFAULT ajp13 WORKER DEFINITION ------------------------------#---------------------------------------------------------------------# ## Defining a worker named ajp13 and of type ajp13# Note that the name and the type do not have to match.#worker.ajp13.port=8009worker.ajp13.host=localhostworker.ajp13.type=ajp13## Specifies the load balance factor when used with# a load balancing worker.# Note:# ----> lbfactor must be > 0# ----> Low lbfactor means less work done by the worker.worker.ajp13.lbfactor=1 ## Specify the size of the open connection cache.#worker.ajp13.cachesize ##------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------#---------------------------------------------------------------------# ## The loadbalancer (type lb) workers perform wighted round-robin# load balancing with sticky sessions.# Note:# ----> If a worker dies, the load balancer will check its state# once in a while. Until then all work is redirected to peer# workers.worker.loadbalancer.type=lbworker.loadbalancer.balanced_workers=ajp13,ajp12 ##------ DEFAULT JNI WORKER DEFINITION---------------------------------#---------------------------------------------------------------------# ## Defining a worker named inprocess and of type jni# Note that the name and the type do not have to match.#worker.inprocess.type=jni ##------ CLASSPATH DEFINITION -----------------------------------------#---------------------------------------------------------------------# ## Additional class path components.#worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar ## Setting the command line for tomcat. # Note: The cmd_line string may not contain spaces.#worker.inprocess.cmd_line=start # Not needed, but can be customized.#worker.inprocess.cmd_line=-config#worker.inprocess.cmd_line=$(workers.tomcat_home)$(ps)conf$(ps)server.xml#worker.inprocess.cmd_line=-home#worker.inprocess.cmd_line=$(workers.tomcat_home) ## The JVM that we are about to use## This is for Java2## Windowsworker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)client$(ps)jvm.dll# IBM JDK1.3 #worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)libjvm.so# Unix - Sun VM or blackdown#worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)client$(ps)libjvm.so ## And this is for jdk1.1.X##worker.inprocess.jvm_lib=$(workers.java_home)$(ps)bin$(ps)javai.dll ## Setting the place for the stdout and stderr of tomcat#worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdoutworker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr ## Setting the tomcat.home Java property##worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home) ## Java system propertIEs## worker.inprocess.sysprops=java.compiler=NONE# worker.inprocess.sysprops=myprop=mypropvalue ## Additional path components.## worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin# iv.在tomcat的主配置文件server.XML中加入以下內容:在中加入ajp13服務的請求監聽器: 在中加入ajp13主機的監聽器: v. 另外要檢查tomcat是否啟動了ajp13服務,如果沒有啟動,要在tomcat主配置文件中加入啟動該服務的描述: iii.注意:apache的要與tomcat的一一對應。3. 數據存儲環境數據存儲環境采用MySQL, 該數據庫具有速度快,sql標准等特點。可以采用兩種方式與之建立連接關系,即odbc和jdbc,前者是比較成熟的,而jdbc卻會導致漢字亂碼,原因是該數據庫沒有默認的字符集,僅在應用服務器上建立odbc數據源是可以接受的。4. 該平台所需的文件列表如下:a) mod_jk.dllb) MyODBC-3.51.04.exec) j2sdk-1_4_1-Windows-i586.exed) apache_2.0.40-win32-x86-no_ssl.exee) mysql-max-3.23.52-win.zipf) mysqlgui-win32-static-1.7.5-2.zipg) MySQL-connector-Java-2.0.14.ziph) JBossEntWizard3x_v2.2.1_JBuilder7.zipi) jboss-3.0.0_tomcat-4.0.3.zip二.平台應用程序部署1. Web應用程序部署a) Web應用程序打包(.war)後放入%jboss_home%/server/default/deploy下,系統將能夠自動部署,虛擬目錄名就是包名;b) 把打包文件解壓到一特定文件夾,在阿帕奇的主配置文件中加入一個新的、別名與jboss的虛擬目錄相同的虛擬目錄(真實目錄指向解壓後的特定文件夾)2. 企業應用程序部署a) 在JBuilder中,同一個項目下建立ejb應用程序;b) 配置ejb的jndi名;c) 配置web應用程序的ejb屬性,即ejb-ref-name, ejb-ref-link, ejb-home, ejb-remote;d) 新建一企業應用程序(.ear),並編譯之;e) 部署企業應用程序(.ear)。f) 這時,web應用程序的上下文為根。三.實例程序:JBossTest, 一個登錄的演示。
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved