Apache Geronimo应用服务器是在应用服务器许多方面都使用了许多领先开源项目的一个fully certified Java EE 5 runtime。事实上,Geronimo更大程度上是用来创建一个定制的只包含您需要的组件的应用程序分布式服务器的工具包。
默认的,有三个取决于您的需求的不同发行版的Geronimo:
1 Java EE Certified--一个完全认证的Java EE 5分布,使用两个主要的开源web容器:
■Geronimo with Jetty 7
■Geronimo with Tomcat6
2 Little-G--一个提供一个web容器和Geronimo模块的一个子集的distribution,子集包括:
■Geronimo with Jetty 7
■Geronimo with Tomcat6
3 Micro-G--一个允许你from the ground up建立你自己定制的应用服务器。你通过Geronimo deployer决定包含哪些组件。
Geronimo 提供了大量宽广的选择性,但是我们将为本章节使用Little-G 2.2 with Tomcat 6因为它还没有安装ActiveMQ(而Java EE certified runtime确实包括ActiveMQ)。所以从Geronimo下载页面(http://mng.bz/DaoR)下载Little-G 2.2 with Tomcat 6并将它解压到你的电脑上。
在本章节中,我们将为Geronimo部署ActiveMQ插件并使用Geronimo web console来注册ActiveMQ JMS 资源到Geronimo JNDI provider。在完成了这些步骤以后,Geronimo 示例应用(jms-webapp-geronimo项目)能被部署。 8.4.1安装Geronimo并在Geronimo中配置ActiveMQ插件
在archive展开之后,启动到建立的目录并启动Geronimo,如下所示。 Listing 8.10 Start up Geronimo
$ cd ./geronimo-tomcat6-minimal-2.2
$ ./bin/start-server
Launching Geronimo Server...
Booting Geronimo Kernel (in Java 1.6.0_15)...
...
Startup completed in 6.431s seconds
Listening on Ports:
1099 0.0.0.0 RMI Naming
8009 0.0.0.0 Tomcat Connector AJP TomcatAJPConnector
8080 0.0.0.0 Tomcat Connector HTTP BIO TomcatWebConnector
8443 0.0.0.0 Tomcat Connector HTTPS BIO TomcatWebSSLConnector
9999 0.0.0.0 JMX Remoting Connector
Geronimo Server started in 0:00:08.787
Started Application Modules:
WAR: org.apache.geronimo.configs/remote-deploy-tomcat/2.2/car
Web Applications:
/remote-deploy
Geronimo Application Server started
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
<environment>
<moduleId>
<groupId>org.apache.activemq.book</groupId>
<artifactId>jms-webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</moduleId>
<dependencies>
<!-- Depend upon the custom JMS resources group -->
<dependency>
<groupId>console.jms</groupId>
<artifactId>FooGroup</artifactId>
<version>1.0</version>
<type>car</type>
</dependency>
</dependencies>
<!-- Filter out the following items from the parent classloader -->
<hidden-classes>
<filter>org.springframework.</filter>
<filter>META-INF/spring</filter>
</hidden-classes>
</environment>
<context-root>/jms-webapp</context-root>
</web-app>
geronimo-web.xml文件对Geronimo是特殊的。它为Geronimo提供了一些instructions。<moduleId>元素被用来识别发布到Geronimo的WAR文件。<dependency>元素告诉Geronimo它需要在该章节先前建立的JMS资源组。若没有作为资源组一部分的连接工厂和destination,示例应用将不能正确地运行。<hidden-classes>元素告诉Geronimo不要在列出的packages中expose任何classes,因为它们已经存在于exposed到web应用的应用server的classloader中。This is something that should happen automatically and will probably be corrected in the near term based on a JIRA issue that was created to point this out.一旦这被fixed了,<hidden-classes>元素将不再需要来隐藏activemq-broker Geronimo插件的Spring classes。
第二步 取代在web.xml文件中使用<resource-ref>元素定义JMS queue,Geronimo需要使用<message-destination-ref>。<message-destination-ref>元素为web.xml定义在DTD。下面的列表显示了jms-webapp-geronimo/src/main/webapp/WEB-INF/web.xml文件中必要的修改。 Listing 8.12 Change to the web.xml file for Geronimo