Multiple JBoss with Binding file
From Initq
Introduction
We have posted other articles explaining how to change ports so you can have multiple JBoss instances. This required editing vast number of files and could introduce many errors. The following is a cleaner way to indicate ports in one file.
Copy Server Instance
Please make sure JBoss is not running while you copy your instance. Clean out all the log and tmp files. You may copy /JBoss_Home/server/default/ or copy the server you already use. We like to put ports-01 at the end of the server name ( /JBoss_Home/server/apptricityerm40_ports-01/).
Copy Application directory
We use /apptricity_erm_40 as our application directory so we will make a copy of that also.
- cp /apptricity_erm_40/ /apptricity_erm_40_ports-01/
Binding File
Copy the Binding file from examples.
- cp /JBoss_Home/docs/examples/binding-manager/sample-bindings.xml /JBoss_Home/server/apptricityerm40_ports-01/conf
Rename the file
- mv /JBoss_Home/server/apptricity40_ports-01/conf/sample-bindings.xml /JBoss_Home/server/apptricityerm40_ports-01/conf/bindings.xml
Edit JBoss_Home/server/apptricityerm40_ports-01/conf/jboss-service.xml
<!-- ==================================================================== -->
<!-- Service Binding -->
<!-- ==================================================================== -->
<!-- Automatically activated when generatting the clustering environment -->
<!-- @TESTSUITE_CLUSTER_CONFIG@ -->
<!--
| Binding service manager for port/host mapping. This is a sample
| config that demonstrates a JBoss instances with a server name 'ports-01'
| loading its bindings from an XML file using the ServicesStoreFactory
| implementation returned by the XMLServicesStoreFactory.
|
| ServerName: The unique name assigned to a JBoss server instance for
| lookup purposes. This allows a single ServicesStore to handle mulitiple
| JBoss servers.
|
| StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
| during initialization that specifies how to connect to the bindings store.
| StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
| implementation to create to obtain the ServicesStore instance.
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-01</attribute>
<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
-->Uncomment the mbean section and make two changes.
- Check ServerName
Make sure it says ports-01.
- Change StoreURL path to
/server/apptricityerm40_ports-01/conf/bindings.xml
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-01</attribute>
<attribute name="StoreURL">${jboss.home.url}/server/apptricityerm40_ports-01/conf/bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>View JBoss_Home/server/apptricityerm40_ports-01/conf/binding.xml
The bindings file already has default ports section (8080) defined. It also has port 8180, 8280 and 8380 defined.
- ports-default links to 8080
- ports-01 links to 8180
- ports-02 links to 8280
- ports-03 links to 8380
If you need more ports just copy a section of the of 8180, paste it at the bottom of the binding.xml file and change
- <server name="ports-01"> to <server name="ports-04">
- You will also need to change all the ports in your pasted section so it does not conflict with any other section. example: 8180 should be changed to 8480 and so on. Second digit of all the ports should be a 4.
Edit /JBoss_Home/server/apptricityerm40_ports-01/deploy/jboss-web.deployer/server.xml
This is for our application where we have defined some local variables that also need changing.
<Context path="/app_files" appBase="" docBase="C:/apptricity_erm_40_ports-01/app_files" debug="99" reloadable="true"> </Context> <Context path="/apptricitylogos" appBase="" docBase="C:/apptricity_erm_40_ports-01/apptricitylogos" debug="99" reloadable="true"> </Context>
Edit JBoss_Home/server/apptricityerm40_ports-01/deploy/ds.xml
Make sure to edit your database connection file and point it to the correct database.
Edit /JBoss_Home/bin/run files
Create run40_ports-01.sh or run40_ports-01.bat. The file should have the following in it
start runapptricityerm40_ports-01.bat -c apptricityerm40_ports-01 -Djboss.service.binding.set=ports-01 -Djboss.messaging.ServerPeerID=1 -Djboss.bind.address=0.0.0.0
If you will be running things on ports-02 then change the above file to point to ports-02 and the ServerPeerID=2.
Copy run.bat to runapptricityerm40_ports-01.bat then check the following:
- set JAVA_HOME=C:\jdk1.5.0_09
Use which ever version of jdk you desire. Set any other variables that your application requires.
set APPTRICITY_ERM_HOME=c:\apptricity_erm_40_ports-01 set JAVA_OPTS=-Dapptricity.properties.file=%APPTRICITY_ERM_HOME%\apptricityconf\apptricity.properties -Djava.security.auth.login.config=%APPTRICITY_ERM_HOME%\apptricityconf\auth.conf %JAVA_OPTS%
Edit Local application files
/apptricity_erm_40_ports-01/apptricityconf/apptricity.properties
Search the entire file and fix all references to ports-01.
/apptricity_erm_40_ports-01/apptricityconf/apptricitylog.properties
Make sure the log paths are correct in this file.
