I have grouped my Jboss 7 server, Postgres database and test.bat into a demo.exe file using Advanced Installer. When file i.e demo.exe file double clicked on the client side then test.bat file runs and it deploys JBoss and postgres at the predefined location and the service starts and my application runs at the port number 8080 .All the script has been written to test.bat file .This demo.exe file has to used by different users . It may be possible that 8080 might be used or engaged by different application on client side.
So how can i change port number of jboss dynamically on the client side as per port usage? Do i have to use any Jboss installer or write scipt on batch file i.e test.bat ? Not able to click things or right approach :(
Any help will be highly appreciated and will be thankful .
You can do this using CLI
. This example changes the port from 8081 to 8080:
Start CLI (in .../bin/
):
$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
Connect
[disconnected /] connect
Change into the target area
[standalone@localhost:9999 /] cd /socket-binding-group=standard-sockets/socket-binding=http
Show the current state:
[standalone@localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8081 INT
Change the port attribute:
[standalone@localhost:9999 socket-binding=http] :write-attribute(name="port", value="8080")
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
Note that the process-state is "reload-required"
Look again:
[standalone@localhost:9999 socket-binding=http] ls -l
ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address 127.0.0.1 STRING
bound-port 8081 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8080 INT
Note that here as well the bound-port
is still at the old value.
So go back to the root directory
[standalone@localhost:9999 subsystem=web] cd /
Reload
[standalone@localhost:9999 /] :reload
{
"outcome" => "success",
"response-headers" => {"process-state" => "reload-required"}
}
That means that the reload is still in progress, again
[standalone@localhost:9999 /] :reload
{"outcome" => "success"}
Now the HTTP connector should listen on the new port.
Update
The question asks for changing the port dynamically (JBoss is up and running).
The other option is to write the port into the configuration file (standalone.xml
). This is statically, but it will probably work as well as for installation purposes.