---
title: "JBoss EAP 6常见问题"
author: "sunjing"
date: "2017-06-07T22:47:10Z"
tags: []
categories: ["企业架构"]
slug: "jboss-eap-6"
draft: false
lastmod: "2018-07-31T10:54:06Z"
id: 2378414
url: "https://billben.iteye.com/blog/2378414"
---

**1. Jboss EAP 6 配置 URI\_ENCODING**

In order to set UTF-8 for URI encoding you have to edit the JBOSS\_HOME/standalone/configuration/standalone.xml file and add a system property named org.apache.catalina.connector.URI\_ENCODING,(with value set to UTF-8) to the system-properties element.  
Below is the code that needs to be added to the configuration file you use:

```
<system-properties>
    <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
    <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
</system-properties>
```

Please note that the system-properties node has to be placed directly under the extensions node, in standalone.xml file, or you will get parse errors.

 

可以到jboss maven仓库下载jbossweb源码(org/jboss/web/jbossweb/)，查看org.apache.catalina.connector.Connector的代码（jboss module: org\\jboss\\as\\web\\main\\jbossweb-vesionxx.jar)

 

还有一个编码相关参数file.encoding，可以配置在standalone.conf/standalone.conf.bat的JAVA\_OPTS中：

set "JAVA\_OPTS=%JAVA\_OPTS% -Dfile.encoding=UTF-8

 

**2. javax.xml.transform.TransformerConfigurationException: Translet class loaded, but unable to create translet instance**

同样的ear包，部署在EAP 6时正常，当部署在wildfly 8时报以上错误，原因是我使用了opensaml，版本与wildfly本身提供的不一致，导致相关的xml jar冲突，改为一致的版本后恢复正常（建议使用jboss自带的包）。

 

**3. Driver's Blob representation is of an unsupported type: oracle.sql.BLOB**

删除classpath 中的Oracle驱动包，改为在JBoss module中配置。

 

**4. [JBoss EAP 6 as RHEL 7 service](http://www.dmartin.es/2014/07/jboss-eap-6-as-rhel-7-service/)**

service默认启动超时时间是1min 30s，可在service配置中增加如下配置，延长超时时间：

`TimeoutStartSec=10min`

更多Service参数请参考[systemd.service — Service unit configuration](https://www.freedesktop.org/software/systemd/man/systemd.service.html)

 

**5. TransactionReaper check timeout for TX**

事物超时，在EAP 6 standalone.xml中修改超时时间

&lt;subsystem xmlns="urn:jboss:domain:transactions:1.5"&gt;  
            &lt;core-environment&gt;  
                &lt;process-id&gt;  
                    &lt;uuid/&gt;  
                &lt;/process-id&gt;  
            &lt;/core-environment&gt;  
            &lt;recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/&gt;  
            &lt;coordinator-environment default-timeout="1800"/&gt;  
&lt;/subsystem&gt;

 

**6. Ldap配置例子**

&lt;security-domain name="web-security" cache-type="default"&gt;  
    &lt;authentication&gt;  
        &lt;login-module code="Ldap" flag="required"&gt;  
            &lt;module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/&gt;  
            &lt;module-option name="java.naming.provider.url" value="ldap://boms-prod-file.iata-asd.com:389/"/&gt;  
            &lt;module-option name="java.naming.security.authentication" value="simple"/&gt;  
            &lt;module-option name="principalDNPrefix" value="uid="/&gt;  
            &lt;module-option name="principalDNSuffix" value=",ou=People,dc=bjs,dc=iata,dc=org"/&gt;  
            &lt;module-option name="rolesCtxDN" value="ou=Roles,dc=bjs,dc=iata,dc=org"/&gt;  
            &lt;module-option name="uidAttributeID" value="uniquemember"/&gt;  
            &lt;module-option name="matchOnUserDN" value="true"/&gt;  
            &lt;module-option name="roleAttributeID" value="cn"/&gt;  
            &lt;module-option name="roleAttributeIsDN" value="false"/&gt;  
        &lt;/login-module&gt;  
    &lt;/authentication&gt;  
&lt;/security-domain&gt;

附：启动ldap时显示日志，执行如下命令：  
/usr/local/libexec/slapd -d -1

 

**7. 加密数据库密码**

1\) Setup a Java Keystore to store key for password encryption

利用java keytool执行以下命令：  
keytool -genseckey -alias vault -storetype jceks -keyalg AES -keysize 128 -storepass vault22 -keypass vault22 -validity 730 –keystore EAP\_HOME/vault/vault.keystore  
2\) Initialize the Password Vault and store password in the Password Vault  
EAP\_HOME/bin/vault.sh --keystore EAP\_HOME/vault/vault.keystore --keystore-password vault22 --alias vault --vault-block ds\_boms --attribute password --sec-attr test --enc-dir EAP\_HOME/vault/ --iteration 120 --salt 1234abcd  
3\) Configure JBoss EAP 6 to use the Password Vault

登录Jboss CLI执行以下命令：  
/core-service=vault:add(vault-options=\[("KEYSTORE\_URL" =&gt; "EAP\_HOME/vault/vault.keystore"), ("KEYSTORE\_PASSWORD" =&gt; "MASK-5dOaAVafCSd"), ("KEYSTORE\_ALIAS" =&gt; "vault"), ("SALT" =&gt; "1234abcd"),("ITERATION\_COUNT" =&gt; "120"), ("ENC\_FILE\_DIR" =&gt; "EAP\_HOME/vault/")])  
4\) Datasource Definition Using a Password in Masked Form  
&lt;password&gt;${VAULT::ds\_boms::password::1}&lt;/password&gt;

详细信息请参见：[Password Vaults for Sensitive Strings](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/sect-Password_Vaults_for_Sensitive_Strings.html#Configure_the_Enterprise_Application_Platform_to_Use_the_Password_Vault1)

 

**8, 设置log时区**

使用%z，注意一定要放在%d前：

%z{GMT+8}%d{HH:mm:ss,SSS}

 

**9. 配置HTTPS**

```
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https">
   <ssl name="https" key-alias="alias" password="12345678" certificate-key-file="${jboss.server.config.dir}\keystore.jks"/>
</connector>
```

 

**10. 自动删除JSP编译的类**

默认undeploy时会自动删除vfs下的lib，但不会删除work目录下的文件，deploy时JSP不会重新编译。增加系统参数org.jboss.as.web.deployment.DELETE\_WORK\_DIR\_ONCONTEXTDESTROY=true，然后重启Jboss，下次undeploy时就会自动删除了。

 

**11. java.sql.SQLException: javax.resource.ResourceException: IJ000457: Unchecked throwable in managedConnectionReconnected**

使用xa datasource，并添加以下参数：

&lt;xa-pool&gt;  
   &lt;is-same-rm-override&gt;false&lt;/is-same-rm-override&gt;  
   &lt;no-tx-separate-pools/&gt;  
/xa-pool&gt;

 

**12. 删除x-powered-by header**

在domain:web中增加jsp-configuration

```
<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <configuration>
        <jsp-configuration x-powered-by="false"/>
    </configuration>
</subsystem>
```

 如使用JSF，在web.xml中增加：

```
<context-param>
        <param-name>com.sun.faces.sendPoweredByHeader</param-name>
        <param-value>false</param-value>
</context-param>
```

 

**13. JNDI Datasource配置**

 这种方式不大使用了，一般采用JPA方式，升级老系统可能会用到。

1\) 在jboss-web.xml中增加如下配置 

```
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
       <resource-ref>
        <res-ref-name>jdbc/ExampleDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jboss/datasources/ExampleDS</jndi-name>
    </resource-ref>
</jboss-web>
```

2\) 在web.xml中增加如下配置

```
<resource-ref>
  <res-ref-name>jdbc/ExampleDS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
```

3\) Java代码

```
Context ctx = new InitialContext();
DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/ExampleDS");
```

注意：J2EE规范，JDBC DataSource必须使用java:comp/env/jdbc subcontext。

 

**14. 如何配置Picket Link的Character Encoding?**

```
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <security-domain>sp</security-domain>
    <context-root>hello</context-root>
    <valve>
        <class-name>org.picketlink.identity.federation.bindings.tomcat.sp.ServiceProviderAuthenticator</class-name>
        <param>
            <param-name>characterEncoding</param-name>
            <param-value>GBK</param-value>
        </param>
    </valve>
</jboss-web>
```

 

[Jboss EAP 6.4 Administration and Configuration Guide](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/index.html)

[Jboss EAP 6.4 Development Guide](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/index.html)

[Control the order of Deployed Applications on JBoss EAP 6](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/Control_the_order_of_Deployed_Applications_on_JBoss_Enterprise_Application_Platform.html)

[Running Multiple JBoss EAP Standalone Servers on a Single Machine](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/sect-Start_and_Stop_JBoss_EAP_6.html#Running_Multiple_JBoss_EAP_Standalone_Servers_on_a_Single_Machine)

[Replace the Default Welcome Web Application](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/Replace_the_Default_Welcome_Web_Application1.html)

[Setting up an SSL/TLS Connector](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html/how_to_configure_server_security/securing_the_server_and_its_interfaces#setting_up_an_ssl_tls_connector)

[Ldap Login Module](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Security_Guide/chap-Login_Modules.html#LdapLoginModule1)

[JBoss EAP 6 Performance Tuning](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/sect-Performance_Tuning.html)

[JBoss EAP 6 Temporary Queues and Runtime Queues](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/sect-Configuration1.html)

[Jboss Web System Properties](http://docs.jboss.org/jbossweb/7.0.x/sysprops.html)

[Patching JBoss EAP 6](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Installation_Guide/sect-Patching_JBoss_EAP_6.html)

[J2EE and JNDI - The Application Component Environment](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Web_Platform/5/html/Administration_And_Configuration_Guide/Naming_on_JBoss-J2EE_and_JNDI___The_Application_Component_Environment.html)

[**How to Setup SSO with SAML v2**](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html/how_to_setup_sso_with_saml_v2/)

[**Setting up single sign-on using Active Directory with ADFS and SAML**](https://support.zendesk.com/hc/en-us/articles/203663886-Setting-up-single-sign-on-using-Active-Directory-with-ADFS-and-SAML-Professional-and-Enterprise-HdNzLAeXD8QJ3KuArlNJ)

[**Picket Link**](http://picketlink.org/)

[**Picket Link Doc**](https://docs.jboss.org/author/display/PLINK/Home)