注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

0与1构筑世界,程序员创造时代

软件架构设计 Java编程

 
 
 

日志

 
 

Glassfish 与 Apache 集成  

2008-11-18 16:40:46|  分类: GlassFish |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
  文章声明

  
作者:
傲风(aofengblog@163.com)       编写时间:2008年11月18日

网址:http://aofengblog.blog.163.com



预备

资源

版本

下载地址

操作系统

SUSE LINUX Enterprise Server 9

 

Apache

1.3.33 (Unix)

http://archive.apache.org/dist/httpd/apache_1.3.33.tar.gz

mod_jk

mod_jk.so-ap1.3.27-rh72

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/v1.2.4/bin/linux/mod_jk.so-ap1.3.27-rh72

Glassfish

v2ur2-b04-linux-ml

http://java.net/download/javaee5/v2ur2/promoted/Linux/glassfish-installer-v2ur2-b04-linux-ml.jar

Tomcat

5.5.16

http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.16/bin/apache-tomcat-5.5.16.tar.gz

 

commons-logging-1.1.jar

http://apache.mirror.phpchina.com/commons/logging/binaries/commons-logging-1.1.tar.gz

 

commons-modeler-2.0.1.jar

http://apache.mirror.phpchina.com/commons/modeler/binaries/commons-modeler-2.0.1.tar.gz




安装
1、编译安装Apache。

在编译安装Apache时,在安装三步曲的第一步需要做一些改动,将

./configure --prefix=/nfs10/nieyong/apache_1.3.33

改成

./configure --prefix=/nfs10/nieyong/apache_1.3.33 --enable-module=so

 

否则在启动Apache的时候将提示如下的错误信息:

Invalid command 'LoadModule' with the Apache Server

 

Glass 与 Apache 集成 - 傲风 - 傲风的博客如果还想支持一些内含的模块,如:rewriteproxy,只需要加上如下的参数:

--enable-module=rewrite --enable-shared=rewrite --enable-module=proxy --enable-shared=proxy

2、配置Apache。
1)修改配置文件httpd.conf。

修改%APACHE_HOME/conf/httpd.conf,添加如下配置:

# Load mod_jk module

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/worker.properties


JkLogFile logs/mod_jk.log

# log level:debug info error emerg

JkLogLevel error

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

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

JkRequestLogFormat "%w %V %T"


JkMount /*.jsp worker1

JkMount /aimc6/* worker1



2)修改配置文件work.properties
修改%APACHE_HOME/conf/work.properties文件(如果不存,则建立此文件),添加如下的配置信息:
# Define 1 real worker using ajp13
worker.list=worker1

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300


3、配置Glassfish
说明:
  • %TOMCAT_HOME 表示Tomcat的安装目录。
  • %GLASSFISH_HOME表示Glassfish的安装目录。

1)添加类库
复制%TOMCAT_HOME/server/lib/目录下的tomcat-ajp.jar至 %GLASSFISH_HOME/lib目录。
复制commons-logging-1.1.jar 和 commons-modeler-2.0.1.jar 至%GLASSFISH_HOME/lib目录。

2)添加参数
添加jvm 参数 -Dcom.sun.enterprise.web.connector.enableJK=8009。
  • 在命令行里。
$GLASSFISH_HOME/bin/asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009
  • 在glassfish的控制台里。
Application Server -> JVM 设置 ->JVM 选项 里添加。

Glass 与 Apache 集成 - 傲风 - 傲风的博客提示:上述两种方式都必须先启动Glassfish。


完成所有这些操作后,重启Apache和Glassfish即可。


验证
说明:Apache的监听端口为8989,Glassfish的监听端口为8888。

将文件 hello.war 部署至Glassfish,在浏览器中分别输入相应的地址,显示结果如下:

1、直接访问Glassfish。

Glass 与 Apache 集成 - 傲风 - 傲风的博客


2、访问Apache

Glass 与 Apache 集成 - 傲风 - 傲风的博客


故障排除总结
1、安装配置Apache。
1)错误信息1:
Invalid command 'LoadModule' with the Apache Server

解决问题提示:
I just changed the configuration of my Web server when I encountered the problem in the title. Obviously, when I recompiled the server from the source optained from http://www.apache.org/ and http://www.apache-ssl.org/, I somehow managed to make it "forget" the LoadModule command. But how?

A quick search on the Web turned up a few dozen documents, but they were either questions posted to mailing lists or newsgroups without answers, or answers that were meaningless. Finally, I found the answer at the Web site of Halcyon Software.

The problem, it turns out, is that prior to recompiling the Apache server, you need to use the --enable-module=so option when running the configuration script for the Apache source. So to recompile the Apache server, you need to do the following:

    cd /usr/src/apache
    ./configure --prefix=/var/lib/apache --enable-module=so
    make clean
    make install

Needless to say, you may require additional options when running configure, options that match your operating system and desired server configuration settings. On some systems, it may also be necessary to add --enable-rule=SHARED_CORE.

原因:是编译Apache的时候没有设置--enable-module=so,因为默认是so=no。


2)错误信息2:
linux apache undefined symbol: ap_ctx_get

解决问题提示:
If you don't need this module, comment out the respective line from apache's conf. If you do need it, I guess you have to find another binary version that is compatible with your apache, or compile it from source.

原因:是mod_jk.so的版本和当前Apache不匹配,下载一个匹配的mod_jk.so即可。


2、安装配置Glassfish。
1)用5.5.26下的tomcat-ajp.jar导致apache与glassfish不能正常通信。
  • glassfish的报错信息如下:
[#|2008-11-18T15:58:03.684+0800|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=19;_ThreadName=TP-Processor8;_RequestID=fb1765f7-6031-48fa-a836-120c0f80a9b3;|
java.lang.NoSuchMethodError: org.apache.coyote.Response.getContentLengthLong()J
        at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:303)
        at org.apache.jk.core.MsgContext.action(MsgContext.java:267)
        at org.apache.coyote.Response.action(Response.java:221)
        at org.apache.coyote.Response.sendHeaders(Response.java:416)
        at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:355)
        at org.apache.coyote.tomcat5.OutputBuffer.close(OutputBuffer.java:321)
        at org.apache.coyote.tomcat5.CoyoteResponse.finishResponse(CoyoteResponse.java:578)
        at org.apache.coyote.tomcat5.CoyoteAdapter.afterService(CoyoteAdapter.java:318)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:301)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
        at java.lang.Thread.run(Thread.java:619)
|#]

  • apache 的错误信息如下:
[Tue Nov 18 15:58:03 2008]  [jk_worker.c (132)]: Into wc_get_worker_for_name worker1
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (1208)]: Into jk_endpoint_t::service
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (295)]: Into ajp_marshal_into_msgb
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (463)]: ajp_marshal_into_msgb - Done
[Tue Nov 18 15:58:03 2008]  [jk_connect.c (174)]: jk_open_socket, after connect ret = 0
[Tue Nov 18 15:58:03 2008]  [jk_connect.c (183)]: jk_open_socket, set TCP_NODELAY to on
[Tue Nov 18 15:58:03 2008]  [jk_connect.c (192)]: jk_open_socket, set SO_KEEPALIVE to on
[Tue Nov 18 15:58:03 2008]  [jk_connect.c (200)]: jk_open_socket, return, sd = 8
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (661)]: In jk_endpoint_t::ajp_connect_to_endpoint, connected sd = 8
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (693)]: sending to ajp13 #576
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (966)]: ajp_send_request 2: request body to send 0 - request body to resend 0
[Tue Nov 18 15:58:03 2008]  [jk_ajp_common.c (738)]: ERROR: can't receive the response message from tomcat, network problems or tomc
at is down. err=-1

解决方法:用5.5.16下的tomcat-ajp.jar就可以了。


参考资料

1http://weblogs.java.net/blog/jfarcand/archive/2006/03/running_glassfi_1.html

2http://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html

3、http://tomcat.apache.org/connectors-doc/reference/workers.html

4、http://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html

<正文结束>
  评论这张
 
阅读(1579)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017