Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

迁移指南

Red Hat JBoss Enterprise Application Platform 7.0

For Use with Red Hat JBoss Enterprise Application Platform 7.0

Red Hat Customer Content Services

摘要

本指南提供了关于如何从以前的 Red Hat JBoss Enterprise Application Platform 迁移应用程序的信息。

第 1 章 介绍

1.1. 关于 Red Hat JBoss EAP 7

Red Hat JBoss Enterprise Application Platform 7(JBoss EAP 7)是一个构建在开放标准上并和 Java EE 7 规格兼容的中间件平台。它集成了 WildFly Application Server 10 和高可用性的群集、消息系统以及其他技术。

JBoss EAP 使用了模块化结构,允许在有需要时才启用服务,从而提高了启动速度。

管理控制台和管理命令行界面(Command-line Interface,CLI)使您不需要再编辑 XML 配置文件并增添了使用脚本和自动化任务的能力。

JBoss EAP 提供了两种操作模式:独立服务器和受管域。独立服务器操作模式代表 JBoss EAP 作为单个服务器实例运行。受管域模式则允许通过单个控制点管理多个 JBoss EAP 实例。

此外,JBoss EAP 包含了 API 和开放框架以用于快速开发安全和可扩充的 Java EE 应用程序。

1.2. 关于迁移指南

The purpose of this guide is to document the changes that are required to successfully run and deploy Red Hat JBoss Enterprise Application Platform 6 applications on Red Hat JBoss Enterprise Application Platform 7. It provides information about the new features available in this release, the deprecated and unsupported features, and any application and server configuration updates that might be required to prevent changes in application behavior.

It also provides information about tools that can help with the migration, such as Windup, which simplifies migration of Java applications, and the JBoss Server Migration Tool, which updates the server configuration.

Once the application is successfully deployed and running, plans can be made to upgrade individual components to use the new functions and features of JBoss EAP 7.

If you plan to migrate your JBoss EAP 5 applications directly to JBoss EAP 7, see Migrating from Older Releases of JBoss EAP.

1.3. 关于迁移和升级

主要的升级

A major upgrade or migration is required when an application is moved from one major release to another, for example, from JBoss EAP 6 to JBoss EAP 7. This is the type of migration addressed in this guide. If an application follows the Java EE specifications, does not access deprecated APIs, and does not contain proprietary code, it might be possible to run the application in JBoss EAP 7 without any application code changes. However, server configuration has changed in JBoss EAP 7 and any server configuration settings require migration.

次要的升级

JBoss EAP periodically provides point releases, which are minor updates that include bug fixes, security fixes, and new features. The JBoss EAP Patching and Upgrading Guide describes how to upgrade from one point release to another, for example from JBoss EAP 7.0 to JBoss EAP 7.1.

累积补丁

JBoss EAP also periodically provides cumulative patches that contain bug and security fixes. Cumulative patches increment the release by the last digit, for example from 7.0.0 to 7.0.1. Patch installation is covered in detail in the JBoss EAP Patching and Upgrading Guide.

1.4. 关于本文档里 EAP_HOME 的使用

在本文档里,我们使用变量 EAP_HOME 来表示 JBoss EAP 的安装位置。请用实际的安装位置替换这个变量。

  • 如果您用 ZIP 方式安装 JBoss EAP,安装目录就是您解压 ZIP 归档文件的目录 jboss-eap-7.0
  • 如果您用 RPM 方式安装 JBoss EAP,安装目录是 /opt/rh/eap7/root/usr/share/wildfly/
  • 如果您使用安装程序来安装 JBoss EAP,默认的 EAP_HOME 路径是 ${user.home}/EAP-7.0.0

    • 对于 Red Hat Enterprise Linux, Solaris 和 HP-UX:/home/USER_NAME/EAP-7.0.0/
    • 对于 Microsoft Windows:C:\Users\USER_NAME\EAP-7.0.0\
  • 如果您使用 JBoss Developer Studio 安装程序来安装和配置 JBoss EAP 服务器,默认的 EAP_HOME 路径是 ${user.home}/jbdevstudio/runtimes/jboss-eap

    • 对于 Red Hat Enterprise Linux:/home/USER_NAME/jbdevstudio/runtimes/jboss-eap/
    • 对于 Microsoft Windows:C:\Users\USER_NAME\jbdevstudio\runtimes\jboss-eapC:\Documents and Settings\USER_NAME\jbdevstudio\runtimes\jboss-eap\
注意

EAP_HOME 不是一个环境变量。脚本里使用的环境变量是 JBOSS_HOME

第 2 章 准备迁移

2.1. 准备工作概述

In JBoss EAP 7, an effort was made to provide backward compatibility for JBoss EAP 6 applications. However, if your application uses features that were deprecated or functionality that was removed from JBoss EAP 7, you might need to make changes to your application code.

In addition, a number of things have changed in this release that might impact deployment of JBoss EAP 7 applications. It is recommended that you do some research and planning before you attempt to migrate your application.

一旦您了解了这些功能的变化、开发内容及可以协助您迁移的工具,您就可以开始评估应用程序和服务器配置来确定在 JBoss EAP 7 里运行所需的修改。

2.2. 查看 Java EE 7 的功能

Java EE7 包含了许多使得在私有和公共云上开发和运行功能丰富的应用程序更容易的改进。它合并了新的功能及最新的标准,如 HTML5、WebSocket、JSON、Batch 和 Concurrency Utilities。更新还包含了 JPA 2.1、JAX-RS 2.0、Servlet 3.1、Expression Language 3.0、JMS 2.0. JSF 2.2、EJB 3.2、CDI 1.2 和 Bean Validation 1.1。

您可以在 Oracle 的网站找到关于 Java EE 的更多信息,其中包括教程:Java EE at a Glance

2.3. 查看 JBoss EAP 7 里的新功能

与之前的版本相比,JBoss EAP 7 包含了显著的升级和改进。

Java EE 7
JBoss EAP 7 是一个已认证的 Java EE 7 Full 和 Web 配置规格的实现。它也包括对最新的 CDI 1.2 和 Web Sockets 1.1 的支持。
Undertow
Undertow 是 JBoss EAP 7 里包含的新的轻量级的、高性能的 Web 服务器。它是用 Java 编写的,专门为高吞吐量和扩充性而设计的。它支持最新的 Web 技术,如新的 HTTP/2 标准。
Apache ActiveMQ Artemis
Apache ActiveMQ Artemis 是 JBoss EAP 7 的新的内置消息供应商。基于 HornetQ 代码的捐献,这个 Apache 子项目提供了基于非阻塞式架构的突出性能。
IronJacamar 1.2
最新的 IronJacamar 提供了对 JCA 和数据源的稳定的、功能丰富的支持。
JBossWS 5
The fifth generation of JBossWS is a major leap forward, bringing new features and performance improvements to JBoss EAP 7 web services.
RESTEasy 3
JBoss EAP 7 包含了最新的 RESTEasy。通过提供大量的有用扩展,如 JSON Web Encryption、Jackson、YAML、JSON-P 和 Jettison,它超出了标准的 Java EE REST API(JAX-RS 2.0)。
OpenJDK ORB
JBoss EAP 7 用 OpenJDK ORB 的一个下游分支替换了 JacORB IIOP,从而实现了与 JVM ORB 和 Java EE RI 的更好的互用性。
功能丰富的群集
JBoss EAP 7 很大程度地重构了对群集的支持,它包含了应用程序可以访问的几个公用 API。
端口的减少
利用 HTTP 升级,JBoss EAP 7 对几乎所有的协议都使用两个端口的多路复用:管理端口(9990)和应用程序端口(8080):
日志的增强
管理 API 现在支持列出和查看服务器上的可用日志文件,甚至定义默认模式格式器之外的自定义格式器。部署的日志设置也大大地增强了。

For a complete list of new features, see New Features and Enhancements in the JBoss EAP 7 Release Notes.

2.4. 查看已舍弃和不被支持的功能的列表

Before you migrate your application, be aware that some features that were available in previous releases of JBoss EAP might be deprecated or no longer supported.

由于维护成本高、社区不感兴趣以及更好的替代方案的出现,我们取消了对一些技术的支持。下面是对不再支持的功能的概述。

EJB Entity Bean
我们不再支持 EJB Entity Bean。如果您的应用程序使用了 EJB Entity Bean,您应该迁移至提供灵活的 API 及更好性能的 JPA。
JAX-RPC
因为 JAX-WS 提供了更正确和完整的解决方案,根据 JAX-RPC 编写的代码应该迁移至 JAX-WS。
JSR-88
Java EE 应用程序部署 API 规格(JSR-88)定义了启用多个提供者的工具在任何 Java EE 平台产品上配置和部署应用程序的合约。您必须使用另外一个 JBoss EAP 支持的选项进行应用程序部署,如管理控制台、管理 CLI、部署扫描器或 Maven。
通用的 JMS 资源适配器
JBoss EAP 7 不再支持配置通用的 JMS 资源适配器来连接 JMS 供应商。

For a comprehensive list of deprecated and unsupported features, see Unsupported and Deprecated Functionality in the JBoss EAP 7 Release Notes.

2.5. 浏览《JBoss EAP 7 起步指南》的内容

Be sure to review the JBoss EAP Getting Started Guide. It contains the following important information:

  • 如何下载和安装 JBoss EAP 7
  • 如何下载和安装 Red Hat JBoss Developer Studio
  • 如何为您的开发环境配置 Maven,管理项目依赖关系和配置项目使用 JBoss EAP Bill of Material (BOM) 购件。
  • 如何下载和运行产品附带的 Quickstart 例程。

2.6. 迁移分析和规划

Each application and server configuration is unique and you must thoroughly understand the components and architecture of the existing application and server platform before you attempt the migration. Your migration plan should include a detailed roadmap for testing and roll out to production that takes into account the following information.

确定负责迁移的人员
确定利益关系人、项目经理、开发人员、管理员和其他负责迁移的人员。
复查应用服务器平台配置和硬件

检查现有的应用服务器和平台配置来确定 JBoss EAP 7 里的功能变动如何影响它们。这种检查应该包含下列项目。

  • 操作系统和版本
  • 应用程序使用的数据库
  • Web 服务器
  • 安全架构
  • 处理器的数量和类型
  • 内存数量
  • 物理磁盘空间的大小
  • 数据库或消息数据的迁移
  • Other components that might be impacted by the migration
复查当前的产品环境

您应该计划为测试和模拟迁移过程创建和产品环境尽可能相同的环境。

  • Take into account any clustering configurations. See Upgrading a Cluster in the JBoss EAP Patching and Upgrading Guide for more information about how to migrate clusters.
  • 如果您目前运行的是大型的受管域,请考虑渐进式迁移方法。
  • 确定您是否需要迁移任何数据库或消息数据。
检查和了解现有的应用程序

彻底检查现有的 JBoss EAP 6 应用程序。充分熟悉它的架构、功能、特点和组件,其中包括:

  • JVM 版本
  • 与其他 Red Hat 应用服务器中间件组件的集成
  • 与第三方私有软件的集成
  • 需要替换的已舍弃的功能
  • 应用程序配置,包括部署描述符文件、JNDI、持久化、JDBC 配置和池、JMS 主题和队列和日志。

确认在迁移至 JBoss EAP 7 的过程中需要修改的任何代码或配置的不兼容性。

创建详细的测试计划
  • 这个计划应该包括回归测试和验收标准要求。
  • 它也应该包含性能测试。
  • 在产品环境试运行之前,设置和产品环境尽量相同的模拟环境以测试迁移过程。
  • 请确保创建了备份和回滚计划!
查看迁移过程中的可用资源
  • 评估开发团队的技能并规划培训或其他的咨询协助。
  • 请意识到在迁移过程中进行模拟和测试可能要求额外的硬件和其他资源。
  • 确定是否需要任何正式的培训。如果是,将其添加至时间表里。
执行计划
收集必要的资源并实施迁移计划。
重要

在修改应用程序之前,请确保已进行了备份。

2.7. 备份重要数据并复查服务器状态。

在您迁移应用程序前,您应该意识到下列一些潜在的问题。

  • The migration might remove temporary folders. Any deployments stored in the data/content/ directory must be backed up prior to the migration and restored after it completes. Otherwise, the server will fail to start due to the missing content.
  • 在迁移之前,处理任何打开的事务并删除 data/tx-object-store/ 事务目录。
  • 您必须检查 data/timer-service-data 里的持久性定时器数据来确定是否兼容。在迁移之前,复查该目录里的 deployment-* 文件以确定哪些定时器仍在使用。

在您开始前请确保也备份当前服务器配置和应用程序。

2.8. 迁移和 RPM 安装

重要

单个 Red Hat Enterprise Linux 服务器上不支持多个以 RPM 方式安装的 JBoss EAP 实例。因此,我们推荐您在迁移至 JBoss EAP 7 时将 JBoss EAP 安装迁移到新的主机。

在将 JBoss EAP RPM 安装从 JBoss EAP 6 迁移至 JBoss EAP 7 时,请确保 JBoss EAP 7 安装在没有现存 JBoss EAP RPM 安装的主机上。

To install JBoss EAP 7 using RPMs, see the JBoss EAP Installation Guide.

The migration advice in this guide also applies to migrating RPM installations of JBoss EAP, but you might need to alter some steps (such as how to start JBoss EAP) to suit an RPM installation compared to a ZIP or installer installation.

2.9. 迁移作为服务运行的 JBoss EAP

If you run JBoss EAP 6 as a service, be sure to review Configuring JBoss EAP to Run as a Service in the JBoss EAP Installation Guide for updated configuration instructions for JBoss EAP 7.

第 3 章 可协助迁移的工具

3.1. 使用 Windup 来分析要迁移的应用程序

Windup 是 Red Hat JBoss Migration Toolkit 的一部分,它是一个可扩展和定制的基于规则的工具,它有助于简化 Java 应用程序的迁移。它分析要迁移的应用程序使用的 API、技术和架构,并提供详细的迁移报告。这些报告提供了下列信息。

  • 所需的迁移修改的详细解释
  • 报告的修改是强制的还是可选的
  • 报告的修改是复杂的还是不重要的
  • 到需要迁移修改的代码的链接
  • 关于如何进行所需的修改的信息的提示和链接
  • 对发现的每个迁移问题的工作级别以及迁移应用程序所需的总共工作的估计

在迁移至 JBoss EAP 7 之前,您可以用 Windup 来分析 JBoss EAP 6 应用程序的代码和架构。Windup 在 XML 描述符里设置从 JBoss EAP 6 迁移到 JBoss EAP 7 的规则以及当迁移至 JBoss EAP 7 时需要替换配置的专有应用程序代码和参数。

For more information about how to use Windup to analyze your JBoss EAP 6 applications, see the Windup User Guide.

3.2. 使用 JBoss 服务器迁移工具来迁移服务器配置

目前正开发的 JBoss Server Migration Tool 将是更新您的配置以包含 JBoss EAP 7 里新的功能和设置且保持现有配置的首选方法。

JBoss Server Migration Tool 读取现有的 JBoss EAP 6 服务器配置文件并添加配置至新的子系统、用新的功能更新现有的子系统配置并删除过时的子系统配置。

JBoss Server Migration Tool 的最新预发布版本可以在 https://github.com/wildfly/wildfly-server-migration/releases 下载。这个版本支持从 JBoss EAP 6.4 独立服务器迁移至 JBoss EAP 7.0。关于运行这个工具的常用信息,请参考 《JBoss Server Migration Tool 用户指南》

注意

JBoss Server Migration Tool 的预发布版本仍不被支持。

第 4 章 服务器配置的修改

4.1. 服务器配置迁移选项

要将你的服务器配置从 JBoss EAP 6 到 JBoss EAP 7,您可以使用 JBoss Server Migration Tool 或用管理 CLI 的 migrate 操作进行手动迁移。

JBoss Server Migration Tool

目前正开发的 JBoss Server Migration Tool 将是更新您的配置以包含 JBoss EAP 7 里新的功能和设置且保持现有配置的首选方法。

管理 CLI 的 migrate 操作

您可以使用管理 CLI 的 migrate 操作来更新 JBoss EAP 6 服务器配置文件里的 jacorbmessagingweb 子系统,允许它们运行在新版本上,但请注意其结果并非完整的 JBoss EAP 7 配置。例如:

  • 这个操作不会更新原来的 remote 协议和端口设置为 JBoss EAP 7 现在使用的新的 http-remoting 协议和端口设置。
  • 配置不包括新的 Java EAP 子系统或功能,如群集单点登录部署、优雅关闭等。
  • 配置不包括新的 Java EE 7 功能,如批处理。
  • The migrate operation does not migrate the ejb3 subsystem configuration. For information about possible EJB migration issues, see EJB Server Configuration Changes.

关于使用 migrate 操作来迁移服务器配置的更多信息,请参考管理 CLI 的 migration 操作

4.2. 管理 CLI 的迁移操作

您可以使用管理 CLI 来更新您的 JBoss EAP 6 服务器配置文件以运行在 JBoss EAP 7 上。管理 CLI 提供了 migrate 操作来自动更新之前版本的 jacorbmessagingweb 子系统到新配置里。在进行迁移前,您也可以对 jacorbmessagingweb 子系统执行 describe-migration 操作来复核配置的改动。目前没有 cmpjaxrthreads 的替代选项,您必须从服务器配置里删除它们。

重要

关于 migrate 操作的限制,请参考服务器配置迁移选项。目前正开发的 JBoss Server Migration Tool 将是更新您的配置以包含 JBoss EAP 7 里新的功能和设置且保持现有配置的首选方法。

表 4.1. 子系统迁移和管理 CLI 操作

JBoss EAP 6 子系统JBoss EAP 7 子系统管理 CLI 操作

cmp

no replacement

remove

jacorb

iiop-openjdk

migrate

jaxr

no replacement

remove

messaging

messaging-activemq

migrate

threads

no replacement

remove

web

undertow

migrate

Start the Server and the Management CLI

按照下列步骤更新您的 JBoss EAP 6 服务器配置使其运行在 JBoss EAP 7 里。

  1. 在开始之前,请参考备份重要数据并复查服务器状态。它包含关于确保服务器处于良好状态且已备份合适的文件的重要信息。
  2. 用 JBoss EAP 6 服务器配置启动 JBoss EAP 7 服务器。

    1. 备份 JBoss EAP 7 的服务器配置文件。
    2. 将配置文件从之前版本里复制到 JBoss EAP 7 目录里。

      $ cp EAP6_HOME/standalone/configuration/standalone-full.xml EAP7_HOME/standalone/configuration
    3. 进入 JBoss EAP 7 的安装目录并用 --admin-only 参数启动服务器。

      $ bin/standalone.sh -c standalone-full.xml --admin-only
      注意

      在您启动服务器时,您将在服务器日志里看到下列 org.jboss.as.controller.management-operation 错误。这是预料中的错误,表示旧的子系统配置必须删除并迁移至 JBoss EAP 7。

      • WFLYCTL0402: Subsystems [cmp] provided by legacy extension 'org.jboss.as.cmp' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [jacorb] provided by legacy extension 'org.jboss.as.jacorb' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [jaxr] provided by legacy extension 'org.jboss.as.jaxr' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [messaging] provided by legacy extension 'org.jboss.as.messaging' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [threads] provided by legacy extension 'org.jboss.as.threads' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [web] provided by legacy extension 'org.jboss.as.web' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
  3. 打开新的终端窗口,进入 JBoss EAP 7 安装目录,然后用 --controller=remote://localhost:9999 参数启动管理 CLI。

    $ bin/jboss-cli.sh --connect --controller=remote://localhost:9999

Migrate the JacORB, Messaging, and Web Subsystems

  1. 要在执行迁移前复核对子系统做的配置修改,请执行 describe-migration 操作。

    describe-migration 操作使用下列语法。

    /subsystem=SUBSYSTEM_NAME:describe-migration

    下面的例子描述了在迁移到 JBoss ESP 7 时对 JBoss EAP 6.4 standalone-full.xml 配置文件的修改。我们在输出里删除了条目以增强可读性和节省空间。

    describe-migration 操作的示例

    [standalone@localhost:9999 /] /subsystem=messaging:describe-migration
    {
        "outcome" => "success",
        "result" => {
            "migration-warnings" => [],
            "migration-operations" => [
                {
                    "operation" => "add",
                    "address" => [("extension" => "org.wildfly.extension.messaging-activemq")],
                    "module" => "org.wildfly.extension.messaging-activemq"
                },
                {
                    "operation" => "add",
                    "address" => [("subsystem" => "messaging-activemq")]
                },
                <!-- *** Entries removed for readability *** -->
                {
                    "operation" => "remove",
                    "address" => [("subsystem" => "messaging")]
                },
                {
                    "operation" => "remove",
                    "address" => [("extension" => "org.jboss.as.messaging")]
                }
            ]
        }
    }

  2. 执行 migrate 操作以迁移子系统配置。这个操作使用下列语法。

    /subsystem=SUBSYSTEM_NAME:migrate
    注意

    messaging 子系统及 describe-migrationmigrate 操作允许您传入参数以配置旧客户的访问。关于命令行语法的更多信息,请参考 Messaging Subsystem Migration and Forward Compatibility

  3. 查看命令的输出和结果。请确保操作成功地完成且没有 "migration-warning" 信息。这意味着子系统配置的迁移已完成。

    成功的 migrate 操作示例(没有警告信息)

    [standalone@localhost:9999 /] /subsystem=messaging:migrate
    {
        "outcome" => "success",
        "result" => {"migration-warnings" => []}
    }

    如果您在日志里看到 "migration-warnings" 信息,这表示服务器配置的迁移已成功完成,但它无法迁移所有的元素和属性。您必须根据 "migration-warnings" 提供的建议运行其他管理 CLI 命令来修改这些配置。下面是一个返回 "migration-warnings" 信息的 migrate 操作示例。

    带有警告信息的 migrate 操作示例

    [standalone@localhost:9999 /] /subsystem=messaging:migrate
    {
        "outcome" => "success",
        "result" => {"migration-warnings" => [
            "WFLYMSG0080: Could not migrate attribute group-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupB\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupB\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute local-bind-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute local-bind-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group."
        ]}
    }

  4. 查看服务器配置文件以验证扩展、子系统和命名空间都已更新且现有的子系统配置已迁移至 JBoss EAP 7。

    注意

    您必须通过下列命令为 jacorbmessagingweb 子系统重复这个过程。

    /subsystem=jacorb:migrate
    /subsystem=messaging:migrate
    /subsystem=web:migrate
  5. 从服务器配置里删除 cmpjaxrthreads 子系统和扩展。

    在管理 CLI 提示下,执行下列命令删除过时的 cmpjaxrthreads 子系统。

    /subsystem=cmp:remove
    /extension=org.jboss.as.cmp:remove
    /subsystem=jaxr:remove
    /extension=org.jboss.as.jaxr:remove
    /subsystem=threads:remove
    /extension=org.jboss.as.threads:remove
重要

您必须迁移 messagingjacorbweb 子系统并在重启服务器进行正常操作前删除 cmpjaxrthreads 扩展和子系统。如果在完成这个过程前您需要重启服务器,请确保在服务器启动命令里包含 --admin-only 参数。这允许您继续修改配置。

4.3. 日志消息前缀的修改

日志消息用报告该消息的子系统的项目代码作为前缀。JBoss EAP 7 已修改了所有日志消息的前缀。

For a complete list of the new log message project code prefixes used in JBoss EAP 7, see Project Codes Used in JBoss EAP in the JBoss EAP Development Guide.

4.4. Web 服务器配置的修改

4.4.1. 用 Undertow 替换 Web 子系统

在 JBoss EAP 7 里 Undertow 替换了 JBoss Web。这意味着旧的 web 子系统配置必须迁移到新的 JBoss EAP 7 的 undertow 子系统配置。

  • 服务器配置文件里的 urn:jboss:domain:web:2.2 子系统配置命名空间已被 urn:jboss:domain:undertow:3.1 命名空间替代。
  • 位于 EAP_HOME/modules/system/layers/base/ 里的 org.jboss.as.web 扩展模块,已被 org.wildfly.extension.undertow 扩展模块所替代。

您可以使用管理 CLI 的 migrate 操作将服务器配置文件里的 web 子系统迁移到 undertow。然而,请注意这个操作不能迁移所有的 JBoss Web 子系统配置。如果您看到 "migration-warning" 条目,您必须运行其他的管理 CLI 命令来迁移这些配置到 Undertow。关于管理 CLI 的 migrate 操作的更多信息,请参考 Management CLI Migration Operation

下面是 JBoss EAP 6 里默认的 web 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

下面是 JBoss EAP 6 里默认的 undertow 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>
        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
    </filters>
</subsystem>

4.4.2. 迁移 JBoss Web 重写条件

管理 CLI 的 migrate 操作无法自动迁移重写条件,它们被报告为“migration-warnings”,您必须手动迁移它们。在 JBoss EAP 7 里,您可以用 Undertow Predicates Attributes and Handlers 创建同等的配置。

下面是 JBoss EAP 6 里包含 rewrite 配置的默认 web 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default" native="false">
    <virtual-server name="default" enable-welcome-root="true">
        <alias name="localhost"/>
        <rewrite name="test" pattern="(.*)/toberewritten/(.*)" substitution="$1/rewritten/$2" flags="NC"/>
        <rewrite name="test2" pattern="(.*)" substitution="-" flags="F">
            <condition name="get" test="%{REQUEST_METHOD}" pattern="GET"/>
            <condition name="andCond" test="%{REQUEST_URI}" pattern=".*index.html" flags="NC"/>
        </rewrite>
    </virtual-server>
</subsystem>

按照 Management CLI Migration Operation 说明启动服务器和管理 CLI,然后用下列命令迁移 web 子系统配置文件。

/subsystem=web:migrate

当您对上述配置运行 migrate 操作时会出现下面的 "migration-warnings" 信息。

/subsystem=web:migrate
{
    "outcome" => "success",
    "result" => {"migration-warnings" => [
        "WFLYWEB0002: Could not migrate resource {
    \"pattern\" => \"(.*)\",
    \"substitution\" => \"-\",
    \"flags\" => \"F\",
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\")
    ]
}",
        "WFLYWEB0002: Could not migrate resource {
    \"test\" => \"%{REQUEST_METHOD}\",
    \"pattern\" => \"GET\",
    \"flags\" => undefined,
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\"),
        (\"condition\" => \"get\")
    ]
}",
        "WFLYWEB0002: Could not migrate resource {
    \"test\" => \"%{REQUEST_URI}\",
    \"pattern\" => \".*index.html\",
    \"flags\" => \"NC\",
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\"),
        (\"condition\" => \"andCond\")
    ]
}"
    ]}
}

复查服务器配置文件,您会看到 undertow 子系统的下列配置。

注意

重写(Rewrite)配置已被舍弃。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
     <buffer-cache name="default"/>
     <server name="default-server">
         <http-listener name="http" socket-binding="http"/>
         <host name="default-host" alias="localhost, example.com">
             <location name="/" handler="welcome-content"/>
         </host>
     </server>
     <servlet-container name="default">
         <jsp-config/>
     </servlet-container>
     <handlers>
         <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
     </handlers>
 </subsystem>

使用管理 CLI 创建过滤器来替换 undertow 子系统里的重写配置。每个命令您都应该看到 "{"outcome" ⇒ "success"}" 信息。

# Create the filters
/subsystem=undertow/configuration=filter/expression-filter="test1":add(expression="path('(.*)/toberewritten/(.*)') -> rewrite('$1/rewritten/$2')")
/subsystem=undertow/configuration=filter/expression-filter="test2":add(expression="method('GET') and path('.*index.html') -> response-code(403)")

# Add the filters to the default server
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test1":add
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test2":add

复查已更新的服务器配置文件。JBoss Web 子系统现在已完全迁移且已配置了 undertow 子系统。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="http" socket-binding="http"/>
        <host name="default-host" alias="localhost, example.com">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="test1"/>
            <filter-ref name="test2"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <expression-filter name="test1" expression="path('(.*)/toberewritten/(.*)') -> rewrite('$1/rewritten/$2')"/>
        <expression-filter name="test2" expression="method('GET') and path('.*index.html') -> response-code(403)"/>
    </filters>
</subsystem>

For more information about how to configure filters and handlers using the management CLI, see Configuring the Web Server in the JBoss EAP 7 Configuration Guide.

4.4.3. Migrate JBoss Web System Properties

In the previous release of JBoss EAP, system properties could be used to modify the default JBoss Web behavior. For information about how to configure the same behavior in Undertow, see JBoss Web System Properties Migration Reference

4.4.4. Migrate JBoss Web jboss-web.xml Overlay

In JBoss EAP 6, JBoss Web supported the ability to specify additional static files for a web application using the overlay element in the jboss-web.xml file. This feature did not actually overlay existing files, but instead added static files to a deployment outside of the WAR archive.

In the following jboss-web.xml file example, /tmp/mycontents/test.html was returned by the JBoss EAP 6 server when you accessed the URL http://localhost:8080/example/test.html.

<jboss-web>
    <context-root>/example</context-root>
    <overlay>/tmp/mycontents/</overlay>
</jboss-web>

Undertow, which replaces JBoss Web in JBoss EAP 7, does not support the jboss-web.xml file overlay feature.

4.4.5. 迁移全局阀(Global Valve)

以前的 JBoss EAP 版本支持阀(Valve)。阀是在 Servlet 过滤器修改请求或执行其他处理前插入到应用程序的请求处理管道的自定义类。

  • 全局阀(Global Valve)插入到所有应用程序的请求处理管道且在服务器配置文件进行配置。
  • 验证阀(Authenticator valve)验证请求的凭证。
  • 自定义应用程序阀是通过继承 org.apache.catalina.valves.ValveBase 类并配置 jboss-web.xml 描述符文件里的 <valve> 元素来创建的。您必须手动迁移这些阀。

本节描述了如何迁移全局阀。本指南的『Migrate Custom Application Valves』章节涵盖了自定义和验证阀的迁移。

在 JBoss EAP 7 里替换了 JBoss Web 的 Undertow 不支持全局 Valve。然而,通过使用 Undertow 处理程序,您应该能够实现类似的功能。 Undertow 包含了大量的提供常用功能的内嵌处理程序。它也提供创建自定义处理程序的能力,它们可用来替代自定义 Valve 的功能。

如果您的应用程序使用了阀,在迁移至 JBoss EAP 7 时,您必须用合适的 Undertow 处理程序代码替代它们来实现相同功能。

For more information about how to configure handlers, see Configuring Handlers in the JBoss EAP 7 Configuration Guide.

For more information about how to configure filters, see Configuring Filters in the JBoss EAP 7 Configuration Guide.

迁移 JBoss Web 阀

下表列出之前版本的 JBoss EAP 和对应的 Undertow 内置处理程序提供的阀。JBoss Web 阀位于 org.apache.catalina.valves 软件包里。

表 4.2. 阀和处理程序的映射

处理程序

AccessLogValve

io.undertow.server.handlers.accesslog.AccessLogHandler

CrawlerSessionManagerValve

io.undertow.servlet.handlers.CrawlerSessionManagerHandler

ExtendedAccessLogValve

io.undertow.server.handlers.accesslog.AccessLogHandler

JDBCAccessLogValve

相关说明请参考下面的『JDBCAccessLogValve 手动迁移过程』

RemoteAddrValve

io.undertow.server.handlers.IPAddressAccessControlHandler

RemoteHostValve

io.undertow.server.handlers.AccessControlListHandler

RemoteIpValve

io.undertow.server.handlers.ProxyPeerAddressHandler

RequestDumperValve

io.undertow.server.handlers.RequestDumpingHandler

RewriteValve

关于手动迁移这些阀的说明,请参考『迁移 JBoss Web 重写条件』

StuckThreadDetectionValve

io.undertow.server.handlers.StuckThreadDetectionHandler

您可以使用管理 CLI 的 migrate 操作自动迁移满足下列标准的全局阀。

  • 它们必须是之前表里列出的不需要手动处理的阀。
  • 它们必须在服务器配置文件的 web 子系统里进行定义。

关于管理 CLI 的 migrate 操作的更多信息,请参考 Management CLI Migration Operation

JDBCAccessLogValve 的手动迁移过程

org.apache.catalina.valves.JDBCAccessLogValve 阀是规则的一个例外,它不能自动迁移到 io.undertow.server.handlers.JDBCLogHandler。请遵循下面的步骤来迁移示例阀。

<valve name="jdbc" module="org.jboss.as.web" class-name="org.apache.catalina.valves.JDBCAccessLogValve">
    <param param-name="driverName" param-value="com.mysql.jdbc.Driver" />
    <param param-name="connectionName" param-value="root" />
    <param param-name="connectionPassword" param-value="password" />
    <param param-name="connectionURL" param-value="jdbc:mysql://localhost:3306/wildfly?zeroDateTimeBehavior=convertToNull" />
    <param param-name="format" param-value="combined" />
</valve>
  1. 创建一个用于存储日志条目的数据库的驱动模块。
  2. 配置这个数据库的数据源并添加驱动到 datasources 子系统里的可用驱动列表。

    <datasources>
        <datasource jndi-name="java:jboss/datasources/accessLogDS" pool-name="accessLogDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:mysql://localhost:3306/wildfly?zeroDateTimeBehavior=convertToNull</connection-url>
            <driver>mysql</driver>
            <security>
               <user-name>root</user-name>
               <password>Password1!</password>
            </security>
        </datasource>
        ...
        <drivers>
            <driver name="mysql" module="com.mysql">
                <driver-class>com.mysql.jdbc.Driver</driver-class>
            </driver>
        ...
        </drivers>
    </datasources>
  3. 用下列表达式配置 undertow 子系统里的 expression-filterjdbc-access-log(datasource=DATASOURCE_JNDI_NAME)

    <filters>
        <expression-filter name="jdbc-access" expression="jdbc-access-log(datasource='java:jboss/datasources/accessLogDS')" />
        ...
    </filters>

4.5. JGroups 服务器配置的修改

4.5.1. JGroups 默认使用私有网络接口

在 JBoss EAP 6 默认配置里,JGroups 使用了服务器配置文件的 <interfaces> 部分定义的 public 接口。

因为使用专有的网络接口是我们的推荐做法,在默认情况下,JGroups 使用 JBoss EAP 7 里服务器配置文件的 <interfaces> 部分定义的新的 private 接口。

4.5.2. JGroups 频道的修改

JGroups 以 JGroups 频道的形式提供对 HA 服务的组通讯支持。JBoss EAP 7 在服务器配置文件的 jgroups 子系统里引入了 <channel> 元素。您可以用管理 CLI 添加、删除或修改 JGroups频道的配置。

For more information about how to configure JGroups, see Cluster Communication with JGroups in the JBoss EAP Configuration Guide.

4.6. Infinispan 服务器配置的修改

4.6.1. Infinispan 的默认缓存配置的修改

In JBoss EAP 6, the default clustered caches for web session replication and EJB replication were replicated ASYNC caches. This has changed in JBoss EAP 7. The default clustered caches are now distributed ASYNC caches. The replicated caches are no longer even configured by default. See Configure the Cache Mode in the JBoss EAP Configuration Guide for information about how to add a replicated cache and make it the default.

这只适用于新的 JBoss EAP 7 默认配置。如果您从 JBoss EAP 6 迁移配置,那 infinispan 子系统的配置将被保留。

4.6.2. Infinispan 缓存策略的修改

JBoss EAP 7 已修改了 ASYNC 缓存策略的行为。

在 JBoss EAP 6 里,ASYNC 缓存的读操作是与锁无关的。虽然它们永不会阻塞,但很容易导致过时数据的脏读(Dirty Read),例如发生失效切换的时候。这是因为它会允许相同用户之后的请求在之前请求还未完成前开始。在使用分布式模式时,这种随意性是不能接受的,群集拓扑结构的修改可能影响到会话关联性且容易导致数据过时。

在 JBoss EAP 7 里,ASYNC 缓存读操作需要锁。既然它们现在会阻塞相同用户的新请求直至之前的复制完成,这可以防止脏读(Dirty Read)。

4.7. EJB Server Configuration Changes

If you use the management CLI migrate operation to upgrade your existing configuration, you might see exceptions in the server log when you deploy your EJB applications.

重要

If you use the JBoss Server Migration Tool to update your server configuration, the ejb3 subsystem should be configured correctly and you should not see any issues when you deploy your EJB applications.

DuplicateServiceException

The following DuplicateServiceException is caused by caching changes in JBoss EAP 7.

DuplicateServiceException in Server Log

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."mdb-1.0-SNAPSHOT.jar".cache-dependencies-installer: org.jboss.msc.service.StartException in service jboss.deployment.unit."mdb-1.0-SNAPSHOT.jar".cache-dependencies-installer: Failed to start service
...
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.infinispan.ejb."mdb-1.0-SNAPSHOT.jar".config is already registered

You must reconfigure the cache to resolve this error.

  1. Follow the instructions to Start the Server and the Management CLI.
  2. Issue the following commands to reconfigure caching in the ejb3 subsystem.

    /subsystem=ejb3/file-passivation-store=file:remove
    /subsystem=ejb3/cluster-passivation-store=infinispan:remove
    /subsystem=ejb3/passivation-store=infinispan:add(cache-container=ejb, max-size=10000)
    
    /subsystem=ejb3/cache=passivating:remove
    /subsystem=ejb3/cache=clustered:remove
    /subsystem=ejb3/cache=distributable:add(passivation-store=infinispan, aliases=[passivating, clustered])

4.8. 消息服务器配置的修改

在 JBoss EAP 7 里,ActiveMQ Artemis 作为 JMS 支持提供者替代了 HornetQ。本节描述了如何迁移配置和相关的消息数据。

4.8.1. 消息子系统的服务器配置修改

位于 EAP_HOME/modules/system/layers/base/org.jboss.as.messaging 模块扩展,已被 EAP_HOME/modules/system/layers/base/ 扩展模块替代。

urn:jboss:domain:messaging:3.0 子系统配置命名空间已被 urn:jboss:domain:messaging-activemq:1.0 命名空间替代。

管理模型

多数情况下,我们会尽可能地将元素和属性名称和之前版本保持一致。下表列出了其中一些修改。

表 4.3. 映射消息属性

HornetQ NameActiveMQ Name 

hornetq-server

server

hornetq-serverType

serverType

connectors

connector

discovery-group-name

discovery-group

新的 messaging-activemq 子系统上调用的管理操作已从 /subsystem=messaging/hornetq-server= 改为 /subsystem=messaging-activemq/server=

您可以调用 migrate 操作迁移现有的 JBoss EAP 6 messaging 子系统配置至 JBoss EAP 7 服务器上的 messaging-activemq 子系统。

/subsystem=messaging:migrate

Before you execute the migrate operation, you can invoke the describe-migration operation to review the list of management operations that will be performed to migrate from the existing JBoss EAP 6 messaging subsystem configuration to the messaging-activemq subsystem on the JBoss EAP 7 server.

/subsystem=messaging:describe-migration

对于无法自动迁移的资源或属性,migratedescribe-migration 也会显示一个migration-warnings 列表。

消息子系统的迁移和向前兼容性

用于 messaging 子系统的 describe-migrationmigrate 操作提供了额外的配置参数。如果您想配置消息系统以允许旧的 JBoss EAP 6 客户链接 JBoss EAP 7 服务器,您可以像下面这样添加布尔型 add-legacy-entries 参数至 describe-migrationmigrate 操作。

/subsystem=messaging:describe-migration(add-legacy-entries=true)
/subsystem=messaging:migrate(add-legacy-entries=true)

如果布尔型参数add-legacy-entries 被设置为 truemessaging-activemq 子系统将创建 legacy-connection-factory 资源并添加 legacy-entriesjms-queuejms-topic 资源。

如果布尔型参数add-legacy-entries 被设置为 falsemessaging-activemq 子系统里不会创建旧的资源,且旧的 JMS 客户不能与 JBoss EAP 7 服务器通讯。这是默认值。

For more information about forward and backward compatibility see the Backward and Forward Compatibility in Configuring Messaging for JBoss EAP.

关于管理 CLI migratedescribe-migration 操作的更多信息,请参考 Management CLI Migration Operation

Change in Behavior of forward-when-no-consumers Attribute

The behavior of the forward-when-no-consumers attribute has changed in JBoss EAP 7.

In JBoss EAP 6, when forward-when-no-consumers was set to false and there were no consumers in a cluster, messages were redistributed to all nodes in a cluster.

This behavior has changed in JBoss EAP 7. When forward-when-no-consumers is set to false and there are no consumers in a cluster, messages are not redistributed. Instead, they are kept on the original node to which they were sent.

消息子系统的 XML 配置

XML 配置已根据新的 messaging-activemq 进行了极大的修改以提供和其他 JBoss EAP 子系统更一致的 XML 模式。

It is strongly advised that you do not attempt to modify the JBoss EAP messaging subsystem XML configuration to conform to the new messaging-activemq subsystem. Instead, invoke the legacy subsystem migrate operation. This operation will write the XML configuration of the new messaging-activemq subsystem as a part of its execution.

4.8.2. 迁移消息数据

JBoss EAP 7 里由于 JMS 支持供应商从 HornetQ 变成了 ActiveMQ Artemis,消息数据的格式和位置都发生了变化。

您可以使用下列方式之一来迁移数据:

关于不同版本间消息数据文件夹名称的改动的细节,请参考映射消息文件夹名称

4.8.2.1. 用导出和导入迁移消息数据

通过这个方法,您可以用 HornetQ exporter 工具从之前的版本导出数据。然后您可以用 import-journal 操作来导入 XML 格式的输出文件。

警告

这个方法目前还有一个问题。要查看这个问题的最新情况,请参考 JBEAP-4407 - 从导入的日志读取大型消息时消费者会崩溃并抛出异常 IndexOutOfBoundsException

从之前版本导出消息数据
重要

在您导出消息数据前必须先停止JBoss EAP 6 服务器。

HornetQ 的 exporter 工具从 JBoss EAP 6 生成和导出消息数据到一个 XML 格式的文件。这个命令要求您指定附带 JBoss EAP 6 的 HornetQ JAR 的路径,并将路径作为参数传入之前版本的 messagingbindings/messagingjournal/messagingpaging/messaginglargemessages/ 文件夹,然后指定写入导出的 XML 数据的输出文件。

下面是 HornetQ exporter 工具要求的语法。

java -jar -mp MODULE_PATH org.hornetq.exporter MESSAGING_BINDINGS_DIRECTORY MESSAGING_JOURNAL_DIRECTORY MESSAGING_PAGING_DIRECTORY MESSAGING_LARGE_MESSAGES_DIRECTORY > OUTPUT_DATA.xml

创建自定义模块来确保 HornetQ JAR 的正确版本,包括打补丁或升级时安装的任何 JAR 文件,被加载并对 exporter 工具可用。用您喜欢的编辑器在 EAP6_HOME/modules/org/hornetq/exporter/main/ 目录里创建一个新的 module.xml 文件并复制下列内容:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.hornetq.exporter">
    <main-class name="org.hornetq.jms.persistence.impl.journal.XmlDataExporter"/>
    <properties>
        <property name="jboss.api" value="deprecated"/>
    </properties>
    <dependencies>
        <module name="org.hornetq"/>
    </dependencies>
</module>
注意

这个自定义模块在 modules/ 而不是 modules/system/layers/base/ 目录里创建。

按照下列步骤来导出数据。

  1. 停止 JBoss EAP 6 服务器。
  2. 按上述步骤创建自定义模块。
  3. 运行下列命令来导出数据。

    $ java -jar jboss-modules.jar -mp modules/ org.hornetq.exporter standalone/data/messagingbindings/ standalone/data/messagingjournal/ standalone/data/messagingpaging standalone/data/messaginglargemessages/ > OUTPUT_DIRECTORY/OldMessagingData.xml
  4. 确保执行完命令后在日志里没有错误或警告信息。
  5. 使用您的操作系统里可用的工具来检验生成的输出文件里的 XML。
导入 XML 格式的消息数据

然后您可以用 import-journal 操作来导入 XML 格式的输出文件。

/subsystem=messaging-activemq/server=default:import-journal(file=OUTPUT_DIRECTORY/OldMessagingData.xml)

4.8.2.2. 用 JMS 桥迁移消息数据

通过这个方法,您可以配置和部署 JMS 桥将消息从 JBoss EAP 6 HornetQ 队列迁移到 JBoss EAP 7 ActiveMQ Artemis 队列。

JMS 桥消费源 JMS 队列或主题里的消息并发送到目标 JMS 队列或主题(通常位于不同的服务器上)。它可以用于桥接 任何 JMS 服务器间的消息,只要这些消息是兼容 JMS 1.1 的。源和目的 JMS 资源通过 JNDI 查找,用于 JNDI 查找的客户类必须捆绑在模块里。然后在 JMS 桥配置里声明模块名。

本节描述了如何配置服务器和部署 JMS 桥来将消息数据从 JBoss EAP 6 迁移到 JBoss EAP 7。

配置 JBoss EAP 6 服务器
  1. 停止 JBoss EAP 6 服务器。
  2. 备份 HornetQ 日志和配置文件

    • 在默认情况下,HornetQ 日志位于 EAP6_HOME/standalone/data/ 目录里。
    • 关于不同版本的默认消息文件夹,请参考映射消息文件夹名称
  3. 确保在 JBoss EAP 6 服务器上定义了包含 JMS 消息的 InQueue JMS 队列。
  4. 确保 messaging 子系统配置包含用于 RemoteConnectionFactory 的条目,类似于:

    <connection-factory name="RemoteConnectionFactory">
        <entries>
            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
        </entries>
        ...
    </connection-factory>

    如果它没有包含这个条目,请用下列管理 CLI 命令创建:

    /subsystem=messaging/hornetq-server=default/connection-factory=RemoteConnectionFactory:add(factory-type=XA_GENERIC, connector=[netty], entries=[java:jboss/exported/jms/RemoteConnectionFactory],ha=true,block-on-acknowledge=true,retry-interval=1000,retry-interval-multiplier=1.0,reconnect-attempts=-1)
配置 JBoss EAP 7 服务器
  1. 在以前的版本里,JMS 桥配置需要 org.hornetq 模块来连接 HornetQ 服务器。JBoss EAP 7 里这个模块和直接依赖关系已不再出现,所以您必须从之前的版本复制下列模块。

    • 复制 org.hornetq 模块至 JBoss EAP 7 EAP_HOME/modules/org/ 目录。

      • If you did not apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/org/hornetq/
      • If you did apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-6.4.x.CP/org/hornetq/
    • Remove the <resource-root> for the HornetQ lib path from the JBoss EAP 7 EAP_HOME/modules/org/hornetq/main/module.xml file.

      • If you did not apply patches to the JBoss EAP 6.4 org.hornetq module, remove the following line from the file:

        <resource-root path="lib"/>
      • If you did apply patches to the JBoss EAP 6.4 org.hornetq module, remove the following lines from the file:

        <resource-root path="lib"/>
        <resource-root path="../../../../../org/hornetq/main/lib"/>
        警告

        Failure to remove the HornetQ lib path resource-root will cause the bridge to fail with the following error in the log file.

        2016-07-15 09:32:25,660 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("add") failed - address: ([
            ("subsystem" => "messaging-activemq"),
            ("jms-bridge" => "myBridge")
        ]) - failure description: "WFLYMSGAMQ0086: Unable to load module org.hornetq"
    • Copy the org.jboss.netty module into the JBoss EAP 7 EAP_HOME/modules/org/jboss/ directory.

      • If you did not apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/org/jboss/netty/
      • If you did apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-6.4.x.CP/org/jboss/netty
  2. 创建 JMS 队列以包含从 JBoss EAP 6 服务器接收的消息。下面是创建 MigratedMessagesQueue JMS 队列以接收消息的管理 CLI 命令的示例。

    jms-queue add --queue-address=MigratedMessagesQueue --entries=[jms/queue/MigratedMessagesQueue java:jboss/exported/jms/queue/MigratedMessagesQueue]

    这会为 JBoss EAP 7 服务器的 messaging-activemq 子系统的默认服务器创建下列 jms-queue 配置。

    <jms-queue name="MigratedMessagesQueue" entries="jms/queue/MigratedMessagesQueue java:jboss/exported/jms/queue/MigratedMessagesQueue"/>
  3. 确保 messaging-activemq 子系统的 default 服务器包含用于 InVmConnectionFactory connection-factory 的配置,类似于:

    <connection-factory name="InVmConnectionFactory" factory-type="XA_GENERIC" entries="java:/ConnectionFactory" connectors="in-vm"/>

    如果它没有包含这个条目,请用下列管理 CLI 命令创建:

    /subsystem=messaging-activemq/server=default/connection-factory=InVmConnectionFactory:add(factory-type=XA_GENERIC, connectors=[in-vm], entries=[java:/ConnectionFactory])
  4. 创建和部署从 JBoss EAP 6 服务器上配置的 InQueue JMS 队列读取消息的 JMS 桥并将其转换为 JBoss EAP 7 上的 MigratedMessagesQueue

    /subsystem=messaging-activemq/jms-bridge=myBridge:add(add-messageID-in-header=true,max-batch-time=100,max-batch-size=10,max-retries=-1,failure-retry-interval=1000,quality-of-service=AT_MOST_ONCE,module=org.hornetq,source-destination=jms/queue/InQueue,source-connection-factory=jms/RemoteConnectionFactory,source-context=[("java.naming.factory.initial"=>"org.jboss.naming.remote.client.InitialContextFactory"),("java.naming.provider.url"=>"remote://127.0.0.1:4447")],target-destination=jms/queue/MigratedMessagesQueue,target-connection-factory=java:/ConnectionFactory)

    这会在 JBoss EAP 7 服务器上的 messaging-activemq 子系统里创建下列 jms-bridge 配置。

    <jms-bridge name="myBridge" add-messageID-in-header="true" max-batch-time="100" max-batch-size="10" max-retries="-1" failure-retry-interval="1000" quality-of-service="AT_MOST_ONCE" module="org.hornetq">
        <source destination="jms/queue/InQueue" connection-factory="jms/RemoteConnectionFactory">
            <source-context>
                <property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
                <property name="java.naming.provider.url" value="remote://127.0.0.1:4447"/>
            </source-context>
        </source>
        <target destination="jms/queue/MigratedMessagesQueue" connection-factory="java:/ConnectionFactory"/>
    </jms-bridge>
  5. 如果为JBoss EAP 6 配置了安全性,你也必须配置 JMS 桥配置 <source> 元素,使其包含指定正确用户名和密码的 source-context,从而在创建连接时用于 JNDI 查找。
迁移数据
  1. 检验您为下列配置提供的信息是否正确。

    • 任何的队列和主题名称
    • 用于 JNDI 查找的 java.naming.provider.url
  2. 确保您已部署了目标 JMS 目的地至 JBoss EAP 7 服务器。
  3. 启动JBoss EAP 6 及 JBoss EAP 7 服务器。

4.8.2.3. 映射消息文件夹位置

下表展示了之前版本使用的消息目录名和本版本里对应的名称。这些目录是相对于 jboss.server.data.dir 的,如果没有指定,它的默认值是 EAP_HOME/standalone/data/

JBoss EAP 6 的目录名称JBoss EAP 7 的目录名称

messagingbindings/

activemq/bindings/

messagingjournal/

activemq/journal/

messaginglargemessages/

activemq/largemessages/

messagingpaging/

activemq/paging/

注意

The messaginglargemessages/ and messagingpaging/ directories might not be present if there are no large messages or if paging is disabled.

4.8.3. 迁移 JMS 目的地

在以前的 JBoss EAP 版本里,JMS 目的地队列是在 messaging 子系统的 <hornetq-server> 元素下的 <jms-destinations> 里配置的。

<hornetq-server>
  ...
  <jms-destinations>
     <jms-queue name="testQueue">
        <entry name="queue/test"/>
         <entry name="java:jboss/exported/jms/queue/test"/>
      </jms-queue>
  </jms-destinations>
  ...
</hornetq-server>

在 JBoss EAP 7 里,JMS 目的地队列是在 messaging-activemq 子系统的默认 <server> 元素里配置的。

<server name="default">
  ...
  <jms-queue name="testQueue" entries="queue/test java:jboss/exported/jms/queue/test"/>
  ...
</server>

4.8.4. 迁移消息拦截器

JBoss EAP 7 里消息拦截器已发生了重大改变,JMS 消息提供者由 HornetQ 替换为 ActiveMQ Artemis。

之前版本里的 HornetQ 的 messaging 子系统要求您将 HornetQ 拦截器添加至 JAR 并修改 module.xml 文件来安装 HornetQ 拦截器。

The messaging-activemq subsystem included in JBoss EAP 7 does not require modification of a module.xml file. User interceptor classes, which now implement the Apache ActiveMQ Artemis Interceptor interface, can now be loaded from any server module. You specify the module from which the interceptor should be loaded in the messaging-activemq subsystem of the server configuration file.

拦截器配置示例

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
  <server name="default">
    ...
    <incoming-interceptors>
      <class name="com.mycompany.incoming.myInterceptor" module="com.mycompany" />
      <class name="com.othercompany.incoming.myOtherInterceptor" module="com.othercompany" />
    </incoming-interceptors>
    <outgoing-interceptors>
      <class name="com.mycompany.outgoing.myInterceptor" module="com.mycompany" />
      <class name="com.othercompany.outgoing.myOtherInterceptor" module="com.othercompany" />
    </outgoing-interceptors>
  </server>
</subsystem>

4.8.5. 替代 Netty Servlet 配置

在 JBoss EAP 6 里,你可以配置一个 Servlet 引擎与 Netty Servlet 传输一起使用。因为在 JBoss EAP 7 里内置的消息供应商由 ActiveMQ Artemis 替代了 HornetQ,这样的配置不再可用。您必须替换 Servlet 配置以使用新的内置消息 HTTP 连接器和 HTTP 接收器。

4.9. JMX Management Changes

The HornetQ component in JBoss EAP 6 provided its own JMX management; however, it was not recommended and is now deprecated and no longer supported. If you relied on this feature in JBoss EAP 6, you must migrate your management tooling to use either the JBoss EAP management CLI or the JMX management provided with JBoss EAP 7.

You must also upgrade your client libraries to use the jboss-client.jar that ships with JBoss EAP 7.

The following is an example of HornetQ JMX management code that was used in JBoss EAP 6.

JMXConnector connector = null;
try {
    HashMap environment = new HashMap();
    String[] credentials = new String[]{"admin", "Password123!"};
    environment.put(JMXConnector.CREDENTIALS, credentials);

    // HornetQ used the protocol "remoting-jmx" and port "9999"
    JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remoting-jmx://127.0.0.1:9999");

    connector = JMXConnectorFactory.connect(beanServerUrl, environment);
    MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();

    // The JMX object name pointed to the HornetQ JMX management
    ObjectName objectName = new ObjectName("org.hornetq:type=Server,module=JMS");

    // The invoked method name was "listConnectionIDs"
    String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIDs", new Object[]{}, new String[]{});
    for (String connection : connections) {
        System.out.println(connection);
    }
} finally {
    if (connector != null) {
      connector.close();
   }
}

The following is an example of the equivalent code needed for ActiveMQ Artemis in JBoss EAP 7.

JMXConnector connector = null;
try {
    HashMap environment = new HashMap();
    String[] credentials = new String[]{"admin", "Password123!"};
    environment.put(JMXConnector.CREDENTIALS, credentials);

    // ActiveMQ Artemis uses the protocol "remote+http" and port "9990"
    JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remote+http://127.0.0.1:9990");

    connector = JMXConnectorFactory.connect(beanServerUrl, environment);
    MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();

    // The JMX object name points to the new JMX management in the `messaging-activemq` subsystem
    ObjectName objectName = new ObjectName("jboss.as:subsystem=messaging-activemq,server=default");

    // The invoked method name is now "listConnectionIds"
    String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIds", new Object[]{}, new String[]{});
    for (String connection : connections) {
        System.out.println(connection);
    }
} finally {
    if (connector != null) {
      connector.close();
   }
}

Notice that the method names and parameters have changed in the new implementation. You can find the new method names in the JConsole by following these steps.

  1. Connect to the JConsole using the following command.

    EAP_HOME/bin/jconsole.sh
  2. Connect to JBoss EAP local process. Note that it should start with "jboss-modules.jar".
  3. In the MBeans tab, choose jboss.asmessaging-activemqdefaultOperations to display the list of method names and attributes.

4.10. ORB 服务器配置的修改

在 JBoss EAP 7 里 JacORB 实现已用 OpenJDK ORB 的一个下游分支代替。

位于 EAP_HOME/modules/system/layers/base/ 里的 org.jboss.as.jacorb 扩展模块,已被 org.wildfly.iiop-openjdk 扩展模块所替代。

服务器配置文件里的 urn:jboss:domain:jacorb:1.4 子系统配置命名空间已被 urn:jboss:domain:iiop-openjdk:1.0 命名空间替代。

下面是 JBoss EAP 6 里默认的 jacorb 系统配置示例。

<subsystem xmlns="urn:jboss:domain:jacorb:1.4">
    <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl">
        <initializers security="identity" transactions="spec"/>
    </orb>
</subsystem>

下面是 JBoss EAP 7 里默认的 iiop-openjdk 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:iiop-openjdk:1.0">
    <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl" />
    <initializers security="identity" transactions="spec" />
</subsystem>

新的 iiop-openjdk 子系统配置只接受旧的元素和属性的一个子集。下面是之前 JBoss EAP 版本里的 jacorb 子系统配置,它包含所有的有效元素和属性:

<subsystem xmlns="urn:jboss:domain:jacorb:1.4">
   <orb name="JBoss" print-version="off" use-imr="off" use-bom="off"  cache-typecodes="off"
       cache-poa-names="off" giop-minor-version="2" socket-binding="jacorb" ssl-socket-binding="jacorb-ssl">
       <connection retries="5" retry-interval="500" client-timeout="0" server-timeout="0"
           max-server-connections="500" max-managed-buf-size="24" outbuf-size="2048"
           outbuf-cache-timeout="-1"/>
       <initializers security="off" transactions="spec"/>
   </orb>
   <poa monitoring="off" queue-wait="on" queue-min="10" queue-max="100">
       <request-processors pool-size="10" max-threads="32"/>
   </poa>
   <naming root-context="JBoss/Naming/root" export-corbaloc="on"/>
   <interop sun="on" comet="off" iona="off" chunk-custom-rmi-valuetypes="on"
       lax-boolean-encoding="off" indirection-encoding-disable="off" strict-check-on-tc-creation="off"/>
   <security support-ssl="off" add-component-via-interceptor="on" client-supports="MutualAuth"
       client-requires="None" server-supports="MutualAuth" server-requires="None"/>
   <properties>
       <property name="some_property" value="some_value"/>
   </properties>
</subsystem>

下面的元素和属性不再被支持且必须删除。

表 4.4. 要删除的属性

Element不支持的属性

<orb>

  • client-timeout
  • max-managed-buf-size
  • max-server-connections
  • outbuf-cache-timeout
  • outbuf-size
  • connection retries
  • retry-interval
  • name
  • server-timeout

<poa>

  • queue-min
  • queue-max
  • pool-size
  • max-threads

下面的 on/off 属性不再被支持,在运行管理 CLI migrate 操作迁移时也不会被迁移。如果它们被设置为 on,您将看到迁移警告。这个表里提及的其他 on/off 属性(如 <security support-ssl="on|off">)仍被支持且可以成功迁移。唯一的区别是它们的值将从 on/off 改为 true/false

表 4.5. 要关闭或删除的属性

Element要设置为 off 的属性

<orb>

  • cache-poa-names
  • cache-typecodes
  • print-version
  • use-bom
  • use-imr

<interop>

(all except sun)

  • comet
  • iona
  • chunk-custom-rmi-valuetypes
  • indirection-encoding-disable
  • lax-boolean-encoding
  • strict-check-on-tc-creation

<poa/>

  • monitoring
  • queue-wait

4.11. 迁移 Threads 子系统配置

JBoss EAP 6 服务器配置包含了一个 threads 子系统,它用来管理服务器里不同子系统的线程池。

JBoss EAP 7 里不再有 threads 子系统,相反,每个子系统都负责管理自己的线程池。

For information about how to configure thread pools for the infinispan subsystem, see Configure Infinispan Thread Pools in the JBoss EAP Configuration Guide.

For information about how to configure thread pools for the jgroups subsystem, see Configure JGroups Thread Pools in the JBoss EAP Configuration Guide.

In JBoss EAP 6, you configured thread pools for connectors and listeners for the web subsystem by referencing an executor that was defined in the threads subsystem. In JBoss EAP 7, you now configure thread pools for the undertow subsystem by referencing a worker that is defined in the io subsystem. For more information, see Configuring the IO Subsystem in the JBoss EAP Configuration Guide.

For information about about changes to thread pool configuration in the remoting subsystem, see Migrate the Remoting Subsystem Configuration in this guide, and Configuring the Endpoint in the JBoss EAP Configuration Guide.

4.12. 迁移 Remoting 子系统配置

在 JBoss EAP 6 里,您通过设置 worker-* 属性为 remoting 子系统配置线程池。而 JBoss EAP 7 不再在 remoting 子系统里配置工作节点线程池,如果您试图修改现有的配置,你会看到下面的信息。

WFLYRMT0022: Worker configuration is no longer used, please use endpoint worker configuration

在 JBoss EAP 7 里,工作节点线程池被引用 io 子系统里定义的 worker 的端点配置所替代。

For information about how to configure the endpoint, see Configuring the Endpoint in the JBoss EAP Configuration Guide.

4.13. WebSocket 服务器配置的修改

要在 JBoss EAP 里使用 WebSocket,您需要通过下面的命令行为 JBoss EAP 服务器配置文件里 web 子系统的 http 连接器启用非阻塞式的 JAVA NIO2 连接器协议。

/subsystem=web/connector=http/:write-attribute(name=protocol,value=org.apache.coyote.http11.Http11NioProtocol)

要在应用程序里使用 WebSockets,您也需要在应用程序的 WEB-INF/jboss-web.xml 文件里创建一个 <enable-websockets> 元素并设置其为 true

在 JBoss EAP 7 里,您不再需要配置服务器默认支持 WebSocket 或配置应用程序使用它。WebSocket 是 Java EE 7 规格所要求的,也是默认配置的必需协议。多数复杂的 WebSocket 配置都是在 undertow 子系统的 servlet-container 里完成的。您可以用下列命令查看可用的设置。

/subsystem=undertow/servlet-container=default/setting=websockets:read-resource(recursive=true)
{
   "outcome" => "success",
   "result" => {
       "buffer-pool" => "default",
       "dispatch-to-worker" => true,
       "worker" => "default"
   }
}

JBoss EAP 附带的 quickstarts 里也有关于 WebSocket 的代码示例。

4.14. 单点登录服务器的修改

The infinispan subsystem still provides distributed caching support for HA services in the form of Infinispan caches in JBoss EAP 7; however the caching and distribution of authentication information is handled differently than in previous releases.

在 JBoss EAP 6 里,如果 Infinispan 缓存没有提供单点登录(SSO),那么这个缓存不能是分布式的。

而在 JBoss EAP 7 里,当您选择 HA 配置集时,SSO 是自动分布的。当用 HA 配置集运行时,每台主机都有自己的基于 Web 缓存容器默认缓存的 Infinispan 缓存。这个缓存存储相关的会话和主机的 SSO cookie 信息。JBoss EAP 处理单独的缓存信息向所有主机的传播。 在 JBoss EAP 7 里无法专门分配某个 Infinispan 缓存给 SSO。

在 JBoss EAP 7 里,SSO 是在服务器配置的 undertow 子系统里进行配置的。

SSO 迁移到 JBoss EAP 7 时不需要修改代码。

4.15. 数据源配置的修改

4.15.1. JDBC 数据源驱动名称

当您在以前的 JBoss EAP 版本里配置数据源时,为驱动名指定的值取决于 JDBC 驱动 JAR 里包含的 META-INF/services/java.sql.Driver 文件里列出的类的数量。

包含单个类的驱动

如果 META-INF/services/java.sql.Driver 文件只指定了一个类,驱动名将是 JDBC 驱动 JAR 的名称。JBoss EAP 7 没有改变这一点。

包含多个类的驱动

在 JBoss EAP 6 里,如果 META-INF/services/java.sql.Driver 文件列出了多个类,您可以指定哪个类将其名称附加到 JAR 名称,之后是主要和次要版本号。例如:

JAR_NAME + DRIVER_CLASS_NAME + "_" + MAJOR_VERSION + "_" + MINOR_VERSION

而 JBoss EAP 7 里的命名有所不同,现在您用下列格式指定驱动名称。

JAR_NAME + "_" + DRIVER_CLASS_NAME + "_" + MAJOR_VERSION + "_" + MINOR_VERSION
注意

JAR_NAME 和 DRIVER_CLASS_NAME 之间多了一个下划线。

MySQL 5.1.31 JDBC 驱动是一个包含两个类的例子。其驱动类名是 com.mysql.jdbc.Driver。下面的例子展示了之前版本和当前版本的 JBoss EAP 指定驱动名的不同之处。

JBoss EAP 6 驱动名称示例

mysql-connector-java-5.1.31-bin.jarcom.mysql.jdbc.Driver_5_1

JBoss EAP 7 驱动名称示例

mysql-connector-java-5.1.31-bin.jar_com.mysql.jdbc.Driver_5_1

4.16. 安全服务器配置的修改

For information about Java Security Manager server configuration changes, see Considerations Moving from Previous Versions in How To Configure Server Security for JBoss EAP.

4.17. Transactions 子系统的修改

JBoss EAP 6 的 transactions 子系统里的一些事务管理者配置属性在 JBoss EAP 7 里进行了修改。

Removed Transactions Subsystem Attributes

下表列出了JBoss EAP 7 里删除的 JBoss EAP 6 transactions 子系统属性及其替代属性。

JBoss EAP 6 里的属性JBoss EAP 7 里的接替者

path

object-store-path

relative-to

object-store-relative-to

已舍弃的 Transactions 子系统属性

The following attributes that were available in the transactions subsystem in JBoss EAP 6 are deprecated in JBoss EAP 7. The deprecated attributes might be removed in a future release of the product. The following table lists the equivalent replacement attributes.

JBoss EAP 6 里的属性JBoss EAP 7 里的接替者

use-hornetq-store

use-journal-store

hornetq-store-enable-async-io-to

journal-store-enable-async-io

enable-statistics

statistics-enabled

4.18. mod_cluster 配置的修改

JBoss EAP 7 已修改了 mod_cluster 里的静态代理列表的配置。

在 JBoss EAP 6 里,您会配置 proxy-list 属性,它是一个用逗号隔开的格式为 hostname:port 的 HTTPS 代理地址列表。

JBoss EAP 7 里已舍弃了 proxy-list 属性。它被作为转出套接字绑定名称列表的 proxies 属性替代。

This change impacts how you define a static proxy list, for example, when disabling advertising for mod_cluster. For information about how to disable advertising for mod_cluster, see Disable Advertising for mod_cluster in the JBoss EAP Configuration Guide.

For more information about mod_cluster attributes, see ModCluster Subsystem Attributes in the JBoss EAP Configuration Guide.

第 5 章 应用程序迁移的修改

5.1. Web Service 的应用程序修改

JBossWS 5 为 JBoss EAP 7 Web Services 带来了新的功能和性能改进,这主要是通过升级 Apache CXFApache WSS4JApache Santuario 完成的。

5.1.1. JAX-RPC 支持的修改

基于 XML 的 RPC(JAX-RPC)的 Java API 在 Java EE 6 已被舍弃,在 Java EE 7 里是可选的。在 JBoss EAP 7 里它不再可用也不被支持。使用 JAX-RPC 的应用程序必须迁移以使用目前 Java EE 的标准 Web Service 框架 JAX-WS

JAX-RPC Web Service 可以用下列途径确认:

  • 使用 JAX-RPC 映射文件,它是一个 XML 文件,其根元素是 <java-wsdl-mapping>
  • 使用包含 <webservice-description> 元素(包含 <jaxrpc-mapping-file> 子元素)的 webservices.xml XML 描述符文件。下面是一个定义 JAX-RPC web service 的 webservices.xml 描述符文件示例。

    <webservices xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd" version="1.1">
      <webservice-description>
        <webservice-description-name>HelloService</webservice-description-name>
        <wsdl-file>WEB-INF/wsdl/HelloService.wsdl</wsdl-file>
        <jaxrpc-mapping-file>WEB-INF/mapping.xml</jaxrpc-mapping-file>
        <port-component>
          <port-component-name>Hello</port-component-name>
          <wsdl-port>HelloPort</wsdl-port>
          <service-endpoint-interface>org.jboss.chap12.hello.Hello</service-endpoint-interface>
          <service-impl-bean>
            <servlet-link>HelloWorldServlet</servlet-link>
          </service-impl-bean>
        </port-component>
      </webservice-description>
    </webservices>
  • 使用 ejb-jar.xml 文件,它包含引用 JAX-RPC 映射文件的 <service-ref> 元素。

5.1.2. Apache CXF Spring Web Services 的修改

在以前的 JBoss EAP 版本里,您可以通过在端点部署归档里包含 jbossws-cxf.xml 配置文件来自定义 JBossWS 和 Apache CXF 集成。其中已一个例子是为 Apache CXF 总线上的 Web Service 客户和服务器端点配置连接器链。这个集成要求在 JBoss EAP 服务器里部署 Spring。

JBoss EAP 7 不再支持 Spring 集成。任何包含 jbossws-cxf.xml 描述符配置文件的应用程序必须进行修改,替换该文件里定义的自定义配置。虽然您仍可以直接访问 Apache CXF API,请注意应用程序将会是不可迁移的。

我们建议的方法是尽量用新的 JBossWS 描述符配置选项替换 Spring 自定义配置。基于 JBossWS 描述符的方法提供了类似的功能而无需修改客户端点代码。在某些情况下,您可以用 Context Dependency Injection (CDI) 替代 Spring。

Apache CXF 拦截器

JBossWS 描述符提供了新的配置选项,允许您声明拦截器而无需修改客户端点代码。通过指定 cxf.interceptors.incxf.interceptors.out 属性的拦截器类名,您可以在预定义的客户和端点配置里声明拦截器。

下面是一个 jaxws-endpoint-config.xml 文件示例,它用这些属性声明拦截器。

<?xml version="1.0" encoding="UTF-8"?>
<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
  xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
  <endpoint-config>
    <config-name>org.jboss.test.ws.jaxws.cxf.interceptors.EndpointImpl</config-name>
    <property>
      <property-name>cxf.interceptors.in</property-name>
      <property-value>org.jboss.test.ws.jaxws.cxf.interceptors.EndpointInterceptor,org.jboss.test.ws.jaxws.cxf.interceptors.FooInterceptor</property-value>
    </property>
    <property>
      <property-name>cxf.interceptors.out</property-name>
      <property-value>org.jboss.test.ws.jaxws.cxf.interceptors.EndpointCounterInterceptor</property-value>
    </property>
  </endpoint-config>
</jaxws-config>
Apache CXF 功能

JBossWS 描述符允许您通过指定 cxf.features 属性的功能类名列表,在预定义的客户和端点配置里声明功能。

下面是一个 jaxws-endpoint-config.xml 文件示例,它用这些属性声明了一个功能。

<?xml version="1.0" encoding="UTF-8"?>
<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
  xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
  <endpoint-config>
    <config-name>Custom FI Config</config-name>
    <property>
      <property-name>cxf.features</property-name>
      <property-value>org.apache.cxf.feature.FastInfosetFeature</property-value>
    </property>
  </endpoint-config>
</jaxws-config>
Apache CXF 的 HTTP 传输

在 Apache CXF 里,HTTP 传输配置是通过 org.apache.cxf.transport.http.HTTPConduit 属性实现的。JBoss WS 集成允许在程序里使用 Apache CXF API 修改 Conduit。

import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

// Set chunking threshold before using a JAX-WS port client
...
HTTPConduit conduit = (HTTPConduit)ClientProxy.getClient(port).getConduit();
HTTPClientPolicy client = conduit.getClient();

client.setChunkingThreshold(8192);
...

您也通过设置系统属性来控制和覆盖 Apache CXF HTTPConduit 的默认值。

属性类型描述

cxf.client.allowChunking

布尔值

指定是否用分块发送请求。

cxf.client.chunkingThreshold

整数

设置从非分块切模式切换至分块模式时的极限值。

cxf.client.connectionTimeout

长整数

设置连接超时(毫秒)。

cxf.client.receiveTimeout

长整数

设置接收超时(毫秒)。

cxf.client.connection

字符串

指定是否使用 Keep-Aliveclose 连接类型。

cxf.tls-client.disableCNCheck

布尔值

指定是否禁用 CN 主机名称检查。

5.1.3. WS-Security 修改

  • 如果您的应用程序包含了自定义的访问 org.apache.ws.security.WSPasswordCallback 类的回调处理程序,请注意这个类已经移至 org.apache.wss4j.common.ext 软件包。
  • org.apache.ws.security.saml.ext 软件包里大多数 SAML bean 对象已经移至 org.apache.wss4j.common.saml package
  • 使用 RSA v1.5 关键字传输并默认禁用所有相关的算法。
  • 安全令牌服务(Security Token Service,STS)之前只检验 onBehalfOf 令牌。它现在可以检验 ActAs 令牌。因此,您必须在为 ActAs 令牌提供的 UsernameToken 里指定有效的用户名和密码。
  • SAML Bearer 令牌现在要求具有内部签名。org.apache.wss4j.dom.validate.SamlAssertionValidator 类现在有一个 setRequireBearerSignature() 方法来启用或禁用签名验证。

5.1.4. JBoss 模块结构的修改

cxf-apicxf-rt-core JAR 已合并到一个 cxf-core JAR。因此,JBoss EAP 里的 org.apache.cxf 模块现在包含了 cxf-core JAR 并较之以前的版本开放了更多的类。

5.1.5. Bouncy Castle 的要求和修改

如果您想对 XML/WS-Security 里的对称加密使用 AES 加密和 Galois/Counter Mode (GCM),您需要 BouncyCastle 安全提供者。

JBoss EAP 7 附带了 org.bouncycastle 模块,JBossWS 现在能够依赖自己的类加载来获取和使用 BouncyCastle 安全提供者。因此不再需要再当前 JMV 里静态地安装 BouncyCastle。对于运行在容器外而要访问安全提供者的应用程序,你可以添加 BouncyCastle 库到 classpath 里。

您可以通过设置 jaxws-endpoint-config.xml(服务器)或 jaxws-client-config.xml (客户)里的 org.jboss.ws.cxf.noLocalBC 属性值为 true 来禁用这个行为。

如果您不想使用 JBoss EAP 附带的版本,您仍可以将 BouncyCastle 静态地安装到 JVM 里。在这种情况下,静态安装的 BouncyCastle 将优先于 classpth 的安全提供者。要避免这种情况,您必须使用 BouncyCastle 1.49、1.51 或更高的版本。

5.1.6. Apache CXF 总线选择策略

容器里运行的客户的默认总线选择策略已从 THREAD_BUS 改为 TCCL_BUS。对于在容器外运行的客户,默认的策略仍是 THREAD_BUS。您可以用下列方法来恢复之前版本里的设置。

  • 将系统属性 org.jboss.ws.cxf.jaxws-client.bus.strategy 设置为 THREAD_BUS 来引导 JBoss EAP 服务器。
  • 显性地在客户代码里设置选择策略。

5.1.7. WebServiceRef 对 JAX-WS 2.2 的要求

容器必须使用JAX-WS 2.2 风格的构造器,它使用 WebServiceFeature 类来构建注入到 Web service 引用里的客户。这意味着用户提供的服务类(由容器注入)必须实现 JAX-WS 2.2 或更高规格。

5.1.8. 忽略 HttpsHost CN 检查

在以前的版本里,通过设置系统属性 org.jboss.security.ignoreHttpsHosttrue,您可以禁用对证书里服务器的公共名称(Common Name,CN) 的 HTTPS URL 主机名检查。这个系统属性名称已被 cxf.tls-client.disableCNCheck 所替代。

5.1.9. 服务器端的配置和类加载

As a consequence of enabling injections into service endpoint and service client handlers, it is no longer possible to automatically load handler classes from the org.jboss.as.webservices.server.integration JBoss module. If your application depends on a given predefined configuration, you might need to explicitly define new module dependencies for your deployment. For more information, see Migrate Explicit Module Dependencies

5.1.10. 舍弃 Java Endorsed Standards Override Mechanism

JDK 1.8_40 已舍弃 Java Endorsed Standards Override Mechanism 而 JDK 9 将删除它。这个机制允许开发人员将 JAR 放入 JRE 里支持的目录,从而使这些库为所有部署的应用程序所用。

如果您的应用程序使用了 Apache CXF 的 JBossWS 实现,JBoss EAP 7 会确保以正确的顺序添加所需的依赖关系,所以您不会受这些改动的影响。如果您的应用程序直接访问 Apache CXF,作为应用程序部署的一部分,在 JBossWS 依赖关系之后您现在必须提供 Apache CXF 依赖关系。

5.1.11. EAR 归档里的描述符规格

在以前的 JBoss EAP 版本里,您可以为 JAR 归档的 META-INF/ 里的 EJB Web Service 部署或 WEB-INF/ 里的 POJO Web Service 部署及 WAR 归档捆绑的 EJB Web Service 端点配置 jboss-webservices.xml 部署描述符文件。

在 JBoss EAP 7 里,您现在可以在 EAR 归档的 META-INF/ 目录里配置 jboss-webservices.xml 部署描述符文件。如果 EAR 归档和 JAR 或 WAR 归档里都有 jboss-webservices.xml 文件,JAR 或 WAR 的 jboss-webservices.xml 里的配置数据会覆盖 EAR 描述符文件里对应的数据。

5.2. 更新远程 URL 连接器和端口

在 JBoss EAP 7 里,默认的连接器已从 remote 改为 http-remoting,且默认的远程连接端口已从 4447 改为 8080。默认配置的 JNDI 供应商 URL 已从 remote://localhost:4447 改为 http-remoting://localhost:8080

If you use the JBoss EAP 7 migrate operation to update your configuration, you do not need to modify the remote connector, remote port, or JNDI provider URLs because the migration operation preserves the JBoss EAP 6 remoting connector and 4447 port configuration settings in the subsystem configuration. For more information about the migrate operation, see Management CLI Migration Operation.

如果您没有使用 migrate 操作而用新的 JBoss EAP 7 默认配置来运行,你必须修改远程连接、远程端口以及 JNDI 供应商 URL 来使用上述新的设置。

5.3. 消息应用程序的修改

5.3.1. 替换或更新 JMS 部署描述符

JBoss EAP 7 舍弃了用命名模式 -jms.xml 标识的私有 JMS 资源部署描述符文件。下面是一个 JBoss EAP 6 的 JMS 资源部署描述符示例。

<?xml version="1.0" encoding="UTF-8"?>
<messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0">
  <hornetq-server>
    <jms-destinations>
      <jms-queue name="testQueue">
        <entry name="queue/test"/>
        <entry name="java:jboss/exported/jms/queue/test"/>
      </jms-queue>
      <jms-topic name="testTopic">
        <entry name="topic/test"/>
        <entry name="java:jboss/exported/jms/topic/test"/>
      </jms-topic>
    </jms-destinations>
  </hornetq-server>
</messaging-deployment>

在以前的版本里,如果您的应用程序使用了 -jms.xml JMS 部署描述符,您可以按照 Java EE 7 规格的 EE.5.18 章节转成使用标准 Java EE 7 部署描述符,或者升级部署描述符来使用 JBoss EAP 7 里的 messaging-activemq 子系统。

如果您选择更新描述符,您需要进行下列修改。

  • 修改命名空间 "urn:jboss:messaging-deployment:1.0" 为 "urn:jboss:messaging-activemq-deployment:1.0"。
  • 修改 <hornetq-server> 元素名为 <server>

修改后的文件应该类似于下面的例子。

<?xml version="1.0" encoding="UTF-8"?>
<messaging-deployment xmlns="urn:jboss:messaging-activemq-deployment:1.0">
  <server>
    <jms-destinations>
      <jms-queue name="testQueue">
        <entry name="queue/test"/>
        <entry name="java:jboss/exported/jms/queue/test"/>
      </jms-queue>
      <jms-topic name="testTopic">
        <entry name="topic/test"/>
        <entry name="java:jboss/exported/jms/topic/test"/>
      </jms-topic>
    </jms-destinations>
  </server>
</messaging-deployment>

关于和消息相同相关的服务器配置修改,请参考 Messaging Server Configuration Changes

5.3.2. 更新外部的 JMS 客户

JBoss EAP 7 仍支持 JMS 1.1 API,所以您不需要修改您的代码。

JBoss EAP 7 修改了默认的远程连接器和端口。关于这种改动的细节,请参考更新远程 URL 连接器和端口

如果您用 migrate 操作移您的服务器配置,旧的设置将被保留,您不需要更新 PROVIDER_URL。然而,如果您用新的 JBoss EAP 7 的默认配置来运行,您必须在客户代码里修改 PROVIDER_URL 并使用新的 http-remoting://localhost:8080 设置。更多信息请参考迁移远程命名客户代码

如果您计划将您的代码迁移至 JMS 2.0 API,请参考 helloworld-jms quickstart 里的用法。

5.3.3. 替代 HornetQ API

JBoss EAP 6 包含 org.hornetq 模块,它允许您在代码里使用 HornetQ API

JBoss EAP 7 里 Apache ActiveMQ Artemis 替代了 HornetQ,所以您必须迁移任何使用 HornetQ API 的代码,使其使用 Apache ActiveMQ Artemis API。这个 API 库包含在 org.apache.activemq.artemis 模块里。

ActiveMQ Artemis 是 HornetQ 的演化版本,所以许多概念仍然适用。

5.4. JAX-RS 和 RESTEasy 应用程序的修改

之前的 JBoss EAP 版本捆绑了实现 JAX-RS 1.x 的 RESTEasy 2。JBoss EAP 7 附带实现 JAX-RS 2.0(由 JSR 339: JAX-RS 2.0: The Java API for RESTful Web Services 规格定义)的 RESTEasy 3。关于用于 RESTful Web Service 的 Java API 的更多信息,请参考 JAX-RS 2.0 API 规格

JBoss EAP 7 里包含的 Jackson 版本已有改变。之前的 JBoss EAP 包含的是 Jackson 1.9.9,而 JBoss EAP 7 现在包含 Jackson 2.6.3 或更高的版本。

This section describes how these changes might impact applications that use RESTEasy or JAX-RS.

5.4.1. RESTEasy 已舍弃的类

Interceptor 和 MessageBody 类

JSR 311: JAX-RS: The Java™ API for RESTful Web Services did not include an interceptor framework, so RESTEasy 2 provided one. JSR 339: JAX-RS 2.0: The Java API for RESTful Web Services introduced an official interceptor and filter framework, so the interceptor framework included in RESTEasy 2 is now deprecated, and is replaced by the JAX-RS 2.0 compliant interceptor facility in RESTEasy 3.x. The relevant interfaces are defined in the javax.ws.rs.ext package of the jaxrs-api module.

注意

之前 RESTEasy 版本的所有拦截器都可以和新的 JAX-RS 2.0 过滤器和拦截器接口并行运行。

For more information about interceptors, see RESTEasy Interceptors in Developing Web Services Applications for JBoss EAP.

关于新的替代 API 的更多信息,请参考 RESTEasy JAX-RS 3.0.13.Final API 或更新的版本。

Client API

resteasy-jaxrs 里的 RESTEasy 客户框架已被兼容 JAX-RS 2.0 的 resteasy-client 模块替代。因此,某些 RESTEasy Client API 类和方法已被舍弃。

注意

关于 org.jboss.resteasy.client.jaxrs API 类的更多信息,请参考 RESTEasy JAX-RS JavaDoc

StringConverter

RESTEasy 3.x 已舍弃了 org.jboss.resteasy.spi.StringConverter 类。这个功能可以用 JAX-RS 2.0 jax.ws.rs.ext.ParamConverterProvider 类替代。

5.4.2. 已删除或变成 protected 权限的 RESTEasy 类

ResteasyProviderFactory 的 Add 系列方法

在 RESTEasy 3.0 里,大部分 org.jboss.resteasy.spi.ResteasyProviderFactory add() 方法已被删除或权限变为 protected。例如,addBuiltInMessageBodyReader{}addBuiltInMessageBodyWriter() 方法已被删除而 addMessageBodyReader()addMessageBodyWriter() 方法的权限已变成 protected。

现在您应该使用 registerProvider()registerProviderInstance() 方法。

RESTEasy 3 里删除的其他类

指定 JAX-RS 方法的响应应该在服务器上缓存的 @org.jboss.resteasy.annotations.cache.ServerCached 注解,已从 RESTEasy 3 删除且必须从应用程序代码里删除。

5.4.3. 其他 RESTEasy 修改

SignedInput 和 SignedOuput
  • 用于 resteasy-cryptoSignedInputSignedOutput 必须将 RequestResponse 对象里的 Content-Type 设置为 multipart/signed,或者使用 @Consumes@Produces 注解。
  • 通过在 @Produces@Consumes 注解里设置 application/pkcs7-signature MIME 类型,SignedOutputSignedInput 可以用来以二进制形式返回 "application/pkcs7-signature" MIME 类型。
  • 如果 @Produces@Consumestext/plain MIME 类型,SignedOutput 将用 base64 编码并作为 String 发送。
安全过滤器

@RolesAllowed@PermitAll@DenyAll 的安全过滤器现在返回 "403 Forbidden" 而不是 "401 Unauthorized"。

客户端过滤器

当您使用之前版本的 RESTEasy client API 时,新的 JAX-RS 2.0 客户端过滤器不会被绑定和运行。

对异步 HTTP 的支持

Because the JAX-RS 2.0 specification adds asynchronous HTTP support using the @Suspended annotation and the AsynResponse interface, the RESTEasy proprietary API for asynchronous HTTP has been deprecated and might be removed as soon as RESTEasy 3.1. The asynchronous Tomcat and asynchronous JBoss Web modules have also been removed from the server installation. If you are not using the Servlet 3.0 container or higher, asynchronous HTTP server-side processing will be simulated and run synchronously in same request thread.

服务器端的缓存

服务器端的缓存设置已经改变,更多信息请参考 RESTEasy Documentation

5.4.4. 对 RESTEasy SPI 的修改

SPI 异常

我们已舍弃所有的 SPI 失败异常,不再在内部使用它们。它们已被对应的JAX-RS 2.0 异常所替代。

已舍弃的异常jaxrs-api 模块里的替代异常

org.jboss.resteasy.spi.ForbiddenException

javax.ws.rs.ForbiddenException

org.jboss.resteasy.spi.MethodNotAllowedException

javax.ws.rs.NotAllowedException

org.jboss.resteasy.spi.NotAcceptableException

javax.ws.rs.NotAcceptableException

org.jboss.resteasy.spi.NotFoundException

javax.ws.rs.NotFoundException

org.jboss.resteasy.spi.UnauthorizedException

javax.ws.rs.NotAuthorizedException

org.jboss.resteasy.spi.UnsupportedMediaTypeException

javax.ws.rs.NotSupportedException

InjectorFactory 和 Registry

InjectorFactoryRegistry SPI 已有改动。如果您按照文档和支持来使用 RESTEasy,这不应该成为问题。

5.4.5. Jackson 提供者的变动

JBoss EAP 7 里包含的 Jackson 版本已有改变。之前的 JBoss EAP 包含的是 Jackson 1.9.9,而 JBoss EAP 7 现在包含 Jackson 2.6.3 或更高的版本。因此,Jackson 提供者已从 resteasy-jackson-provider 变为 resteasy-jackson2-provider

升级至 resteasy-jackson2-provider 要求修改一些软件包。例如,Jackson 注解软件包已从 org.codehaus.jackson.annotate 改成 com.fasterxml.jackson.annotation

To switch your application to use the default provider that was included in the previous release of JBoss EAP, see Switching the Default Jackson Provider in Developing Web Services Applications for JBoss EAP.

5.4.6. Spring RESTEasy 集成的修改

Spring 4.0 框架引入了对 Java 8 的支持。如果您计划集成 RESTEasy 3.x 和 Spring,请确保在部署里指定最低的 Spring 版本为 4.2.x,因为这是 JBoss EAP 7 支持的最早的稳定版本。

5.4.7. RESTEasy Jettison JSON 提供者的修改

JBoss EAP 7 已舍弃了 RESTEasy Jettison JSON 提供者,默认不再将其添加到部署里。我们鼓励您切换至我们推荐的 RESTEasy Jackson 提供者。如果您宁愿继续使用 Jettison 提供者,您必须在 jboss-deployment-descriptor.xml 文件里为其定义一个显性依赖关系,如下例所示。

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <exclusions>
      <module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
      <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
    </exclusions>
    <dependencies>
      <module name="org.jboss.resteasy.resteasy-jettison-provider" services="import"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

For more information about how to define explicit dependencies, see Add an Explicit Module Dependency to a Deployment in the JBoss EAP Development Guide.

5.5. CDI 1.2 应用程序的修改

JBoss EAP 7 includes support for CDI 1.2. As a result, applications written using CDI 1.0 might see some changes in behavior when migrated to JBoss EAP 7. This section summarizes only a few of those changes.

您可以在下列引用里找到关于 Weld 和 CDI 1.2 的更多信息:

Bean 归档

已启用的 bean 的 Bean 类必须部署在 bean 归档里以确保被 CDI 扫描并发现和处理 bean 类。

在 CDI 1.0 里,对于应用程序客户、EJB 或库 JAR,如果归档的 META-INF/ 目录包含了 beans.xml,或者是 WAR 的 WEB-INF/ 目录包含了 beans.xml 文件,这个就被定义为显性的 bean 归档。

CDI 1.1 引入了隐性的 bean 归档,也就是包含一个或多个带有 bean 定义注解 bean 类或者会话 bean 的归档。隐性的 bean 归档会被 CDI 扫描,在类型发现过程中,只有带有 bean 定义注解的类会被发现。详情请参考Java EE 平台的上下文和依赖关系注入里的类型和 Bean 的发现

Bean 归档具有 allannotatednone 发现模式。包含不带版本的 beans.xml 文件的 bean 归档的默认发现模式是 all。包含 1.1 或更高版本的 beans.xml 文件的 bean 归档必须指定 bean-discovery-mode 属性。这个属性的默认值是 annotated

在下列情况下归档不是 Bean 归档:

  • 它包含 bean-discovery-modenonebeans.xml 文件。
  • 它包含不带有 beans.xml 文件的 CDI 扩展。

在下列情况下归档是显性的 Bean 归档:

  • 归档包含版本为 1.1 或更高的 beans.xml 文件,且 bean-discovery-mode 模式为 all
  • 归档包含没有版本号的 beans.xml 文件。
  • 归档包含空的 beans.xml 文件。

在下列情况下归档是隐性的 Bean 归档:

  • 归档包含一个或多个带有 bean 定义注解 bean 类或者会话 bean,即使它没有包含 beans.xml 文件。
  • 归档包含 bean-discovery-modeannotatedbeans.xml 文件。

CDI 1.2 将 bean 定义注解限制为:

  • @ApplicationScoped@SessionScoped@ConversationScoped@RequestScoped 注解。
  • 所有其他的普通作用域类型
  • @Interceptor@Decorator 注解
  • 使用 @Stereotype 的所有原型注解
  • @Dependent 作用域注解

关于 Bean 归档的更多信息,请参考Java EE 平台的上下文和依赖关系注入里的 Bean 归档

会话解析(Conversation Resolution)的说明

会话上下文生命周期已被修改以防止和 CDI Specification Issue CDI-411 里描述的 Servlet 规格冲突。会话作用域在所有 Servlet 请求期间都时是活动的,它不应该阻止其他 Serlet 或 Servlet 过滤器设置请求主体或字符编码。

Observer 解析

CDI 1.2 已部分地重写了事件解析(Event resolution)。在 CDI 1.0 里,如果一个 observer 方法具有所有的事件限定符,事件将被递送给它。在 CDI 1.2 里,如果一个 observer 方法没有事件限定符或只有一个子集,事件将被递送给它。

5.6. 迁移显性模块依赖关系

之前 JBoss EAP 版本里引入模块化类加载系统和 JBoss Modules 允许对应用程序可用的类进行细颗粒度的控制。这个功能允许您用应用程序的 MANIFEST.MFjboss-deployment-structure.xml 部署描述符文件配置显性的模块依赖关系。

如果您在应用程序里定义了显性的模块依赖关系,您应该意识到 JBoss EAP 7 里下列的变化。

复查依赖关系的可用性

JBoss EAP 里包含的模块已经改动。当您迁移应用程序至 JBoss EAP 7 时,请复查您的 MANIFEST.MFjboss-deployment-structure.xml 文件以确保它们没有引用本版本已删除的模块。

要求注解扫描的依赖关系

在之前 JBoss EAP 版本里,如果依赖关系包含了在注解扫描时需要处理的注解,如声明 EJB 拦截器时,您会被要求在新的 JAR 文件里生成和包括 Jandex 索引并在 MANIFEST.MFjboss-deployment-structure.xml 部署描述符文件里设置一个标记。

JBoss EAP 7 现在为静态模块提供了注解索引的运行时自动生成,所以您不再需要手动生成它们。然而,您仍需要添加 annotations 标记到应用程序的 MANIFEST.MFjboss-deployment-structure.xml 文件(如下所示)。

MANIFEST.MF 文件里的注解标记示例

Dependencies: com.company.my-ejb annotations, com.company.other

jboss-deployment-structure.xml 文件里的注解标记示例

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="com.company.my-ejb" annotations="true"/>
      <module name="com.company.other"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

5.7. Hibernate 和 JPA 迁移的修改

5.7.1. Hibernate ORM 3.0

The integration classes that made it easier to use Hibernate ORM 3 in the previous release were removed from JBoss EAP 7. If your application still uses Hibernate ORM 3 libraries, it is strongly recommended that you migrate your application to use Hibernate ORM 5 as Hibernate ORM 3 will no longer work in JBoss EAP without a lot of effort. If you can not migrate to Hibernate ORM 5, you must define a custom JBoss Module for the Hibernate ORM 3 JARs and exclude the Hibernate ORM 5 classes from your application.

5.7.2. Hibernate ORM 4.0 - 4.3

If your application needs second-level cache enabled, you should migrate to Hibernate ORM 5, which is integrated with Infinispan 8.x.

Applications written with Hibernate ORM 4.x can still use Hibernate ORM 4.x. You must define a custom JBoss module for the Hibernate ORM 4.x JARs and exclude the Hibernate ORM 5 classes from your application. However, it is strongly recommended that you rewrite your application code to use Hibernate ORM 5. For information about migrating to Hibernate ORM 5, see Migrating to Hibernate ORM 5.

5.7.3. Hibernate ORM 5

If your application contains a persistence.xml file or the code uses the @PersistenceContext or @PersistenceUnit annotations, JBoss EAP 7 detects this during deployment and assumes the application uses JPA. It implicitly adds the Hibernate ORM 5 libraries plus a few other dependencies to your application class path and defaults to using these libraries.

5.7.4. Migrating to Hibernate ORM 5

This section highlights the changes you need to make when migrating from Hibernate ORM version 4.3 to version 5. For more information about the changes implemented between Hibernate ORM 4 and Hibernate ORM 5, see the Hibernate ORM 5.0 Migration Guide.

Removed and Deprecated Classes

The following deprecated classes were removed from Hibernate ORM 5.

Other Changes to Classes and Packages
Type Handling
  • Built-in org.hibernate.type.descriptor.sql.SqlTypeDescriptor implementations no longer auto-register themselves with org.hibernate.type.descriptor.sql.SqlTypeDescriptorRegistry. Applications using custom SqlTypeDescriptor implementations that extend the built-in implementations and rely on that behavior must be updated to call SqlTypeDescriptorRegistry.addDescriptor() themselves.
  • For IDs defined as generated UUIDs, some databases require you to explicitly set the @Column(length=16) in order to generate BINARY(16) so that comparisons work properly.
  • For EnumType mappings defined in the hbm.xml, where you want javax.persistence.EnumType.STRING name-mapping, this configuration must be explicitly stated by using either the useNamed(true) setting or by specifying a VARCHAR value of 12.
Transaction Management
Other Hibernate ORM 5 Changes
  • The cfg.xml files are again fully parsed and integrated with events, security, and other functions.
  • The properties loaded from the cfg.xml using the EntityManagerFactory did not previously prefix names with hibernate. This has now been made consistent.
  • The configuration is no longer serializable.
  • The org.hibernate.dialect.Dialect.getQuerySequencesString() method now retrieves catalog, schema, and increment values.
  • The AuditConfiguration modifier was removed from org.hibernate.envers.boot.internal.EnversService.
  • The AuditStrategy method parameters were changed to remove the obsolete AuditConfiguration and use the new EnversService.
  • Various classes and interfaces in the org.hibernate.hql.spi package and subpackages have been moved to the new org.hibernate.hql.spi.id package. This includes the MultiTableBulkIdStrategy class and the AbstractTableBasedBulkIdHandler, TableBasedDeleteHandlerImpl, and TableBasedUpdateHandlerImpl interfaces and their subclasses.
  • There was a complete redesign of property access contracts.
  • Valid hibernate.cache.default_cache_concurrency_strategy setting values are now defined using the org.hibernate.cache.spi.access.AccessType.getExternalName() method rather than the org.hibernate.cache.spi.access.AccessType enum constants. This is more consistent with other Hibernate settings.

5.8. Hibernate Search 的修改

JBoss EAP 7 附带的 Hibernate Search 版本已被修改。之前版本的 JBoss EAP 附带 Hibernate Search 4.6.x,而 JBoss EAP 7 附带 Hibernate Search 5.5.x。

Hibernate Search 5.5 is built upon Apache Lucene 5.3.1. If you use any native Lucene APIs, be sure to align with this version. The Hibernate Search 5.5 API wraps and hides the complexity of many of the Lucene API changes made between version 3 and version 5, however, some classes are now deprecated, renamed, or repackaged. This section describes how these changes might impact your application code.

Hibernate Search Mapping 的修改

内嵌关系的 ID 字段的索引

当使用 @IndexedEmbedded 注解来包含相关实体的字段时,相关实体的 id 字段不再被包含。您可以用 @IndexedEmbedded 注解的 includeEmbeddedObjectId 属性启用对 id 的包含。

@IndexedEmbedded(includeEmbeddedObjectId=true)
数字和日期索引格式的修改

数字和日期现在默认用数值型字段作为索引。intlongfloatdouble类型的属性及对应的 Wrapper 类都不再用字符串进行索引了。它们现在改为使用 Lucene 的数字编码来索引。id 字段是这个规则的一个例外。即使它们用数字类型来表达,它们的索引默认仍使用字符串键值。@NumericField 现在已废弃,除非您希望为数字编码定制精度。您可以通过制定一个字符串编码的字段桥(field bridge)来保留旧的基于字符串的索引格式。对于整型,它就是 org.hibernate.search.bridge.builtin.IntegerBridge。关于其他可用的公用字段桥,请参考org.hibernate.search.bridge.builtin软件包。

DateCalendar 不再以字符串为索引。它们改为用长整型来代表自 1970 年 1 月1 日 00:00:00 GMT 以来的毫秒数。您可以用新的EncodingType 枚举来切换索引格式。例如:

@DateBridge(encoding=EncodingType.STRING)
@CalendarBridge(encoding=EncodingType.STRING)

数字和日期的编码修改是很重要的,这对应用程序的行为有重大影响。如果以字段为目标的查询之前是用字符串编码,而现在是数字编码,您就必须更新这个查询。数字型的字段必须用 NumericRangeQuery 进行搜索。您也必须确保所有按目标分类的字段都是用字符串编码的。如果您使用 Search 查询 DSL,正确的查询应该会自动创建。

其他的 Hibernate Search 修改

  • 我们改进了排序选项,排序选项的错误字段编码现在会导致 runtime 异常抛出。如果预先知道排序使用的字段,Lucene 也提供了更高性能的排序方式。Hibernate Search 5.5 提供了新的 @SortableField 注解及其多值选项 @SortableFields。更多信息请参考《从 Hibernate Search 5.4 到 5.5 的迁移指南》
  • Lucene SortField API 要求进行下列程序代码的修改。

    在以前的 JBoss EAP 6 版本里,您可以像下面这样设置排序字段的类型。

    fulltextQuery.setSort(new Sort(new SortField("title", SortField.STRING)));

    下面是在 JBoss EAP 7 进行设置的例子。

    fulltextQuery.setSort(new Sort(new SortField("title", SortField.Type.STRING)));
  • 既然 SearchFactory 只应被 ORM 集成使用,它从 hibernate-search-engine 模块移至 hibernate-search-orm 模块。其他集成应该专门地依赖于 SearchIntegrator,它替代了已舍弃的 SearchFactoryIntegrator
  • 枚举值 SpatialMode.GRID 被重命名为 SpatialMode.HASH
  • FullTextIndexEventListener 现在是 final 类。如果您目前继承了这个类,您必须找到替代方案来实现相同的功能。
  • hibernate-search-analyzers 模块已删除。我们推荐的方法是直接使用合适的 Lucene 工件,例如 org.apache.lucene:lucene-analyzers-common
  • The JMS controller API has changed. The JMS back-end dependency on Hibernate ORM was removed so that it could be used in other non-ORM environments. A consequence is that implementors of org.hibernate.search.backend.impl.jms.AbstractJMSHibernateSearchController must adjust to the new signature. This class is an internal class and it is recommended to use it as an example instead of extending it.
  • org.hibernate.search.spi.ServiceProvider SPI 已被重构。如果您要集成旧的服务合约,新合约的细节请参考 ServiceManagerServiceStartableStoppableHibernate Search 5.5 Javadoc
  • 如果您已保留了 Lucene 3.x 生成的索引且没有用 Hibernate Search 5.0 或更新的版本进行重构,您将遇到 IndexFormatTooOldException。我们推荐您用 mass indexer 重构索引。如果您不能这样做,请试图使用 Lucene 的 IndexUpgrader。如果默认行为已修改,您必须小心地更新 Hibernate Search 映射。更多的信息请参考《Apache Lucene 迁移指南》
  • JBoss EAP 7 已将 Apache Lucene 升级为 3.6 到 5.3。如果您的代码直接导入了 Lucene 代码,相关细节请参考《Apache Lucene 迁移指南》。其他信息可以在 Lucene 更新日志里找到。
  • 当使用 @Field(indexNullAs=) 来对索引里的空 marker 值编码时,这个 marker 的类型必须和在相同字段里其他索引值兼容。例如,之前可能对数值型字段用字符串 "null" 编码空的值。现在这是不允许的。相反,您必须选择一个数字来表示 null 值,如 -1
  • 我们对 faceting 引擎进行了重大改进。多数改动不会影响 API。一个值得注意的例外是您必须注解任何要用 @Facet@Facets 注解进行 faceting 的字段。

Hibernate Search 重命名和重打包的类

下面是被重新打包或重命名的 Hibernate Search 类的列表。

之前的软件包和类新的软件包和类

org.hibernate.search.Environment

org.hibernate.search.cfg.Environment

org.hibernate.search.FullTextFilter

org.hibernate.search.filter.FullTextFilter

org.hibernate.search.ProjectionConstants

org.hibernate.search.engine.ProjectionConstants

org.hibernate.search.SearchException

org.hibernate.search.exception.SearchException

org.hibernate.search.Version

org.hibernate.search.engine.Version

Lucene - 重命名和重打包的类

查询解析器已移至新的模块,所在软件包从 org.apache.lucene.queryParser.QueryParser 改为 org.apache.lucene.queryparser.classic.QueryParser

许多 Lucene 分析器都已重构,导致软件包的变动。要寻找替代的软件包,请查看 Apache Lucene 文档

某些 Apache Solr 工具类,如 TokenizerFactoryTokenFilterFactory,都已移至 Apache Lucence。如果您的应用程序使用了这些工具或自定义的分析器,您必须找到 Apache Lucene 里新的软件包名称。

更多的信息请参考《Apache Lucene 迁移指南》

Hibernate Search 已舍弃的 API

关于 Hibernate Search 已舍弃的接口、类、枚举、注解类型、方法、构造器和枚举常量的完整列表,请参考 Hibernate Search 已舍弃的 API 文档

Hibernate Search 已舍弃的接口
接口描述

org.hibernate.search.store.IndexShardingStrategy

从 Hibernate Search 4.4 开始已舍弃,可能在 Search 5 里删除。现在请使用 ShardIdentifierProvider

org.hibernate.search.store.Workspace

This interface will be moved and should be considered non-public API. For more information, see HSEARCH-1915.

Hibernate Search 已舍弃的类
描述

org.hibernate.search.filter.FilterKey

自定义的过滤器键已舍弃且在 Hibernate Search 6 里将被删除。从 Hibernate Search 5.1 开始,用于缓存 Lucene 过滤器的键将基于给定的过滤器参数自动计算。

org.hibernate.search.filter.StandardFilterKey

自定义的过滤器键已舍弃且在 Hibernate Search 6 里将被删除。从 Hibernate Search 5.1 开始,用于缓存 Lucene 过滤器的键将基于给定的过滤器参数自动计算。

Hibernate Search 已舍弃的枚举
枚举描述

org.hibernate.search.annotations.FieldCacheType

请删除已舍弃的 CacheFromIndex 注解。详情请参考Hibernate Search 已舍弃的注解

Hibernate Search 已舍弃的注解
注解描述

org.hibernate.search.annotations.CacheFromIndex

请删除这个注解,不需要其他接替者。

org.hibernate.search.annotations.Key

自定义的过滤器缓存键已舍弃且在 Hibernate Search 6 里将被删除。从 Hibernate Search 5.1 开始,过滤器缓存键将基于过滤器参数自动确定,所以不再需要提供键对象。

Hibernate Search 已舍弃的方法
方法描述

org.hibernate.search.FullTextSharedSessionBuilder.autoClose()

没有接替者

org.hibernate.search.FullTextSharedSessionBuilder.autoClose(boolean)

没有接替者

org.hibernate.search.cfg.IndexedMapping.cacheFromIndex(FieldCacheType…​)

它将被删除且没有接替者。

org.hibernate.search.cfg.EntityDescriptor.getCacheInMemory()

它将被删除且没有接替者。

org.hibernate.search.cfg.ContainedInMapping.numericField()

请改为调用 field().numericField()

org.hibernate.search.cfg.EntityDescriptor.setCacheInMemory(Map<String, Object>)

它将被删除且没有接替者。

org.hibernate.search.MassIndexer.threadsForSubsequentFetching(int)

这个方法将被删除。

org.hibernate.search.query.dsl.FuzzyContext.withThreshold(float)

请使用 FuzzyContext.withEditDistanceUpTo(int)

Hibernate Search 已舍弃的构造器
构造器描述

org.hibernate.search.cfg.NumericFieldMapping(PropertyDescriptor, EntityDescriptor, SearchMapping)

请改为使用 NumericFieldMapping.NumericFieldMapping(String, PropertyDescriptor, EntityDescriptor, SearchMapping)

影响高级集成器的修改

本节描述了非公用 API 的修改。它们不应该影响普通开发人员,因为这些工件只应该由继承 Hibernate Search 框架的集成者访问。

5.9. 迁移 Entity Bean 至 JPA

Java EE 7 对 EJB Entity Bean 的支持是可选的,它们不再受到支持。这意味着迁移到 JBoss EAP 7 时,您必须重写 CMP(container-managed persistence)和 BMP(bean-managed persistence)来使用 Java Persistence API (JPA) 实体。

在以前的 JBoss EAP 版本里,Entity Bean 是通过应用程序代码继承 javax.ejb.EntityBean 类并实现所需方法来创建的。它们然后在 ejb-jar.xml 文件里进行配置,CMP Entity Bean 用包含值为 Container<persistence-type> 子元素的 <entity> 元素来指定。BMP entity bean 用包含值为 Bean 的子元素 <persistence-type><entity> 元素来指定。

在 JBoss EAP 7 里,您必须用 Java Persistence API (JPA) 实体替换任何 CMP 和 BMP Entity Bean。JPA 实体使用 javax.persistence.* 类创建并在 persistence.xml 文件里定义的。

下面是一个 JPA 实体类示例。

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
// User is a keyword in some SQL dialects!
@Table(name = "MyUsers")
public class MyUser {
    @Id
    @GeneratedValue
    private Long id;

    @Column(unique = true)
    private String username;
    private String firstName;
    private String lastName;

    public Long getId() {
        return id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

下面是一个 persistence.xml 文件示例。

<persistence version="2.1"
      xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="my-unique-persistence-unit-name">
    <properties>
      // properties...
    </properties>
  </persistence-unit>
</persistence>

关于 JPA 实体的示例,请参考 JBoss EAP 7 附带的 bmtcmthibernate5 Quickstarts 例程。

5.10. JPA 持久化属性的修改

我们添加了新的持久性属性 jboss.as.jpa.deferdetach 来提供对之前版本的 JBoss EAP 里的持久性行为的支持。

jboss.as.jpa.deferdetach 属性控制每次 EntityManager 调用后非 JTA 事务线程里使用的事务作用域的持久化上下文是否分离加载的实体,或者等待至持久化上下文关闭。例如,当 Session Bean 调用结束时。这个属性值默认是 false,表示实体在每次 EntityManager 调用后被分离或清除。这是 JPA 规格里定义的正确的默认行为。如果属性被设置为 true,实体在持久化上下文关闭前不会被分离。

在 JBoss EAP 5 里,持久化的行为就像将 jboss.as.jpa.deferdetach 属性设置为 true 一样。要在迁移至 JBoss EAP 7 时获得相同的行为,您必须在 persistence.xml 里将 jboss.as.jpa.deferdetach 属性设置为 true,如下例所示。

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="EAP5_COMPAT_PU">
    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
    <properties>
         <property name="jboss.as.jpa.deferdetach" value="true" />
    </properties>
  </persistence-unit>
</persistence>

在 JBoss EAP 6 里,持久化的行为就像将 jboss.as.jpa.deferdetach 属性设置为 false 一样。这在 JBoss EAP 7 里是相同的,所以迁移应用程序时不需要进行修改。

5.11. 迁移 EJB 客户代码

JBoss EAP 7 修改了默认的远程连接器和端口。关于这种改动的细节,请参考更新远程 URL 连接器和端口

如果您使用了 migrate 操作来迁移服务器配置,旧的设置将被保留,您不需要修改下面的细节。然而,如果您用新的 JBoss EAP 7 默认配置运行,您必须进行下列修改。

5.11.1. 更新默认的远程连接端口

jboss-ejb-client.properties 文件里将远程连接端口值从 4447 改为 8080

下面是之前和当前版本里的 jboss-ejb-client.properties 文件示例。

示例:JBoss EAP 6 jboss-ejb-client.properties 文件

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

示例:JBoss EAP 7 jboss-ejb-client.properties 文件

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

5.11.2. 更新默认的连接器

如果您使用新的 JBoss EAP 7 配置运行,默认的连接器已从 remote 改为 http-remoting。这次改动影响了使用某个版本里的库并连接不同版本的服务器的客户。

  • 如果客户应用程序使用 JBoss EAP 6 里的 EJB 客户库并希望连接至 JBoss EAP 7 服务器,您必须配置服务器通过 8080 之外的端口开放 remote 连接器。然后客户必须使用新配置的连接器进行连接。
  • 使用 JBoss EAP 7 里的 EJB 客户库并希望连接至 JBoss EAP 6 服务器的客户应用程序必须意识到服务器实例没有使用 http-remoting 而是 remoting 连接器。这是通过定义新的客户端连接属性来实现的。

    remote.connection.default.protocol=remote

5.11.3. 迁移远程命名客户代码

如果您用新的默认 JBoss EAP 7 配置运行,你必须修改客户代码以使用新的默认远程端口和连接器。

下面是 JBoss EAP 6 里如何在客户代码里指定远程命名属性的例子。

java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447

下面是 JBoss EAP 7 里如何在客户代码里指定远程命名属性的例子。

java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=http-remoting://localhost:8080

5.12. 迁移部署计划配置

The Java EE Application Deployment specification (JSR-88) was intended to define a standard contract to enable tools from multiple providers to configure and deploy applications on any Java EE platform product. The contract required Java EE Product Providers to implement the DeploymentManager and other javax.enterprise.deploy.spi interfaces to be accessed by the Tool Providers. In case of JBoss EAP 6, a deployment plan is identified by an XML descriptor named deployment-plan.xml that is bundled in a ZIP or JAR archive.

我们已很少采用这个规格,因为多数应用服务器产品提供了自己更“功能丰富”的部署方案。出于这个原因,Java EE 7 取消了对 JSR-88 的支持,所以 JBoss EAP 7 也不再支持。

If you used JSR-88 to deploy your application, you must now use another method to deploy the application. The JBoss EAP management CLI deploy command provides a standard way to deploy archives to standalone servers or to server groups in a managed domain. For more information about the management CLI, see the Management CLI Guide.

5.13. 迁移自定义应用程序阀

您必须手动迁移自定义阀或任何在 jboss-web.xml XML 文件里定义的阀。这包含通过继承 org.apache.catalina.valves.ValveBase 类创建以及在 jboss-web.xml 描述符文件的 <valve> 元素里配置的阀。

重要

自定义阀和 jboss-web.xml 文件里定义的阀必须被重写或用对应的 Undertow 内置处理程序替代。关于映射阀到 Undertow 处理程序的更多信息,请参考迁移 JBoss Web 阀

验证阀必须用 Undertow 内嵌的验证机制手动替换。

迁移部署里配置的阀

在 JBoss EAP 6,您可以在 jboss-web.xml 描述符文件里进行配置来定义应用程序级别的自定义阀。而在 JBoss EAP 7 里,您可以用 Undertow 处理程序来实现。

下面是 JBoss EAP 6 里的 jboss-web.xml 文件配置的阀的示例。

<jboss-web>
    <valve>
        <class-name>org.jboss.examples.MyValve</class-name>
​        <param>
    ​        <param-name>myParam</param-name>
​            <param-value>foobar</param-value>
    ​    </param>
    </valve>
</jboss-web>

For more information about how to create and configure custom handlers in JBoss EAP, see Creating Custom Handlers in the JBoss EAP Development Guide.

迁移自定义验证器阀

关于如何迁移验证器阀的信息,请参考安全性应用程序的修改

5.14. 安全性应用程序的修改

用 Undertow 替代 JBoss Web 要求修改 JBoss EAP 7 的安全性配置。

5.14.1. 迁移

验证器阀(Authenticator Valve)必须用 Undertow 内置的验证机制手动替代。关于如何迁移验证器阀的信息,请阅读下面的章节。

5.14.3. 其他安全性应用程序的修改

For information about the differences in SSO configuration with Kerberos, see Differences from Configuring Previous Versions JBoss EAP in How to Set Up SSO with Kerberos for JBoss EAP.

5.15. JBoss Logging 的修改

如果您的应用程序使用了 JBoss Logging,请注意 JBoss EAP 7 已舍弃在 org.jboss.logging 软件包里进行注解。它们被移至 org.jboss.logging.annotations 软件包,所以您必须更新源码来导入新的软件包。

这些注解也已移至单独的 Maven groupId:artifactId:version (GAV) ID,所以您需要在 pom.xml 文件里为 org.jboss.logging:jboss-logging-annotations 添加一个新的依赖关系。

注意

只移动了日志注解。org.jboss.logging.BasicLoggerorg.jboss.logging.Logger 仍存在于 org.jboss.logging 软件包里。

下表列出已舍弃的注解类和对应的接替者。

表 5.1. 已舍弃的 Logging 注解的接替者

已舍弃的类替代的类

org.jboss.logging.Cause

org.jboss.logging.annotations.Cause

org.jboss.logging.Field

org.jboss.logging.annotations.Field

org.jboss.logging.FormatWith

org.jboss.logging.annotations.FormatWith

org.jboss.logging.LoggingClass

org.jboss.logging.annotations.LoggingClass

org.jboss.logging.LogMessage

org.jboss.logging.annotations.LogMessage

org.jboss.logging.Message

org.jboss.logging.annotations.Message

org.jboss.logging.MessageBundle

org.jboss.logging.annotations.MessageBundle

org.jboss.logging.MessageLogger

org.jboss.logging.annotations.MessageLogger

org.jboss.logging.Param

org.jboss.logging.annotations.Param

org.jboss.logging.Property

org.jboss.logging.annotations.Property

5.16. JavaServer Faces (JSF) 代码的修改

取消对 JSF 1.2 的支持

JBoss EAP 6 允许您通过创建 jboss-deployment-structure.xml 文件继续使用 JSF 1.2。

JBoss EAP 7 包含 JSF 2.2 且不再支持 JSF 1.2 API。如果您的应用程序使用 JSF 1.2,您必须重写代码以使用 JSF 2.2。

JSF 2.1 和 JSF 2.2 间的兼容性问题

JSF 2.1 和 JSF 2.2 API 不是完全兼容的。FACELET_CONTEXT_KEY 常量从 com.sun.faces.facelets.FACELET_CONTEXT 改成了 javax.faces.FACELET_CONTEXT。编译器内联这个值,根据某个版本编译的代码将无法在其他版本里使用。

用 JSF 2.1 API 编译的包含和下面例子相似的代码的应用程序,如果在使用 JSF 2.2 API 的 JBoss EAP 7 里运行会导致 NullPointerException。要修复这个问题,您必须用 JSF 2.2 API 重新编译应用程序。

Object obj = FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);

详情请参考 JAVASERVERFACES_SPEC_PUBLIC-1257

5.17. 模块类加载的修改

在 JBoss EAP 7 里,多个模块包含相同的类或软件包时的类加载行为已修改。

假设有两个模块 MODULE_AMODULE_B,彼此依赖并包含一些相同的软件包。在 JBoss EAP 6 里,从依赖关系加载的类或软件包优先于 module.xml 文件的 resource-root 元素里指定的。这意味着 MODULE_A 可以看到 MODULE_B 的软件包而 MODULE_B 可以看到 MODULE_A 的软件包。这种行为让人困惑且可能导致冲突。而 JBoss EAP 7 已修改了这种行为。现在 module.xml 文件的 resource-root 元素指定的类或软件包优先于依赖关系所指定的。这意味着 MODULE_A 只可以看到 MODULE_A 的软件包而 MODULE_B 可以看到 MODULE_B 的软件包。这防止了冲突并提供了更合适的行为。

If you have defined custom modules that include resource-root libraries or packages that contain classes that are duplicated in their module dependencies, you might see ClassCastException, LinkageError, class loading errors, or other changes in behavior when you migrate to JBoss EAP 7. To resolve these issues, you must configure your module.xml file to ensure only one version of a class is used. This can be accomplished by using either of the following approaches.

  • 您可以避免指定在模块依赖关系里重复类的 resource-root
  • 您可以使用 importsexportsincludeexclude 子元素来控制 module.xml 文件里的类加载。下面是使用 export 元素排除指定软件包里的类的例子。

    <exports>
      <exclude path="com/mycompany/duplicateclassespath/"/>
    </exports>

如果您希望保留现有的行为,你必须通过 filter 元素在过滤 module.xml 文件里 resource-root 的依赖关系软件包。这允许您保留现有的行为而不会看到 JBoss EAP 6 里看到的奇怪的循环。下面是通过 root-resource 过滤指定软件包里的类的例子。

<resource-root path="mycompany.jar">
  <filter>
    <exclude path="com/mycompany/duplicateclassespath"/>
  </filter>
</resource-root>

For more information about modules and class loading, see Class Loading and Modules in the JBoss EAP Development Guide.

5.18. 应用程序群集的修改

5.18.1. 新的群集功能概述

下面描述了从 JBoss EAP 6 迁移至 JBoss EAP 7 时要注意的新的群集功能。

  • JBoss EAP 7 introduces a new public API for building singleton services that significantly simplifies the process. For more information, see Implement an HA Singleton in Developing EJB Applications for JBoss EAP.
  • A singleton deployment can be configured to deploy and start on only a single node in the cluster at a time. For more information, see HA Singleton Deployments in the JBoss EAP Development Guide.
  • You can now define clustered singleton MDBs. For more information, see Clustered Singleton MDBs in Developing EJB Applications for JBoss EAP.
  • JBoss EAP 7 includes the Undertow mod_cluster implementation. This offers a pure Java load balancing solution that does not require an httpd web server. For more information, see Configuring JBoss EAP as a Front-end Load Balancer in the JBoss EAP Configuration Guide.

The remainder of this section describes how clustering changes might impact the migration of your applications to JBoss EAP 7.

5.18.2. Web 会话群集的修改

JBoss EAP 7 引入了新的 Web 会话群集实现。它替代了之前和旧的 JBoss Web 子系统紧耦合的实现。

新的 Web 会话群集实现影响了如何在 jboss-web.xml 描述符文件里配置应用程序。下面是这个文件里保留的群集配置元素。

<jboss-web>
  ...
  <max-active-sessions>...</max-active-sessions>
  ...
  <replication-config>
    <replication-granularity>...</replication-granularity>
    <cache-name>...</cache-name>
  </replication-config>
  ...
</jboss-web>

下表描述了如何实现和 jboss-web.xml 里现已舍弃的元素类似的行为。

配置元素对修改的描述

<max-active-sessions/>

以前,如果活动会话的数量超过了 <max-active-sessions/> 指定的值,创建会话将会失败。

在新的实现里,<max-active-sessions/> 用于启用会话钝化。如果创建会话可能导致活动会话数量超过 <max-active-sessions/>,那么会话管理者已知的最老的会话将会钝化,为新的会话留出空间。

<passivation-config/>

JBoss EAP 7 不再使用这个配置元素及其子元素。

<use-session-passivation/>

以前,钝化是用这个属性启用的。

在新的实现里,钝化是通过为 <max-active-sessions/> 指定非负的值来启用的。

<passivation-min-idle-time/>

以前,会话在成为钝化候选者之前,需要处于活动状态一段最短的时间。这可能导致创建会话失败,即使已启用了钝化。

新的实现不支持这个逻辑,所以避免了拒绝服务(Denial of Service,DoS)漏洞。

<passivation-max-idle-time/>

以前,会话将处于空闲状态一段时间后将被钝化。

新的实现只支持 lazy 钝化。它不支持 eager 钝化。会话只有在需要遵从 <max-active-sessions/> 时才被钝化。

<replication-config/>

新的实现舍弃了大量的子元素。

<replication-trigger/>

Previously, this element was used to determine when session replication was triggered. The new implementation replaces this configuration option with a single, robust strategy. For more information, see Immutable Session Attributes in the JBoss EAP Development Guide.

<use-jk/>

以前,处理给定请求的节点的 instance-id 被附加到 jsessionid,根据 <use-jk/> 所指定的值,它用于不同的负载平衡器,如 mod_jk、mod_proxy_balancer、mod_cluster。

在新的实现里,如果定义了 instance-id,它总是附加到 jsessionid

<max-unreplicated-interval/>

以前,这个配置选项的目的是防止没有修改会话属性时会话时间戳的重复。虽然这听起来不错,但事实上它没有防止任何 RPC,因为无论是否修改了任何会话属性,访问会话都要求缓存事务 RPC。

在新的实现里,会话的时间戳在每次请求时进行复制。这防止了失效切换后的过时的会话元数据。

<snapshot-mode/>

Previously, one could configure <snapshot-mode/> as INSTANT or INTERVAL. Infinispan’s asynchronous replication makes this configuration option obsolete.

<snapshot-interval/>

它只和 <snapshot-mode>INTERVAL</snapshot-mode> 相关。既然 <snapshot-mode/> 已被舍弃,这个选项也已被舍弃。

<session-notification-policy/>

以前,这个属性指定的值定义了触发会话事件的策略。

在新的实现里,这个行为是规格驱动的且是不可配置的。

This new implementation also supports write-through cache stores as well as passivation-only cache stores. Typically, a write-through cache store is used in conjunction with an invalidation cache. The web session clustering implementation in JBoss EAP 6 did not operate correctly when used with an invalidation cache.

5.18.3. Stateful Session EJB 群集的修改

在 JBoss EAP 6 里,您被要求以下列方式之一启用 stateful session beans (SFSBs) 的群集行为。

  • 您可以在 session bena 里添加 org.jboss.ejb3.annotation.Clustered 注解。

    @Stateful
    @Clustered
    public class MyBean implements MySessionInt {
    
       public void myMethod() {
          //
       }
    }
  • 您可以将 <clustered> 元素添加到 jboss-ejb3.xml 文件里。

    <c:clustering>
      <ejb-name>DDBasedClusteredSFSB</ejb-name>
      <c:clustered>true</c:clustered>
    </c:clustering>

JBoss EAP 7 不再要求您启用群集行为。在默认情况下,如果服务器用 HA 配置集启动,SFSB 的状态将自动复制。

您可以用下列方式之一禁用默认的行为。

  • 您可以使用 EJB 3.2 规格里新的 @Stateful(passivationCapable=false) 来禁用单个 stateful session bean 的默认行为。
  • 你也可以通过服务器配置的 ejb3 子系统来在全局禁用这个行为。
注意

如果没有从应用程序里删除 @Clustered 注解,它会被忽略且不会影响到应用程序的部署。

5.18.4. 群集服务的修改

在 JBoss EAP 6,用于群集服务的 API 位于私有模块且不被支持。

JBoss EAP 7 引入了公用群集 API。新的服务被设计为轻量级的、易于注入的且没有外部依赖关系。

  • 新的 org.wildfly.clustering.group.Group 接口提供了对当前群集状态的访问并允许侦听群集成员的变动。
  • 新的 org.wildfly.clustering.dispatcher.CommandDispatcher 接口允许在群集、所有或选择的节点子集里运行代码。

这些服务替代了之前版本里类似的 API,也就是 JBoss EAP 5 的 HAPartition,JBoss EAP 6 里的 GroupCommunicationServiceGroupMembershipNotifierGroupRpcDispatcher

For more information, see Public API for Clustering Services in the JBoss EAP Development Guide.

5.18.5. 迁移群集 HA 单点登录

在 JBoss EAP 6 里,群集范围的 HA 单点登录服务没有可用的公用 API。如果您使用了私有 org.jboss.as.clustering.singleton.* 类,在迁移应用程序至 JBoss EAP 7 时,您必须修改代码以使用新的公用 org.wildfly.clustering.singleton.* 软件包。

For more information about how to implement an HA singleton, see HA Singleton Service in the Development Guide for JBoss EAP.

第 6 章 其他修改

6.1. 修改 JBoss EAP Natives 和 Apache HTTP 服务器的提供方式

这个版本里 JBoss EAP 7 Natives 的提供与之前不同,其中一些现在附带新的 Red Hat JBoss Core Services 产品,这是许多 Red Hat JBoss 中间件产品常用的一套补充软件。新产品提供了更快的更新分发和更一致的更新体验。JBoss Core Services 产品可以在 Red Hat 客户门户网站的不同位置来下载。

  • 下表列出了不同 JBoss EAP 版本的提供方式间不同之处。

    软件包JBoss EAP 6JBoss EAP 7

    用于消息处理的 AIO Natives

    和单独的 "Native Utilities" 下载里的产品一起提供

    包含在 JBoss EAP 里,不需要额外的下载。

    Apache HTTP 服务器

    和单独的 "Apache HTTP Server" 下载里的产品一起提供

    和新的 "JBoss Core Services" 产品一起提供

    mod_cluster、mod_jk、isapi 和 nsapi 连接器

    和单独的 "Webserver Connector Natives" 下载里的产品一起提供

    和新的 "JBoss Core Services" 产品一起提供

    JSVC

    和单独的 "Native Utilities" 下载里的产品一起提供

    和新的 "JBoss Core Services" 产品一起提供

    OpenSSL

    和单独的 "Native Utilities" 下载里的产品一起提供

    JBoss EAP 7 已舍弃它

    tcnatives

    和单独的 "Native Components" 下载里的产品一起提供

    JBoss EAP 7 已舍弃它

  • 您应该注意到下列变化:

    • 已停止对和 RHEL RPM 频道的 Apache HTTP 服务器一起使用的 mod_cluster 和 mod_jk 连接器的支持。如果您从 RHEL PRM 频道运行 Apache HTTP 服务器并需要平衡 JBoss EAP 7 服务器的负载,您可以使用下列方法之一:

      • 使用 JBoss Core Services 提供的 Apache HTTP 服务器。
      • You can configure JBoss EAP 7 to act as a front-end load balancer. For more information, see Configuring JBoss EAP as a Front-end Load Balancer in the JBoss EAP Configuration Guide.
      • You can deploy Apache HTTP Server on a machine that is supported and certified and then run the load balancer on that machine. For the list of supported configurations, see Overview of HTTP Connectors in the JBoss EAP 7 Configuration Guide.
    • 已停止对和 HP-UX Web Server Suites 的 Apache HTTP 服务器一起使用的 mod_cluster 和 mod_jk 连接器的支持。如果您从 HP-UX Web Server Suites 运行 Apache HTTP 服务器并需要平衡 JBoss EAP 7 服务器的负载,您可以使用下列方法之一:

      • You can configure JBoss EAP 7 to act as a front-end load balancer. For more information, see Configuring JBoss EAP as a Front-end Load Balancer in the JBoss EAP Configuration Guide.
      • You can deploy Apache HTTP Server on a machine that is supported and certified and then run the load balancer on that machine. For the list of supported configurations, see Overview of HTTP Connectors in the JBoss EAP Configuration Guide.
  • You can find more information about JBoss Core Services in the Apache HTTP Server Installation Guide.

6.2. 在 Amazon EC2 上部署的修改

A number of changes have been made to the Amazon Machine Images (AMI) in JBoss EAP 7. This section briefly summarizes some of those changes.

  • 在 Amazon EC2 里启动非群集和群集的 JBoss EAP 实例和域已进行重大修改。
  • JBoss EAP 6 将 User Data: 字段用于 JBoss EAP 配置。JBoss EAP 7 已删除解析 User Data: 字段配置及在实例启动时自动启动服务器的 AMI 脚本。
  • 以前的 JBoss EAP 版本安装了 Red Hat JBoss Operations Network 代理,而在 JBoss EAP 7 里,您需要单独安装它。

For details on deploying JBoss EAP 7 on Amazon EC2, see Deploying Red Hat JBoss Enterprise Application Platform on Amazon EC2.

6.3. Changes to JBoss EAP Scripts

The add-user script behavior has changed in JBoss EAP 7 due to a change in password policy. JBoss EAP 6 had a strict password policy. As a result, the add-user script rejected weak passwords that did not satisfy the minimum requirements. In JBoss EAP 7, weak passwords are accepted and a warning is issued. For more information, see Setting Add-User Utility Password Restrictions in the JBoss EAP Configuration Guide.

6.4. Removal of OSGi Support

When JBoss EAP 6.0 GA was first released, JBoss OSGi, an implementation of the OSGi specification, was included as a Technology Preview feature. With the release of JBoss EAP 6.1.0, JBoss OSGi was demoted from Technology Preview to Unsupported.

In JBoss EAP 6.1.0, the configadmin and osgi extension modules and subsystem configuration for a standalone server were moved to a separate EAP_HOME/standalone/configuration/standalone-osgi.xml configuration file. Because you should not migrate this unsupported configuration file, the removal of JBoss OSGi support should not impact the migration of a standalone server configuration. If you modified any of the other standalone configuration files to configure osgi or configadmin, those configurations must be removed.

For a managed domain, the osgi extension and subsystem configuration were removed from the EAP_HOME/domain/configuration/domain.xml file in the JBoss EAP 6.1.0 release. However, the configadmin module extension and subsystem configuration remain in the EAP_HOME/domain/configuration/domain.xml file. This configuration is no longer supported in JBoss EAP 7 and must be removed.

第 7 章 Migrating from Older Releases of JBoss EAP

7.1. Migrating from JBoss EAP 5 to JBoss EAP 7

This guide focuses on the changes that are required to successfully run and deploy JBoss EAP 6 applications on JBoss EAP 7. If you plan to migrate your applications directly from JBoss EAP 5 to JBoss EAP 7, there are a number of resources available to help you plan and execute your migration. We suggest you take the following approach.

  1. See Summary of Changes Made to Each Release in this guide for a quick, high-level overview of the changes made to each release of JBoss EAP.
  2. Read through the JBoss EAP 6 Migration Guide and this guide to become familiar with the contents of each one.
  3. Use the JBoss EAP 5 Component Upgrade Reference as a quick reference to migration information about specific components and features.
  4. The Windup rule-based migration tool continues to add rules to help you migrate directly from JBoss EAP 5 to JBoss EAP 7. You can use this tool to analyze your application and to generate detailed reports about the changes needed to migrate to JBoss EAP 7. For more information, see Use Windup to Analyze Applications for Migration.
  5. The Customer Portal Knowledgebase currently contains articles and solutions to help with migration from JBoss EAP 5 to JBoss EAP 6. There are plans in place to add additional content for migration from JBoss EAP 5 to JBoss EAP 7 over time.

7.2. Summary of Changes Made to Each Release

Before you plan your migration, you should be aware of the changes that were made to JBoss EAP 6 and JBoss EAP 7.

The JBoss EAP 6 Migration Guide covers changes that were made between JBoss EAP 5 and JBoss EAP 6. The following is a condensed list of the most significant changes made in JBoss EAP 6.

  • Implemented a new architecture built on the Modular Service Container
  • Was a certified implementation of the Java Enterprise Edition 6 specification
  • Introduced domain management, new deployment configuration, and a new file directory structure and scripts
  • Standardized on new portable JNDI namespaces

See Review What’s New and Different in JBoss EAP 6 in the JBoss EAP 6 Migration Guide for a detailed list of changes made in that release.

JBoss EAP 7 is built on the same modular structure as JBoss EAP 6 and includes the same domain management, deployment configuration, file directory structure, and scripts. It also still uses the same standardized JNDI namespaces. However, JBoss EAP 7 introduces the following changes.

  • Adds support for the Java Enterprise Edition 7 specification
  • Replaces the web server with Undertow
  • Replaces the JacORB IIOP implementation with a downstream branch of the OpenJDK ORB
  • Includes Apache ActiveMQ Artemis as the new messaging provider
  • Removes the cmp, jaxr, and threads subsystems
  • Removes support for EJB entity beans

For a more complete list of changes, see Review What’s New in JBoss EAP 7

7.3. Review the Content in the Migration Guides

Review the entire contents of the Migration Guide for each release to become aware of the features that were added or deprecated, and to understand the server configuration and the application changes required to run existing applications for that release.

Because the underlying architecture was not changed between JBoss EAP 6 and JBoss EAP 7, many of the changes documented in the JBoss EAP 6 Migration Guide still apply. For example, changes documented under Changes Required by Most Applications are related to the underlying architectural changes made in JBoss EAP 6, which still apply to this release. The change to the new modular class loading system is significant and impacts the packaging and dependencies of almost every JBoss EAP 5 application. Many of the changes listed under Changes Dependent on Your Application Architecture and Components are also still valid. However, because JBoss EAP 7 replaced the web server, ORB, and messaging provider, removed the cmp, threads, and jaxr subsystems, and removed support for EJB entity beans, you must consult this guide for any changes related to those component areas. Pay particular attention to the Server Configuration Changes and Application Migration Changes detailed in this guide before you begin.

7.4. JBoss EAP 5 Component Upgrade Reference

Use the following table to find information about how to migrate a particular feature or component from JBoss EAP 5 to JBoss EAP 7.

JBoss EAP 5
Feature or Component
Summary of Changes and
Where to Find Migration Information

Application Packaging and Class Loading

In JBoss EAP 6, the previous hierarchical class loading structure was replaced with a modular architecture based on JBoss Modules. Application packaging also changed due to the new modular class loading structure. This architecture is still used in JBoss EAP 7. For information about the new modular architecture, see the following chapter in the JBoss EAP 7 Development Guide.

For information about how to update and repackage applications for the new modular architecture, see the following section in the JBoss EAP 6 Migration Guide.

Application Configuration Files

Due to the changes in JBoss EAP 6 to use modular class loading, you might need to create or modify one or more application configuration files to add dependencies or to prevent automatic dependencies from loading. This has not changed in JBoss EAP 7. For details, see the following section in the JBoss EAP 6 Migration Guide.

Caching and Infinispan

JBoss Cache was replaced by Infinispan for internal use by the server only in JBoss EAP 6. See the following sections in the JBoss EAP 6 Migration Guide for information about how to replace JBoss Cache in application code.

Infinispan caching strategy and configuration changes for JBoss EAP 7 are documented in the following section of this guide.

Data Sources and Resource Adapters

JBoss EAP 6 consolidated configuration of data sources and resource adapters into mainly one file and this is still true in JBoss EAP 7. See the following section in the JBoss EAP 6 Migration Guide for more information.

In addition, the ability to configure a generic JMS resource adapter to connect to a JMS provider is no longer supported in JBoss EAP 7. See the following section in this guide.

Directory Structure, Scripts, and Deployment Configuration

In JBoss EAP 6, the directory structure, scripts, and deployment configuration changed. These changes are still valid in JBoss EAP 7. See the following section of the JBoss EAP 6 Migration Guide for more information.

EJB

The Java EE 7 specification made EJB 2.x and earlier features optional, so it is strongly recommended that you rewrite your application code to use the EJB 3.x specification and JPA. For information about deprecated features and changes required to run EJB 2.x, see the following section in the JBoss EAP 6 Migration Guide.

In JBoss EAP 6, stateful EJB cache and stateless session bean pool size is configured in the ejb3 subsystem of the server configuration file. The jboss-ejb3.xml deployment descriptor replaces the jboss.xml deployment descriptor file. For more information about these changes, see the following section in the JBoss EAP 6 Migration Guide.

The default remote connector and port has changed in JBoss EAP 7. For more information about this and server configuration changes, see the following sections in this guide.

EJB entity beans are not supported in JBoss EAP 7. For information about how to migrate entity beans to JPA, see the following section in this guide.

Hibernate 和 JPA

In JBoss EAP 6, Hibernate was updated from version 3 to version 4. This version of JBoss EAP also implemented the JPA 2.0 specification and changes were made to JPA persistence properties. For information about how to modify your application for these changes, see the following section in the JBoss EAP 6 Migration Guide.

JBoss EAP 7 implements JPA 2.1 and includes Hibernate 5. It also updates Hibernate Search from version 4.6.x to version 5.5.x. Other changes include removal of support for EJB entity beans and additional updates to JPA persistence properties. For information about how these changes impact your applications, see the following sections in this guide.

JAX-RS and RESTEasy

JBoss EAP 6 bundled RESTEasy 2, which automatically configured RESTEasy and required changes in application configuration. See the following section in the JBoss EAP 6 Migration Guide for information.

JBoss EAP 7 includes RESTEasy 3 and many classes have been deprecated. The version of Jackson changed from version 1.9.9 to version 2.6.3 or greater. For details about these changes, see the following section in this guide.

JBoss AOP

JBoss AOP (Aspect Oriented Programming) was removed in JBoss EAP 6. For information about how to refactor applications that use JBoss AOP, see the following section in the JBoss EAP 6 Migration Guide.

JGroups and Clustering

The way you enable clustering and specify bind addresses changed in JBoss EAP 6. See the following section in the JBoss EAP 6 Migration Guide for more information.

In JBoss EAP 7, JGroups now defaults to using a private network interface instead of a public network interface and also introduces <channel> elements to the jgroups subsystem. JBoss EAP 7 also includes the Undertow mod_cluster implementation, introduces a new API for building singleton services, and other new clustering features. These changes are documented in the following sections of this guide.

JNDI

JBoss EAP 6 implemented a new standardized global JNDI namespace and a series of related namespaces that map to the various scopes of a Java EE application. See the following section of the JBoss EAP 6 Migration Guide for information about application changes needed to use the new JNDI namespace rules.

JSF

JBoss EAP 6 included JSF 2.0 and allowed you to configure your application to use an older version. This is no longer possible in JBoss EAP 7, which now includes JSF 2.2. See the following section in this guide for more information.

日志

JBoss EAP 6 introduced a new JBoss Logging framework that is still used in JBoss EAP 7. Applications that use third-party logging frameworks might be impacted by the modular class loading changes. Review the following section in the JBoss EAP 6 Migration Guide for information about these changes.

In JBoss EAP 7, annotations in the org.jboss.logging package are now deprecated, which impacts source code and Maven GAVs (groupId:artifactId:version). The prefixes for all log messages were also changed. For more information about these changes, see the following sections in this guide.

Messaging and JMS

In JBoss EAP 6, HornetQ replaced JBoss Messaging as the default JMS implementation. Then in JBoss EAP 7, ActiveMQ Artemis replaced HornetQ as the built-in messaging provider.

The best approach to migrating your messaging configuration is to start with the JBoss EAP 7 default server configuration and use the following guide to apply your current messaging configuration changes.

If you want to understand the changes required to move from JBoss Messaging to HornetQ, review the following section of the JBoss EAP 6 Migration Guide.

Then review the following information about how to migrate the HornetQ configuration and related messaging data in this guide.

ORB

In JBoss EAP 6, JacORB configuration was moved from the EAP_HOME/server/production/conf/jacorb.properties file to the server configuration file. JBoss EAP 7 then replaced the JacORB IIOP implementation with a downstream branch of the OpenJDK ORB.

The best approach to migrating your ORB configuration is to start with the JBoss EAP 7 default server configuration and use the following section in the JBoss EAP 7 Configuration Guide to apply the your current ORB configuration changes.

Remote Invocation

A new EJB client API was introduced in JBoss EAP 6 for remote invocations; however, if you preferred not to rewrite your application code to use the new API, you could modify your existing code to use the ejb:BEAN_REFERENCE for remote access to EJBs. See the following section in the JBoss EAP 6 Migration Guide for more information.

In JBoss EAP 7, the default connector and default remote connection port changed. For more information, see the following sections in this guide.

Seam 2.x

While official support for Seam 2.2 applications was dropped in JBoss EAP 6, it was still possible to configure dependencies for JSF 1.2 and Hibernate 3 to allow Seam 2.2 applications to run on that release. JBoss EAP 7, which now includes JSF 2.2 and Hibernate 5, does not support Seam 2.2 or Seam 2.3 due to end of life of Red Hat JBoss Web Framework Kit. It is recommended that you rewrite your Seam components using Weld CDI beans.

安全性

Security updates in JBoss EAP 6 included changes to security domain names and changes to how to configure security for basic authentication. The LDAP security realm configuration was moved to the server configuration file. See the following sections in the JBoss EAP 6 Migration Guide for more information.

Updates that impact security in JBoss EAP 7 include server configuration changes and application changes. Information can be found in the following sections of this guide.

Spring Applications

Spring 4.2.x is the earliest stable Spring version supported by JBoss EAP 7. For information about Apache CXF Spring web services and Spring RESTEasy integration changes, see the following sections in this guide.

事务

JBoss EAP 6 consolidated transaction configuration and moved it to the server configuration file. Other updates included changes to JTA node identifier settings and how to enable JTS. For details, see the following section in the JBoss EAP 6 Migration Guide.

Some Transaction Manager configuration attributes that were available in the transactions subsystem in JBoss EAP 6 have changed in JBoss EAP 7. For more information, see the following section in this guide.

Valves

Undertow replaced JBoss Web in JBoss EAP 7 and valves are no longer supported. See the following sections in this guide.

Web 服务

JBoss EAP 6 included JBossWS 4. For information about the changes required by that version update, see the following section in the JBoss EAP 6 Migration Guide.

JBoss EAP 7 introduced JBossWS 5. See the following section in this guide for required updates.

附录 A. 参考资料

A.1. JacORB 子系统迁移操作警告

The migrate operation is not able to process all resources and attributes. The following table lists some of the warnings you might see when you run either the migrate or describe-migration operation for the jacorb subsystem.

注意

如果您在 migrate 操作的输出里看到 "Could not migrate" 或 "Can not migrate" 信息,表示服务器配置的迁移已成功完成,但它无法迁移所有的元素和属性。您必须根据 "migration-warnings" 提供的建议来修改这些配置。

警告信息这意味着什么 / 如何进行修复

当服务器处于 admin-only 模式时可以执行 iiop 迁移

migrate 操作要求以 admin-only 模式启动服务器,这是在服务器启动命令里使用 --admin-only 参数来实现的:

$ EAP_HOME/bin/standalone.sh --admin-only

属性 X 无法用 OpenJDK ORB 模拟且不被支持

指定的属性的配置不被支持也没有包含在新的 iiop-openjdk 子系统配置里。之前版本的 JBoss EAP 里的这个属性展示的行为没有被迁移,管理员必须检验 JBoss EAP 7 里新的 iiop-openjdk 子系统是否可以正确操作而无需这个行为。

不支持的属性包括:cache-poa-names, cache-typecodes, chunk-custom-rmi-valuetypes, client-timeout, comet, indirection-encoding-disable, iona, lax-boolean-encoding, max-managed-buf-size, max-server-connections, max-threads, outbuf-cache-timeout, outbuf-size, queue-max, queue-min, poa-monitoring, print-version, retries, retry-interval, queue-wait, server-timeout, strict-check-on-tc-creation, use-bom, use-imr

属性 X 使用表达式。用于解析这些表达式的配置属性应该手动转换为新的 iiop-openjdk 子系统格式。

使用表达式的属性必须由管理员手动配置。

例如,JBoss EAP 6 里的 jacorb 子系统定义了一个 giop-minor-version 属性。而 JBoss EAP 7 里的 iiop-openjdk 子系统定义了 giop-version 属性。假设 jacorb 子系统的次要版本属性被设置为 ${iiop-giop-minor-version} 而系统属性在 standalone.conf 文件里被配置为 -Diiop-giop-minor-version=1。在 migrate 操作执行后,管理员必须修改系统属性为 1.1 以确保新的子系统被正确配置。

无法迁移:已经定义新的 iiop-openjdk 子系统

这个消息包含了相关的解释。

A.2. Messaging 子系统迁移操作警告

The migrate operation is not able to process all resources and attributes. The following table lists some of the warnings you might see when you run either the migrate or describe-migration operation for the messaging subsystem.

注意

如果您在 migrate 操作的输出里看到 "Could not migrate" 或 "Can not migrate" 信息,表示服务器配置的迁移已成功完成,但它无法迁移所有的元素和属性。您必须根据 "migration-warnings" 提供的建议来修改这些配置。

警告信息这意味着什么 / 如何进行修复

无法执行 migrate 操作:服务器必须处于 admin-only 模式。

migrate 操作要求以 admin-only 模式启动服务器,这是在服务器启动命令里使用 --admin-only 参数来实现的:

$ EAP_HOME/bin/standalone.sh --admin-only

无法从资源 X 迁移属性 local-bind-address。请改为使用 socket-binding 属性来配置这个 broadcast-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 local-bind-port。请改为使用 socket-binding 属性来配置这个 broadcast-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 group-address。请改为使用 socket-binding 属性来配置这个 broadcast-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 group-port。请改为使用 socket-binding 属性来配置这个 broadcast-group

broadcast-group 资源不再接受 local-bind-addresslocal-bind-portgroup-addressgroup-port 属性。它只接受 socket-binding 属性。这个警告是表示资源 X 具有不受支持的属性。您必须手动设置资源上的 socket-binding 属性并确保它对应已定义的 socket-binding 资源。

在迁移过程中舍弃了提供 X 的类。要在新的 messaging-activemq 子系统使用它们,您需要继承基于 Artemis 的 Interceptor

JBoss EAP 7 对消息拦截器的支持已明显不同。之前版本的子系统里配置的任何拦截器在迁移过程中已被舍弃。更多的信息请参考迁移消息拦截器

无法迁移 X 的 HA 配置。它的 shared-storebackup 属性含有表达式,无法明确地确定如何为 messaging-activemq 服务器创建对应的 ha-policy

这意味着 hornetq-server Xshared-storebackup 属性包含了一个表达式,如 ${xxx},而 migration 操作无法将其解析为具体的表达式。这个值被舍弃,messaging-activemqha-policy 必须手动进行更新。

无法从资源 X 迁移属性 local-bind-address。请改为使用 socket-binding 属性来配置这个 discovery-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 local-bind-port。请改为使用 socket-binding 属性来配置这个 discovery-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 group-address。请改为使用 socket-binding 属性来配置这个 discovery-group

这个消息包含了相关解释及如何进行修复。

无法从资源 X 迁移属性 group-port。请改为使用 socket-binding 属性来配置这个 discovery-group

discovery-group 资源不再接受 local-bind-addresslocal-bind-portgroup-addressgroup-port 属性。它只接受 socket-binding 属性。这个警告是表示资源 X 具有不受支持的属性。您必须手动设置资源上的 socket-binding 属性并确保它对应已定义的 socket-binding 资源。

无法创建基于 connection-factory Xlegacy-connection-factory。它使用不兼容 Artemis in-vm 连接器的 HornetQ in-vm 连接器。

旧的 HornetQ 远程 connection-factory 资源被迁移至 legacy-connection-factory 资源以允许 JBoss EAP 6 客户连接至 JBoss EAP 7。然而,legacy-connection-factory 资源只有当 connection-factory 使用远程连接器时才被创建。任何使用 in-vmconnection-factory 都不会迁移,因为 in-vm 客户是基于 JBoss EAP 7 而不是 JBoss EAP 6 的。这个警告表示 in-vm connection-factory 没有被迁移。

无法从资源 Y 迁移属性 X。这个属性使用可以根据系统属性解析的表达式。在迁移后,您必须使用具体值而不是表达式再添加这个属性。

当在迁移过程种无法解析属性 X为具体值时这个警告会出现。这个值将被舍弃而属性必须手动迁移。它发生在下类情况下:

  • cluster-connection forward-when-no-consumers:

    这个布尔型属性已被枚举型 message-load-balancing-type 属性替代,它的值可以是 OFFSTRICTON_DEMAND

  • broadcast-groupdiscovery-groupjgroups-stackjgroups-channel 属性

    它们引用了其他资源,而 JBoss EAP 7 不再接受这些表达式。

无法从资源 Y 迁移属性 X。新的 messaging-activemq 子系统不支持这个属性。

新的 messaging-activemq 子系统不再支持某些属性而只是简单地舍弃:

  • hornetq-serverfailback-delay 属性
  • http-connectoruse-nio 属性
  • http-acceptoruse-nio 属性
  • remote-connectoruse-nio 属性
  • remote-acceptoruse-nio 属性

无法从资源 X 迁移属性 failback-delay。Artemis 可以确切地检测到故障恢复且不再要求指定发生故障恢复的延迟。

这个消息包含了相关的解释。

替换已舍弃的 broadcast-group 或 discovery-group 属性

如果您被建议用 socket-binding 属性替代已舍弃的 broadcast-groupdiscovery-group 属性,您可以用管理 CLI 添加新的属性。

这个例子假定您在迁移在 messaging 子系统里包含下列 discovery-group 配置的独立服务器。

<discovery-groups>
    <discovery-group name="my-discovery-group">
        <group-address>224.0.1.105</group-address>
        <group-port>56789</group-port>
    </discovery-group>
</discovery-groups>

当你对 messaging 子系统运行 migrate 操作时,您会看到下列输出和警告:

[standalone@localhost:9999 /] /subsystem=me
    "outcome" => "success",
    "result" => {"migration-warnings" => [
        "WFLYMSG0084: Can not migrate attribute group-address from resource [
    (\"subsystem\" => \"messaging-activemq\"),
    (\"server\" => \"default\"),
    (\"discovery-group\" => \"my-discovery-group\")
]. Use instead the socket-binding attribute to configure this discovery-group.",
        "WFLYMSG0084: Can not migrate attribute group-port from resource [
    (\"subsystem\" => \"messaging-activemq\"),
    (\"server\" => \"default\"),
    (\"discovery-group\" => \"my-discovery-group\")
]. Use instead the socket-binding attribute to configure this discovery-group."
    ]}
}

migrate 操作在新的 messaging-activemq 子系统里创建了一个名为 "my-discovery-group" 的 discovery-group,其配置如下。

<discovery-group name="my-discovery-group"/>

您现在必须使用下列管理 CLI 命令在名为 "my-discovery-group-socket-binding" 的服务器配置文件里创建 socket-binding 元素。

/socket-binding-group=standard-sockets/socket-binding=my-discovery-group-socket-binding:add(multicast-address=224.0.1.105, multicast-port=56789)

然后,通过下列 CLI 命令添加新创建的 socket-binding 至配置文件的 messaging-activemq 子系统里名为 "my-discovery-group" 的 discovery-group 里。

/subsystem=messaging-activemq/server=default/discovery-group=my-discovery-group:write-attribute(name=socket-binding,value=my-discovery-group-socket-binding)

这些命令在服务器配置文件里创建了下列 XML。

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
    <server name="default">
        ...
        <discovery-group name="my-discovery-group" socket-binding="my-discovery-group-socket-binding"/>
        ...
    </server>
</subsystem>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    ...
    <socket-binding name="my-discovery-group-socket-binding" multicast-address="224.0.1.105" multicast-port="56789"/>
    ...
</socket-binding-group>

A.3. Web 子系统迁移操作警告

The migrate operation is not able to process all resources and attributes. The following table lists some of the warnings you might see when you run either the migrate or describe-migration operation for the web subsystem.

注意

如果您在 migrate 操作的输出里看到 "Could not migrate" 或 "Can not migrate" 信息,表示服务器配置的迁移已成功完成,但它无法迁移所有的元素和属性。您必须根据 "migration-warnings" 提供的建议来修改这些配置。

警告信息这意味着什么 / 如何进行修复

只有 admin-only 模式才允许迁移操作

migrate 操作要求以 admin-only 模式启动服务器,这是在服务器启动命令里使用 --admin-only 参数来实现的:

$ EAP_HOME/bin/standalone.sh --admin-only

无法迁资源 X

这个资源在之前的 JBoss EAP 版本里展示的行为没有被迁移。管理员必须检验 JBoss EAP 7 里新的 undertow 子系统在没有这些行为时是否能够正常操作,或者这些行为是否必须手动进行迁移。

无法从资源 Y 迁移属性 X

这个资源属性在之前的 JBoss EAP 版本里展示的行为没有被迁移。管理员必须检验 JBoss EAP 7 里新的 undertow 子系统在没有这些行为时是否能够正常操作,或者这些行为是否必须手动进行迁移。

See Web Subsystem Migration Operation Attribute Warnings for the list of attributes that are not migrated.

无法迁移 SSL 连接器,因为没有定义 SSL 配置。

这个消息包含了相关的解释。

无法迁移 verify-client 属性 X 至 Undertow 里对应的属性

这个消息包含了相关的解释。

无法迁移 verify-client 表达式 X

这个消息包含了相关的解释。

无法迁移阀 X

这个阀在之前的 JBoss EAP 版本里展示的行为没有被迁移。管理员必须检验 JBoss EAP 7 里新的 undertow 子系统在没有这些行为时是否能够正常操作,或者这些行为是否必须手动进行迁移。

This warning can occur for the following valves:

  • org.apache.catalina.valves.RemoteAddrValve

    它必须至少有一个允许或拒绝的值。

  • org.apache.catalina.valves.RemoteHostValve

    它必须至少有一个允许或拒绝的值。

  • org.apache.catalina.authenticator.BasicAuthenticator
  • org.apache.catalina.authenticator.DigestAuthenticator
  • org.apache.catalina.authenticator.FormAuthenticator
  • org.apache.catalina.authenticator.SSLAuthenticator
  • org.apache.catalina.authenticator.SpnegoAuthenticator
  • 自定义阀

无法从阀 Y 迁移属性 X

The behavior exhibited by this valve attribute in the previous release of JBoss EAP was not migrated. The administrator must verify if the new undertow subsystem in JBoss EAP 7 is able to operate correctly without that behavior or whether the behavior must be migrated manually. This warning can occur for the following valve attributes:

  • org.apache.catalina.valves.AccessLogValve

    • resolveHosts
    • fileDateFormat
    • renameOnRotate
    • encoding
    • locale
    • requestAttributesEnabled
    • buffered
  • org.apache.catalina.valves.ExtendedAccessLogValve

    • resolveHosts
    • fileDateFormat
    • renameOnRotate
    • encoding
    • locale
    • requestAttributesEnabled
    • buffered
  • org.apache.catalina.valves.RemoteIpValve

    • httpServerPort
    • httpsServerPort
    • remoteIpHeader

      如果被定义但没设置为 "x-forwarded-for"

    • protocolHeader

      如果被定义但没设置为 "x-forwarded-proto"

Web Subsystem Migration Operation Attribute Warnings

The migrate operation is not able to process all JBoss Web attributes. See the following reference tables for information about how to migrate the unprocessed attributes manually.

Web SSL Connector Attributes

The following attributes were used in JBoss EAP 6 to configure the SSL connector. OpenSSL native libraries are not supported in JBoss EAP 7 so there are no equivalent settings.

Attribute描述Undertow Equivalent

ca-revocation-url

The file or URL that contains the revocation list.

No equivalent in Undertow.

certificate-file

When using OpenSSL encryption, the path to the file containing the server certificate.

No equivalent in Undertow.

ssl-protocol

The SSL protocol string.

No equivalent in Undertow.

verify-depth

The maximum number of intermediate certificate issuers checked before deciding that the clients do not have a valid certificate.

No equivalent in Undertow.

Web Static Resource Attributes

The following static-resources element attributes were used to describe how static resources were handled by the DefaultServlet or by the WebdavServlet. There are no equivalents for these attributes because WebDAV is not supported by Undertow. For more information, see https://issues.jboss.org/browse/JBEAP-1036.

Attribute描述Undertow Equivalent

disabled

Enable the default Servlet mapping.

No equivalent setting in Undertow.

file-encoding

File encoding to be used when reading static files.

No equivalent setting in Undertow.

max-depth

Maximum recursion for PROPFIND.

This is a WebDAV setting and WebDAV is not supported by Undertow.

read-only

Allow write HTTP methods (PUT, DELETE).

This is a WebDAV setting and WebDAV is not supported by Undertow.

secret

Secret for WebDAV locking operations.

This is a WebDAV setting and WebDAV is not supported by Undertow.

sendfile

Enable sendfile if possible, for files bigger than the specified byte size.

This is set to a sensible default value in Undertow and is not configurable.

webdav

Enable WebDAV functionality.

WebDAV is not supported by Undertow.

Web SSO Resource Attributes

SSO is handled differently than in the previous release and there are no equivalent attribute settings in JBoss EAP 7.

JBoss Web Attribute描述Undertow Equivalent

cache-container

Name of the cache container to use for clustered SSO.

This setting is no longer needed in Undertow. This works by default across a distributed clustered environment.

cache-name

Name of the cache to use for clustered SSO.

This setting is no longer needed in Undertow. This works by default across a distributed clustered environment.

reauthenticate

Whether each request should cause a reauthentication.

There is no equivalent setting in Undertow, which behaves similarly to the reauthenticate=true setting in JBoss EAP 6. While reauthenticate=false could possibly improve performance, it could also create security issues.

Web Access Log Attributes
JBoss Web Attribute描述Undertow Equivalent

resolve-hosts

Whether to enable resolving hosts for access logging.

Use the setting on the connector to accomplish the same behavior.

Web Connector Attributes
JBoss Web Attribute描述Undertow Equivalent

executor

The name of the executor that should be used to process the threads of this connector.

You now reference a worker that is defined in the io subsystem.

See Migrate the Threads Subsystem Configuration for more information.

proxy-binding

The socket binding to define the host and port that is used when sending a redirect.

There is no direct equivalent.

See https-listener Attributes in the JBoss EAP Configuration Guide for available configuration options.

redirect-port

The port for redirection to a secure connector.

This attribute was deprecated in JBoss EAP 6 and replaced with redirect-binding. Undertow provides the redirect-socket attribute on the http-listener element, which is a replacement for redirect-binding.

See https-listener Attributes in the JBoss EAP Configuration Guide for more information.

A.4. Migrate JBoss Web System Properties Reference

This reference describes how to map system properties previously used for JBoss Web configuration to the equivalent configuration for Undertow in JBoss EAP 7.

表 A.1. Map Servlet Container and Connectors System Properties

JBoss EAP 6 System Property

Description

Equivalent in JBoss EAP 7

jvmRoute

Provides a default value for the jvmRoute attribute. It does not override the automatically generated value when using the standalone-ha.xml configuration file.

It supports reload.

Management CLI command:

/subsystem=undertow:write-attribute(name=instance-id,value=VALUE)

org.apache.tomcat.util.buf.StringCache.byte.enabled

If true, the String cache is enabled for ByteChunk. If the value is not specified, the default value of false is used.

No equivalent configuration

org.apache.tomcat.util.buf.StringCache.char.enabled

If true, the String cache is enabled for CharChunk. If the value is not specified, the default value of false is used.

No equivalent configuration

org.apache.tomcat.util.buf.StringCache.cacheSize

The size of the String cache. If the value is not specified, the default value of 5000 is used.

No equivalent configuration

org.apache.tomcat.util.buf.StringCache.maxStringSize

The maximum length of String that will be cached. If the value is not specified, the default value of 128 is used.

No equivalent configuration

org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE

The size of the cache to use parsed and formatted date value. If the value is not specified, the default value of 1000 is used.

No equivalent configuration

org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP

If true, the connector startup is not done automatically. It is useful in embedded mode.

No equivalent configuration

org.apache.catalina.connector.Request.SESSION_ID_CHECK

If true, the Servlet container verifies that a session exists in a context with the specified session ID before creating a session with that ID.

No equivalent configuration

org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER

If true, custom HTTP status messages are used within HTTP headers. Users must ensure that any such message is ISO-8859-1 encoded, particularly if user provided input is included in the message, to prevent a possible XSS vulnerability. If value is not specified the default value of false is used.

Must be enabled programmatically by implementing a custom io.undertow.servlet.ServletExtension. Then use the extension to call setSendCustomReasonPhraseOnError(true) on the io.undertow.servlet.api.DeploymentInfo structure instance.

org.apache.tomcat.util.http.Parameters.MAX_COUNT

The maximum number of parameters that can be parsed in a post body. If exceeded, parsing fails using an IllegalStateException. The default value is 512 parameters.

Management CLI command:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-parameters,value=VALUE)
/subsystem=undertow/server=default-server/https-listener=default:write-attribute(name=max-parameters,value=VALUE)
/subsystem=undertow/server=default-server/ajp-listener=default:write-attribute(name=max-parameters,value=VALUE)

org.apache.tomcat.util.http.MimeHeaders.MAX_COUNT

The maximum number of headers that can be sent in the HTTP request. If exceeded, parsing will fail using an IllegalStateException. The default value is 128 headers.

Management CLI command:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-headers,value=VALUE)
/subsystem=undertow/server=default-server/https-listener=default:write-attribute(name=max-headers,value=VALUE)
/subsystem=undertow/server=default-server/ajp-listener=default:write-attribute(name=max-headers,value=VALUE)

org.apache.tomcat.util.net.MAX_THREADS

The maximum number of threads a connector is going to use to process requests. The default value is 32 x 512. (512 x Runtime.getRuntime().availableProcessors() for the JIO connector)

Management CLI command:

/subsystem=io/worker=default:write-attribute(name=task-max-threads, value=VALUE)

org.apache.coyote.http11.Http11Protocol.MAX_HEADER_SIZE

The maximum size of the HTTP headers, in bytes. If exceeded, parsing will fail using an ArrayOutOfBoundsException. The default value is 8192 bytes.

Management CLI command:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-header-size,value=VALUE)
/subsystem=undertow/server=default-server/https-listener=default:write-attribute(name=max-header-size,value=VALUE)
/subsystem=undertow/server=default-server/ajp-listener=default:write-attribute(name=max-header-size,value=VALUE)

org.apache.coyote.http11.Http11Protocol.COMPRESSION

Allows using simple compression with the HTTP connector. The default value is off, and compression can be enabled using the value on to enable it conditionally, or force to always enable it.

Configure a filter using the management CLI:

# Create a filter
/subsystem=undertow/configuration=filter/gzip=gzipfilter:add()
/subsystem=undertow/server=default-server/host=default-host/filter-ref=gzipfilter:add()

org.apache.coyote.http11.Http11Protocol.COMPRESSION_RESTRICTED_UA

User agents regexps that will not receive compressed content. The default value is empty.

Configure a predicate in a filter using the management CLI:

# Use a predicate in a filter
/subsystem=undertow/configuration=filter/gzip=gzipfilter:add()
/subsystem=undertow/server=default-server/host=default-host/filter-ref=gzipfilter:add(predicate="regex[pattern='AppleWebKit',value=%{i,User-Agent}]")

org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES

Content type prefixes of compressible content. The default value is text/html,text/xml,text/plain.

Configure a predicate in a filter using the management CLI:

# Use a predicate in a filter
/subsystem=undertow/configuration=filter/gzip=gzipfilter:add()
/subsystem=undertow/server=default-server/host=default-host/filter-ref=gzipfilter:add(predicate="regex[pattern='text/html',value=%{o,Content-Type}]")

org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE

Minimum size of content that will be compressed. The default value is 2048 bytes.

Configure a predicate in a filter using the management CLI:

# Use a predicate in a filter
/subsystem=undertow/configuration=filter/gzip=gzipfilter:add()
/subsystem=undertow/server=default-server/host=default-host/filter-ref=gzipfilter:add(predicate="max-content-size[value=MIN_SIZE]")

org.apache.coyote.http11.DEFAULT_CONNECTION_TIMEOUT

Default socket timeout. The default value is 60000 ms.

Management CLI command:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=no-request-timeout,value=VALUE)
/subsystem=undertow/server=default-server/https-listener=default:write-attribute(name=no-request-timeout,value=VALUE)
/subsystem=undertow/server=default-server/ajp-listener=default:write-attribute(name=no-request-timeout,value=VALUE)

org.jboss.as.web.deployment.DELETE_WORK_DIR_ONCONTEXTDESTROY

Use this property to remove .java and .class files to ensure that JSP sources are recompiled. The default value is false. Default socket timeout for keep-alive. The default value is -1 ms, which means it will use the default socket timeout.

No equivalent configuration

org.apache.tomcat.util.buf.StringCache.trainThreshold

Specifies the number of times toString() must be invoked before activating cache. The default value is 100000.

No equivalent configuration

表 A.2. Map EL System Properties

JBoss EAP 6 System Property

Description

Equivalent in JBoss EAP 7

org.apache.el.parser.COERCE_TO_ZERO

If true, when coercing expressions to numbers, empty strings ("") and null will be coerced to zero as required by the specification. If a value is not specified, the default value of true is used.

System property is still valid and processed by the EL

表 A.3. Map JSP System Properties

JBoss EAP 6 System Property

Description

Equivalent in JBoss EAP 7

org.apache.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY

The name of the variable to use for the expression language expression factory. If value is not specified, the default value of _el_expressionfactory is used.

System property has not changed

org.apache.jasper.compiler.Generator.VAR_INSTANCEMANAGER

The name of the variable to use for the instance manager factory. If value is not specified, the default value of _jsp_instancemanager is used.

System property has not changed

org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING

If false, the requirements for escaping quotes in JSP attributes are relaxed so that a missing required quote does not cause an error. If value is not specified, the specification compliant default of true is used.

System property has not changed

org.apache.jasper.Constants.DEFAULT_TAG_BUFFER_SIZE

Any tag buffer that expands beyond org.apache.jasper.Constants.DEFAULT_TAG_BUFFER_SIZE is destroyed and a new buffer is created of the default size. If value is not specified, the default value of 512 is used.

System property has not changed

org.apache.jasper.runtime.JspFactoryImpl.USE_POOL

If true, a ThreadLocal PageContext pool is used. If value is not specified, the default value of true is used.

System property has not changed

org.apache.jasper.runtime.JspFactoryImpl.POOL_SIZE

The size of the ThreadLocal PageContext. If value is not specified, the default value of 8 is used.

System property has not changed

org.apache.jasper.Constants.JSP_SERVLET_BASE

The base class of the Servlets generated from the JSPs. If value is not specified, the default value of org.apache.jasper.runtime.HttpJspBase is used.

System property has not changed

org.apache.jasper.Constants.SERVICE_METHOD_NAME

The name of the service method called by the base class. If value is not specified, the default value of _jspService is used.

System property has not changed

org.apache.jasper.Constants.SERVLET_CLASSPATH

The name of the ServletContext attribute that provides the class path for the JSP. If value is not specified, the default value of org.apache.catalina.jsp_classpath is used.

System property has not changed

org.apache.jasper.Constants.JSP_FILE

The name of the request attribute for <jsp-file> element of a servlet definition. If present on a request, this overrides the value returned by request.getServletPath() to select the JSP page to be executed. If value is not specified, the default value of org.apache.catalina.jsp_file is used.

System property has not changed

org.apache.jasper.Constants.PRECOMPILE

The name of the query parameter that causes the JSP engine to just pregenerate the servlet but not invoke it. If value is not specified, the default value of org.apache.catalina.jsp_precompile is used.

System property has not changed

org.apache.jasper.Constants.JSP_PACKAGE_NAME

The default package name for compiled JSP pages. If value not specified, the default value of org.apache.jsp is used.

System property has not changed

org.apache.jasper.Constants.TAG_FILE_PACKAGE_NAME

The default package name for tag handlers generated from tag files. If value is not specified, the default value of org.apache.jsp.tag is used.

System property has not changed

org.apache.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX

Prefix to use for generated temporary variable names. If value is not specified, the default value of _jspx_temp is used.

System property has not changed

org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS

If true, the instance manager is used to obtain tag handler instances. If value is not specified, true is used.

System property has not changed

org.apache.jasper.Constants.INJECT_TAGS

If true, annotations specified in tags will be processed and injected. This can have a performance impact when using simple tags, or if tag pooling is disabled. If value is not specified, false is used.

System property has not changed

表 A.4. Map Security System Properties

JBoss EAP 6 System Property

Description

Equivalent in JBoss EAP 7

org.apache.catalina.connector.RECYCLE_FACADES

If this is true or if a security manager is in use a new facade object is created for each request. If value is not specified, the default value of false is used.

No equivalent configuration

org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH

If this is true the '\' character is permitted as a path delimiter. If value is not specified, the default value of false is used.

No equivalent configuration

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH

If this is true, '%2F' and '%5C' is permitted as path delimiters. If value is not specified, the default value of false is used.

Management CLI command:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=allow-encoded-slash,value=VALUE)
/subsystem=undertow/server=default-server/https-listener=default:write-attribute(name=allow-encoded-slash,value=VALUE)
/subsystem=undertow/server=default-server/ajp-listener=default:write-attribute(name=allow-encoded-slash,value=VALUE)

org.apache.catalina.STRICT_SERVLET_COMPLIANCE

If value is not specified, true is used. If this is true the following actions will occur: any wrapped request or response object passed to an application dispatcher is checked to ensure that it has wrapped the original request or response. (SRV.8.2 / SRV.14.2.5.1) a call to Response.getWriter() if no character encoding has been specified results in subsequent calls to Response.getCharacterEncoding() returning ISO-8859-1 and the Content-Type response header will include a charset=ISO-8859-1 component. (SRV.15.2.22.1) every request that is associated with a session causes the session’s last accessed time to be updated regardless of whether or not the request explicity accesses the session. (SRV.7.6)

Compliant by default

org.apache.catalina.core.StandardWrapperValve.SERVLET_STATS

If true or if org.apache.catalina.STRICT_SERVLET_COMPLIANCE is true, the wrapper will collect the JSR-77 statistics for individual servlets. If value is not specified, the default value of false is used.

No equivalent configuration

org.apache.catalina.session.StandardSession.ACTIVITY_CHECK

If this is true or if org.apache.catalina.STRICT_SERVLET_COMPLIANCE is true Tomcat tracks the number of active requests for each session. When determining if a session is valid, any session with at least one active request is always be considered valid. If value is not specified, the default value of false is used.

No equivalent configuration

A.5. 版本间的兼容性和互用性

本节描述了 JBoss EAP 5、JBoss EAP 6 和 JBoss EAP 7 版本间的客户、服务器 EJB 和消息组件的兼容性和互用性。

使用 IIOP 的 EJB Remoting

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 5 服务器

使用 JNDI 的 EJB Remoting

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器

JBoss EAP 6 提供对 EJB 3.1 规格的支持并引入了标准化的全局 JNDI 命名空间,这在 JBoss EAP 7 里仍被使用。由于 JNDI 命名空间名称的修改,下列配置是不兼容的:

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 或 JBoss EAP 6 服务器
  • 从 JBoss EAP 7 或 JBoss EAP 6 客户连接至 JBoss EAP 5 服务器

关于标准化 JNDI 命名空间修改的详情,请参考《JBoss EAP 6 迁移指南》里的『JNDI 修改』章节。

使用 @WebService 的 EJB Remoting

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 5 服务器

消息独立客户

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器

在下面的配置里,如果客户使用消息中介专有的 HornetQ API 而不是通用的 JMS API,连接是有可能实现的。然而,JNDI 查找必须用 JBoss EAP 7 附带的旧的 JBoss EAP JNDI 命名扩展来寻址。

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 服务器

由于协议的兼容性问题,JBoss EAP 7 内置的消息系统不能与 JBoss EAP 5 附带的 HornetQ 2.2.x。 因此,下列配置是不兼容的。

  • 从 JBoss EAP 7 客户连接至 JBoss EAP 5 服务器

Messaging MDB

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器

在下面的配置里,如果客户使用消息中介专有的 HornetQ API 而不是通用的 JMS API,连接是有可能实现的。然而,JNDI 查找必须用 JBoss EAP 7 附带的旧的 JBoss EAP JNDI 命名扩展来寻址。

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 服务器

由于协议的兼容性问题,JBoss EAP 7 内置的消息系统不能与 JBoss EAP 5 附带的 HornetQ 2.2.x。 因此,下列配置是不兼容的。

  • 从 JBoss EAP 7 客户连接至 JBoss EAP 5 服务器

JMS 桥

对于下列配置您应该不会遇到任何问题。

  • 从 JBoss EAP 5 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 6 客户连接至 JBoss EAP 7 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 6 服务器
  • 从 JBoss EAP 7 客户连接至 JBoss EAP 5 服务器





Revised on 2018-01-12 05:23:39 EST

法律通告

Copyright © 2018 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.