另外,Richfaces 3.3.4.Final fileupload组件页面显示有中文乱码问题,需要修改FileUploadRendererBase的initLabels方法,删除value = dumpingWriter.toString();这一行。
-
强烈建议升级到Hibernate 5,如确实不能升级,需创建一个3.5 module,放入依赖包,module配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="org.hibernate" slot="3.5">
<properties>
<property name="jboss.api" value="unsupported"/>
</properties>
<resources>
<resource-root path="hibernate-core-3.5.6-Final.jar"/>
<resource-root path="hibernate-entitymanager-3.5.6-Final.jar"/>
<resource-root path="hibernate-annotations-3.5.6-Final.jar"/>
<resource-root path="hibernate-commons-annotations-3.2.0.Final.jar"/>
<resource-root path="hibernate-validator-3.1.0.GA.jar"/>
<resource-root path="cglib-2.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="javax.xml.bind.api"/>
<module name="org.antlr"/>
<module name="org.apache.commons.collections"/>
<module name="org.dom4j"/>
<module name="org.javassist" export="true"/>
<module name="org.jboss.as.jpa.spi"/>
<module name="org.jboss.jandex"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
<module name="org.slf4j"/>
</dependencies>
</module>
- jboss-deployment-structure.xml中排除org.hibernate,引入3.5
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate"/>
</exclusions>
<dependencies>
<module name="org.hibernate" slot="3.5" export="true"/>
<module name="org.antlr" export="true"/>
<module name="org.javassist" export="true"/>
</dependencies>
</deployment>
<sub-deployment name="ejb.jar">
<exclusions>
<module name="org.hibernate"/>
</exclusions>
<dependencies>
<module name="org.hibernate" slot="3.5"/>
<module name="org.javassist"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
- 修改persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="schedule">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/scheduleDatasource</jta-data-source>
<class>...</class>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3.5"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
...
</properties>
</persistence-unit>
</persistence>
HornetQ
EAP 7 使用了ActiveMQ Artemis取代了HornetQ,原Message-Driven Bean不需更改,需更改配置和客户端调用代码。
- jms-destinations
EAP 6中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>
更改为:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
...
<jms-queue name="testQueue" entries="queue/test java:jboss/exported/jms/queue/test"/>
...
</server>
</subsystem>
- security
如不启用security,增加如下配置:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security enabled="false"/>
...
</server>
</subsystem>
- Dependency
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_2.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.json</groupId>
<artifactId>jboss-json-api_1.0_spec</artifactId>
<scope>provided</scope>
</dependency>
- org.apache.activemq.artemis module取代org.hornetq
- 客户端代码
EAP 7,默认connector从remote改为http-remoting,使用undertow default http-listener、http端口,这也是推荐的方式:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
...
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
...
</server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:4.0">
...
<server name="default-server">
<ajp-listener name="ajp" socket-binding="ajp"/>
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
...
</server>
...
</subsystem>
客户端代码要做以下修改:remote connection port从4447改为8080,PROVIDER_URL从remote://localhost:4447改为http-remoting://localhost:8080。INITIAL_CONTEXT_FACTORY从org.jboss.naming.remote.client.InitialContextFactory改为org.wildfly.naming.client.WildFlyInitialContextFactory。
EAP 6:
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
EAP 7:
java.naming.factory.initial=org.wildfly.naming.client.WildFlyInitialContextFactory
java.naming.provider.url=http-remoting://localhost:8080
EJB
- Connector
EAP 7,默认connector从remote改为http-remoting,使用undertow default http-listener、http端口。
EAP 6:
<subsystem xmlns="urn:jboss:domain:remoting:1.2">
<connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
</subsystem>
EAP 7:
<subsystem xmlns="urn:jboss:domain:remoting:4.0">
<endpoint/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
- Dependency
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-ejb-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-naming-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-nio</artifactId>
<scope>provided</scope>
</dependency>
- jboss-ejb-client.properties
EAP 6:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.protocol=remote
remote.connection.default.host=localhost
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=quickuser
remote.connection.default.password=quick-123
EAP 7:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.protocol=http-remoting
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=quickuser
remote.connection.default.password=quick-123
- 客户端代码
EAP 6:
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
EAP 7:
java.naming.factory.initial=org.wildfly.naming.client.WildFlyInitialContextFactory
java.naming.provider.url=http-remoting://localhost:8080
- Standalone Client
EAP 7.1引入新的配置文件wildfly-config.xml,统一了所有客户端的配置,在standalone client中推荐使用这种方式。wildfly-config.xml放在classpath或META-INF目录下,也可用-Dwildfly.config.url指定路径(优先级:wildfly.config.url > classpath > META-INF)。
wildfly-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<authentication-client xmlns="urn:elytron:1.0.1">
<authentication-rules>
<rule use-configuration="ejb"/>
</authentication-rules>
<authentication-configurations>
<configuration name="ejb">
<sasl-mechanism-selector selector="DIGEST-MD5"/>
<set-user-name name="quickuser"/>
<credentials>
<clear-password password="quick-123"/>
</credentials>
<providers>
<use-service-loader/>
</providers>
<set-mechanism-realm name="ApplicationRealm"/>
</configuration>
</authentication-configurations>
</authentication-client>
</configuration>
使用wildfly-config.xml时的Java代码:
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
properties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
Context context = new InitialContext(properties);
Object theRemote = context.lookup(jndiName);
...
代码很简单,多个PROVIDER_URL时用逗号分隔。注意运行之前要添加ApplicationRealm用户:
add-user.sh -a -u quickuser -p quick-123
- Server-to-Server
利用remote-outbound-connection,在standalone.xml中增加如下配置:
增加security-realm,密码需经Base64编码
<management>
<security-realms>
<security-realm name="ejb-security-realm">
<server-identities>
<secret value="cXVpY2stMTIz"/>
</server-identities>
</security-realm>
...
</security-realms>
...
</management>
配置remote-outbound-connection
<subsystem xmlns="urn:jboss:domain:remoting:4.0">
<endpoint/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
<outbound-connections>
<remote-outbound-connection name="remote-ejb-connection1" outbound-socket-binding-ref="remote-ejb1" username="quickuser" security-realm="ejb-security-realm" protocol="http-remoting">
<properties>
<property name="SASL_POLICY_NOANONYMOUS" value="false"/>
<property name="SSL_ENABLED" value="false"/>
</properties>
</remote-outbound-connection>
</outbound-connections>
</subsystem>
配置Socket
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<outbound-socket-binding name="remote-ejb1">
<remote-destination host="127.0.0.1" port="8080"/>
</outbound-socket-binding>
</socket-binding-group>
在war的WEB-INF或ear的META-INF中新建文件jboss-ejb-client.xml:
<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.2">
<client-context>
<ejb-receivers>
<remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection1" connect-timeout="10000"/>
</ejb-receivers>
</client-context>
</jboss-ejb-client>
Java代码
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new javax.naming.InitialContext(props);
Object theRemote = context.lookup(jndiName);
Seam 2.2.2.Final
seam 2.2可以运行在Jboss EAP 7,同在EAP 6中一样,需修改org.jboss.seam.transaction.Transaction:
protected javax.transaction.UserTransaction getUserTransaction() throws NamingException
{
InitialContext context = Naming.getInitialContext();
try
{
return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
}
catch (NamingException ne)
{
try
{
//Embedded JBoss has no java:comp/UserTransaction
javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction");
ut.getStatus(); //for glassfish, which can return an unusable UT
return ut;
}
catch (NamingException nnfe2) {
// Try the other JBoss location in JBoss AS7
return (javax.transaction.UserTransaction) context.lookup("java:jboss/UserTransaction");
}
catch (Exception e)
{
throw ne;
}
}
}
如使用了seam-resteasy,需排除jaxrs子系统,使用EAP 6中的resteasy版本即可。
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs"/>
</exclude-subsystems>
...
</deployment>
</jboss-deployment-structure>
PicketLink
配置Subsystem
EAP 7默认是不支持picketlink的,需要配置picketlink subsystem。
增加extension
<extensions>
...
<extension module="org.wildfly.extension.picketlink"/>
...
</extensions>
配置subsystem
<profile>
...
<subsystem xmlns="urn:jboss:domain:picketlink-federation:2.0"/>
...
</profile>
配置security-domain
将EAP 6中相应配置迁移过来即可。
<security-domain name="sp" cache-type="default">
<authentication>
<login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2LoginModule" flag="required"/>
</authentication>
</security-domain>
<security-domain name="idp" cache-type="default">
<authentication>
<login-module code="UsersRoles" flag="required">
<module-option name="usersProperties" value="users.properties"/>
<module-option name="rolesProperties" value="roles.properties"/>
</login-module>
</authentication>
</security-domain>
配置jboss-deployment-structure
<jboss-deployment-structure>
<deployment>
<dependencies>
...
<module name="org.picketlink" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
注意:必须要添加services="import"。
配置Federation
EAP 7,valve不再使用:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>sp</security-domain>
<valve>
<class-name>org.picketlink.identity.federation.bindings.tomcat.sp.ServiceProviderAuthenticator</class-name>
<param>
<param-name>characterEncoding</param-name>
<param-value>UTF-8</param-value>
</param>
</valve>
</jboss-web>
<jboss-web>
<security-domain>idp</security-domain>
<context-root>idp-sig</context-root>
<valve>
<class-name>org.picketlink.identity.federation.bindings.tomcat.idp.IDPWebBrowserSSOValve</class-name>
</valve>
</jboss-web>
删除valve,参数需迁移到web.xml中:
<context-param>
<param-name>org.picketlink.federation.saml.CHARACTER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>
web.xml中必须配置login-config
<web-app>
...
<login-config>
<auth-method>FORM</auth-method>
</login-config>
</web-app>
注意:idp、sp都要配置auth-method
picketlink.xml sample:
<PicketLink xmlns="urn:picketlink:identity-federation:config:2.1">
<PicketLinkSP xmlns="urn:picketlink:identity-federation:config:2.1" BindingType="POST" SupportsSignatures="true"
ErrorPage="/sso/error.seam" LogOutPage="/sso/logout.seam">
<IdentityURL>http://localhost:8080/idp-sig/</IdentityURL>
<ServiceURL>https://localhost:8443/sso/</ServiceURL>
<KeyProvider ClassName="org.picketlink.identity.federation.core.impl.KeyStoreKeyManager">
<Auth Key="KeyStoreURL" Value="/test.jks"/>
<Auth Key="KeyStorePass" Value="store123"/>
<Auth Key="SigningKeyPass" Value="test123"/>
<Auth Key="SigningKeyAlias" Value="servercert"/>
<ValidatingAlias Key="localhost" Value="servercert"/>
</KeyProvider>
</PicketLinkSP>
<Handlers xmlns="urn:picketlink:identity-federation:handler:config:2.1">
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler">
<Option Key="NAMEID_FORMAT" Value="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"/>
<Option Key="CLOCK_SKEW_MILIS" Value="120000"/>
</Handler>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2SignatureGenerationHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2SignatureValidationHandler"/>
</Handlers>
</PicketLink>
注意:
- 如果升级到EAP 7.1.2后使用picketlink可能会报如下错误:
Error during the logout.: java.lang.NullPointerException
at org.picketlink.identity.federation.bindings.wildfly.sp.SPFormAuthenticationMechanism.lambda$authenticate$0(SPFormAuthenticationMechanism.java:275)
建议7.1.3发布后再升级。
- Undertow Servlet Container有一属性proactive-authentication,默认为true,会拦截所有含有SAMLResponse参数的请求。当项目中使用了其他custom portal时,将其设为"false";
<servlet-container name="default" default-encoding="UTF-8" use-listener-encoding="true" proactive-authentication="false">
<jsp-config/>
<websockets/>
</servlet-container>
Patching EAP
使用CLI应用、回滚、清除Patch
Applying a Patch
patch apply /path/to/downloaded-patch.zip --override-all
shutdown --restart=true
Rolling Backe a Patch
先使用patch history查询出patch id,然后调用rollback命令:
patch history
patch rollback --patch-id=PATCH_ID --reset-configuration=TRUE
shutdown --restart=true
Clearing Patch History
多次打Patch后会占用磁盘空间,可进行清理,但当前应用的Patch是不能删除的。
/core-service=patching:ageout-history
参考文档
Jboss EAP 7.1 Migration Guide
Using the JBoss Server Migration Tool
Configuration Guide
Configuring Messaging
Developing EJB Applications
How to Configure Identity Management
How to Configure Server Security
How To Set Up SSO with SAML v2
Patching and Upgrading Guide