Buscar este blog

miércoles, 22 de abril de 2015

Eclipse + JBoss: Configure multiple isolated profiles

Working with multiples projects in eclipse and JBoss usually leads to a big and complex JBoss configuration file (for example, standalone.xml). Each project has specific requierements as datasources, JNDI naming properties or even SSL config.

Eclipse handles this situations with mutliples workspaces, each containing only related projects. But with JBoss the case is a bit complex if, for example, all projects use standalone configuration.

Once again, working with eclipse and JBoss Tools you can manage multiple configurations of the server with just a few tweaks.

By default, JBoss has these folders:
  • standalone/configuration. Contains all xml config files.
  • standalone/deployments. Directory being periodically scanned  by JBoss in order to discover new wars to deploy.

So, we are going to duplicate these folders to handle two diferents eclipse workspaces:
  • standalone/configuration_ws1
  • standalone/configuration_ws2
  • standalone/deployments_ws1
  • standalone/deployments_ws2
Once you had copied thes folders, you have to edit the configuration file that will be used in each workspace. In the sake of simplicity, we will suppose all workingsets work with standalone.xml.
You have to edit each standalone.xml and change the following lines:
   
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
    <deployment-scanner path="deployments_ws1" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>

In this way you set the deployments folder of each workingset relative to jboss base dir, i.e, standalone.


Now, in eclipse, you have to create the server as usual, but in "configuration file" you have to put the relative route to the working set, for example, ../confinguration_ws/standalone.xml.



The next step is modify VM arguments of the launch configuration. There, you have to specify the property "-Djboss.server.config.dir" to the absolute path of the configuration folder.



Then you have to tell eclipse where to send its deployments in order JBoss can scan them.
In deployment tab, you have to check "Use a custom deploy folder" and set de propper value.



And finally, in order to be able to edit JBoss configuration file from eclipse, you have to configure Filesets.



Done.

No hay comentarios:

Publicar un comentario