Migrate the Oracle WebLogic Server weblogic.xml Descriptor File Configurations to JBoss Enterprise Application Platform 6 or 7

Updated -

Summary

The Orace WebLogic Server weblogic.xml deployment descriptor file provides functionality that is not included in the standard Java EE specification. While there is no direct mapping of these descriptor elements, many of these features may be configured in the application deployment or JBoss server configuration files. This article provides examples of how to map a few common configurations. For more information on how to configure the JBoss server, refer to the Administration and Configuration Guide for JBoss Enterprise Application Platform 6 or 7 on https://access.redhat.com/site/documentation/JBoss_Enterprise_Application_Platform/.

Example weblogic.xml File

This weblogic.xml file is used for the examples below.

​<weblogic-web-app>
​    <context-root>MyAppContextRoot</context-root>​
​    <security-role-assignment>
​        <role-name>TestRole1</role-name>
​        <principal-name>TestRole1</principal-name>
​    </security-role-assignment>
​​    <security-role-assignment>
​        <role-name>TestRole2</role-name>
​        <principal-name>TestRole2</principal-name>
​    </security-role-assignment>
​    <session-descriptor>
​        <session-param>
​            <param-name>TimeoutSecs</param-name>
​            <param-value>3650</param-value>
​        </session-param>
​    </session-descriptor>
​    <container-descriptor>
​        <save-sessions-enabled>true</save-sessions-enabled>
​        <prefer-web-inf-classes>true</prefer-web-inf-classes>
​    </container-descriptor>
​​    <jsp-descriptor>
​        <jsp-param>
​            <param-name>keepgenerated</param-name>
​            <param-value>true</param-value>
​        </jsp-param>
​        <jsp-param>
​            <param-name>encoding</param-name>
​            <param-value>ISO8859_1</param-value>
​        </jsp-param>
​    </jsp-descriptor>
​</weblogic-web-app>

Map weblogic.xml Configurations to JBoss

weblogic.xml JBoss Equivalent
Specify the context root:

<context-root>MyAppContextRoot</context-root>
Specify the context root in the WEB-INF/jboss-web.xml file:

<jboss-web>
    <context-root>MyAppContextRoot</context-root>
</jboss-web>
Map roles:

<security-role-assignment>
    <role-name>TestRole1</role-name>
    <principal-name>TestRole1</principal-name>
</security-role-assignment>
Use the RoleMappingLoginModule in the server configuration file:

<security-domain name="FormBasedAuthWebAppPolicy">
    <authentication>
        <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
            <module-option name="dsJndiName" value="java:/MySQLDS"/>
            <module-option name="principalsQuery" value="select password from  PRINCIPLES where principal_id=?"/>
            <module-option name="rolesQuery" value="select user_role, 'Roles' from  ROLES where  principal_id=?"/>
        </login-module>
        <!-- Following is the RoleMappingLoginModule -->    
        <login-module code="org.jboss.security.auth.spi.RoleMappingLoginModule" flag="optional">
            <module-option name="rolesProperties" value="/home/userone/jboss-eap-6.0-GA/standalone/configuration/test-roles.properties"/>
            <module-option name="replaceRole" value="false"/>
        </login-module>
    </authentication>
</security-domain> 

Then add the following to the WEB-INF/jboss-web.xml file:

<jboss-web>
    <security-domain>java:/jaas/FormBasedAuthWebAppPolicy</security-domain>
</jboss-web>
Specify Session Timeout:

<session-descriptor>
    <session-param>
        <param-name>TimeoutSecs</param-name>
        <param-value>3650</param-value>
    </session-param>
</session-descriptor>
Add the following to the WEB-INF/jboss-web.xml:

<session-config>
    <session-timeout>3650</session-timeout>
</session-config>
Specify class loading precedence:

<container-descriptor>
    <save-sessions-enabled>true</save-sessions-enabled>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
Because the WAR has its own scoped class loader, the classes packaged in the WEB-INF/lib and WEB-INF/classes directories will always be loaded from inside the Web Application. There is no known alternative/relative configuration in JBoss.
Configure JSPs:

<jsp-descriptor>
    <jsp-param>
        <param-name>keepgenerated</param-name>
        <param-value>true</param-value>
    </jsp-param>
    <jsp-param>
        <param-name>encoding</param-name>
        <param-value>ISO8859_1</param-value>
    </jsp-param>
</jsp-descriptor>
In JBoss EAP 6, you configure JSPs in the web subsystem of the server configuration file.

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
    <configuration>
        <jsp-configuration development="true" java-encoding="ISO8859_1" keep-generated="true"/>
    </configuration>
    <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>
In JBoss EAP 7, you configure JSPs in the undertow subsystem of the server configuration file.

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <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 keep-generated="true" java-encoding="ISO8859_1"/>
    </servlet-container>
</subsystem>

2 Comments

Hello,

Does this apply to EAP 7 or is there another article for that?

Thanks!

Yes. This also applies to JBoss EAP 7. I updated the article to indicate that fact.