站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题新兴开放源码J2EE应用平台

新兴开放源码J2EE应用平台

摘要: 新兴开放源码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.conf Listen *:80(在所有地址上监听80端口) ServerName Apache DirectoryIndex 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 +ForwardURICompat JkWorkersFile D:/Apache2/Apache2/conf/JK/workers.properties JkLogFile D:/Apache2/Apache2/conf/JK//mod_jk.log JkMount /*.jsp ajp13 JkMount /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/* ajp13 JkMount /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/* ajp13 JkMount /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=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13 worker.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)\something # # the final value for y will be value\something # # 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=8007 worker.ajp12.host=localhost worker.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=8009 worker.ajp13.host=localhost worker.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=lb worker.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 # # Windows worker.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.stdout worker.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.dll b) MyODBC-3.51.04.exe c) j2sdk-1_4_1-windows-i586.exe d) apache_2.0.40-win32-x86-no_ssl.exe e) mysql-max-3.23.52-win.zip f) mysqlgui-win32-static-1.7.5-2.zip g) mysql-connector-java-2.0.14.zip h) JBossEntWizard3x_v2.2.1_JBuilder7.zip i) 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, 一个登录的演示。