Advertise with us

Search Mastertheboss

Our eBooks

jboss.xml reference

JBoss xml reference

 

JBoss AS uses a set of custom xml descriptors which can be used to customize Enterprise applications. Today they are not used so widely as once, because they have been replaced by their equivalent annotations. Though it can be useful to have a reference to most common XML configuration file, if you need to mantain older Enterprise applications, or if you prefer to mantain your configutation separated from your code.

 

In this tutorial we will cover the following files:

 

  • jboss.xml
  • jboss-web.xml

 

jboss.xml

 

This descriptor can be used if your EJB do not use annotations to declare themselves as EJB.

It needs to be deployed in your EJB jar ander the META-INF folder.

 

Here's a sample jboss.xml file which can be used to declare a Session Bean and a Message driven Bean:



<jboss>
	<enterprise-beans>
		<session>
			<ejb-name>StatelessTest</ejb-name>
			<jndi-name>StatelessTest</jndi-name>
		</session>
		<message-driven> 
                           <ejb-name>SimpleMessageBean</ejb-name> 
                           <destination-jndi-name>queue/MyQueue</destination-jndi-name> 
                  </message-driven>
	</enterprise-beans>
</jboss>

Here's an advanced jboss.xml containing a cluster definition and a security domain



<jboss>

   <enterprise-beans>
	<session>
		<ejb-name>ShoppingCart</ejb-name>
		<jndi-name>ShoppingCart</jndi-name>
		<clustered>true</clustered>
		<cluster-config>
			<partition-name>DefaultPartition</partition-name>
			<load-balance-policy>
				org.jboss.ha.framework.interfaces.RandomRobin
			</load-balance-policy>
		</cluster-config>
		<security-domain>tutorial-test</security-domain>
	</session>
	<session>
		<ejb-name>StatelessTest</ejb-name>
		<jndi-name>StatelessTest</jndi-name>
	</session>
</enterprise-beans>
</jboss>


jboss-web.xml

 

This file descriptor can be bundled in a web application under the WEB-INF folder to define some specific configuration elements, related to the Web application context or to the Security configuration.

 

Here's an example which defines a custom context root for the Web application


<jboss-web>
    <context-root>bank</context-root>
</jboss-web>


Here's a jboss-web.xml example which uses the JaasSecurityMgr other security domain for authentication and authorization of secured web content.defines the security a custom context root for the Web application.
<jboss-web>
    <!-- Use the JaasSecurityMgr other security domain for authentication
      and authorization of secured web content.
     -->
    <security-domain>java:/jaas/other</security-domain>
</jboss-web>


 Here's an example which uses jboss-web.xml to define a Virtual Host

Note that when a WAR file is deployed, it is associated by default with the virtual host whose name matches the defaultHost attribute of the containing Engine.
To deploy a WAR to a specific virtual host you need to specify an appropriate virtual-host definition in your jboss-web.xml descriptor.
The following jboss-web.xml descriptor demonstrates how to deploy a WAR to the virtual host www.myhost.com.

<jboss-web>
 <context-root>/</context-root>
 <virtual-host>www.myhost.com</virtual-host>
</jboss-web>


The above virtual host needs to match the corresponding Host alias defined in the server.xml file

<Host name="myhost.com" autoDeploy="false" deployOnStartup="false" deployXML="false">
 <Alias>www.myhost.com</Alias>
</Host>

© 2021 mastertheboss.com. All Rights Reserved.

Please publish modules in offcanvas position.