Using the CLI:
$ bin/jboss-cli.sh or bin\jboss-cli.bat
[standalone@localhost:9999 /] patch apply /path/to/downloaded-patch.zip
[standalone@localhost:9999 /] shutdown --restart=true
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-commercial-5.1.24-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Deployments in AS7 are also modules, and do not have access to classes that are defined in jars in the application server unless an explicit dependency on those classes is defined.
jboss-eap-6.3.3.rpm
jboss-config-1.0.0.rpm
Do not confuse our domains with JBoss managed domains!
/opt/jboss
/var/lib/jboss/domains/<DOMAIN_NAME>
$ export JAVA_HOME={java_home}
$ export JBOSS_HOME={jboss_home}
$ export JBOSS_BASE_DIR={base_dir}
$ export PRESERVE_JAVA_OPTS=true
$ export JAVA_OPTS="{java_opts}"
$ {jboss_home}/bin/standalone.sh
$ {jboss_home}/bin/jboss-cli.sh
$ [disconnected /] connect :{admin_port}
[standalone@localhost:{admin_port} /]
Local mgmt with CLI does not need a user.
/socket-binding-group=standard-sockets/socket-binding={channel_name}:add(interface=internal,port={listen_port})
This CLI cmd is to add a socket-binding on internal interface and the listen port.
But what if the socket-binding exists?
Check the if-else control flow!
[standalone@localhost:7012 /] /socket-binding-group=standard-sockets/socket-binding=http_1:add(interface=internal,port=7010)
{
"outcome" => "failed",
"failure-description" => "JBAS014803: Duplicate resource [
(\"socket-binding-group\" => \"standard-sockets\"),
(\"socket-binding\" => \"http_1\")
]",
"rolled-back" => true
}
[standalone@localhost:7012 /]
The creation failed because of duplicate resource.
if outcome==success of /socket-binding-group=standard-sockets/socket-binding={channel_name}:read-resource
/socket-binding-group=standard-sockets/socket-binding={channel_name}:write-attribute(name=interface,value=internal)
/socket-binding-group=standard-sockets/socket-binding={channel_name}:write-attribute(name=port,value={listen_port})
else
/socket-binding-group=standard-sockets/socket-binding={channel_name}:add(interface=internal,port={listen_port})
end-if
This is how to do Create or Update.
import org.jboss.as.cli.scriptsupport.CLI.Result;
import org.jboss.dmr.ModelNode;
public class LifecycleHooksDeploy extends LifecycleHooksBase {
@Override
public void execute() {
Result result = cli.cmd("/socket-binding-group=standard-sockets/socket-binding={channel_name}:read-resource");
ModelNode response = result.getResponse();
if ("success".equals(response.get("outcome").asString())) {
// Update the socket-binding here.
} else {
// Add the socket-binding here.
}
}
}
public int execute() {
try {
LifecycleHooksBase lifecycleHooksBase = (LifecycleHooksBase) Class.forName(command).newInstance();
lifecycleHooksBase.init(envProps);
try {
lifecycleHooksBase.execute();
} catch (Exception e) {
throw e;
} finally {
lifecycleHooksBase.fini();
}
} catch (Exception e) {
LOG.log(Level.FINE, "Failed to execute JBoss script: " + command, e);
LOG.severe("Failed to execute JBoss script: " + e.getMessage());
return 1;
}
return 0;
}