Set system properties in standalone-full.xml in wildfly 8.2 - jboss

I have added system-properties tag in standalone-full.xml, but its not working in standalone mode. However, if I add the same tag in domain.xml it's working for domain mode.
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:2.2">
<extensions>
....
</extensions>
<system-properties>
<property name="java.util.Arrays.useLegacyMergeSort" value="true"/>
</system-properties>
</server>
According to this article on jBoss General configuration concepts
System property values can be set in a number of places in domain.xml, host.xml and standalone.xml.
Then what about standalone-full.xml?
I don't want to set it through command line and not even in java code.

In standalone it's probably too late to set it in the configuration files. You'll need to add it to the standalone.conf or standalone.conf.bat in the JAVA_OPTS environment variable. A global property like that needs to be set before anything else attempts to use java.util.Arrays.

If you have started the Wildfly server with standalone-full.xml instead of standalone.xml(the default) than this should be reflected in the start of the server:
standalone.sh -b <hostIP> -c standalone-full.xml -Dorg...
Then this will have effect on first start.
If you change something in this config file, you will need to reload Wildfly(configuration) from jboss cli:
[standalone#localhost:9990 /] :reload

For Wildfly 10 it's working nontheless. I was able to read the property for an instance started with the standalone-full.xml containing some properties.
The manual must be outdated then I guess? Because even Wildfly itself inserts a new property in the standalone-full.xml when using the Wildfly admin webinterface: http://localhost:9990 > Configuration > System Properties (Wildfly will add the property of course to the xml config which was used to start the instance). That's enough proof for me.

Related

(Keycloak) Freemarker Template system properties and environment variables

We wanted to work on the Templates and tried to get the system properties that we set earlier in the standalone.xml file like this.
</extensions>
<system-properties>
<property name="testProp" value="TestVal"/>
</system-properties>
In the Docs of Keycloak its described like the following.
${some.system.property} - for system properties
${env.ENV_VAR} - for environment variables.
But nothing worked for us. We always get the following error Message “An internal server error has occurred”.
What is the right way to get the system properties and the environment variables in the Freemarker Template?
Keycloak Theme Property Documentation
is missing how to add them in the template.
It is however just a bit lower in the same document
So in theme.properties could be
customPropInThemeProperties=${env.SOME_OTHER_RESOURCE_URL}
Then uses in .ftl as
${properties.customPropInThemeProperties}
In order to use system properties in the freemarker template of keycloak, do the following configuration.
Declare your system properties in the standalone.xml
<system-properties>
<property name="UATLogin" value="http://localhost:9090" />
</system-properties>
Add variable inside theme.properties to access the system property.
UATURL=${UATLogin}
As an example, I have done the testing with register.ftl
<span>${kcSanitize(msg("backToLogin"))?no_esc}</span>

Wildfly subsystem configuration attribute not allowed here

I would like to set in the WildFly/JBoss ejb3 subsystem enable-graceful-txn-shutdown to true.
Tried two approaches:
<subsystem xmlns="urn:jboss:domain:ejb3:4.0" enable-graceful-txn-shutdown="true">
and
<subsystem xmlns="urn:jboss:domain:ejb3:4.0">
<enable-graceful-txn-shutdown value="true"/>
Both times I got a Validation error in standalone.xml:
'enable-graceful-txn-shutdown' isn't an allowed attribute for the
'subsystem'
element 'enable-graceful-txn-shutdown' isn't an allowed
element here
What is the right place?
Your subsystem tag's namespace is incorrect, enable-graceful-txn-shutdown isn't defined in urn:jboss:domain:ejb3:4.0 but in urn:jboss:domain:ejb3:5.0 (which is new in Wildfly 11).
If you check the XSD defining this namespace (which can be found in the docs/schema dir of your wildfly install, in this case as the wildfly-ejb3_3_5_0.xsd file), you'll find as Omoro pointed out that this tag should be at the root of your subsystem with a value boolean attribute, i.e.
<subsystem xmlns="urn:jboss:domain:ejb3:5.0">
<enable-graceful-txn-shutdown value="true"/>

JBoss EAP 6 configure single server for remote debugging in domain mode

I have Domain controller, one Host controller and one server running in the same machine.
I'm using IDEA to connect to the remote server for debugging but it's not stopping on break points even though it's running the code (i've verified with system outs).
I've enabled HOST_CONTROLLER_JAVA_OPTS and PROCESS_CONTROLLER_JAVA_OPTS for remote debugging in $JBOSS_HOME/bin/domain.conf:
# Sample JPDA settings for remote socket debuging.
PROCESS_CONTROLLER_JAVA_OPTS="$PROCESS_CONTROLLER_JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8788,server=y,suspend=n"
HOST_CONTROLLER_JAVA_OPTS="$HOST_CONTROLLER_JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
When i start JBoss server i can see from netstat that it's properly listening to ports 8787 and 8788. If i list the processes running in the system i can see one for Domain controller, one for Host controller and one for the server (server1). Domain and Host controllers have the debug options specified in their launch properties but they're missing for server1.
I've been looking at the various XML, .conf and .sh files for a while now but i can't figure out how i could specify server1 to use the remote debugging options. Is there a way to remotely debug a single server in domain mode?
JHollanti maybe you are missing some compiler flags (like "lines,vars,source") to allow remote debugging.
For example, is you are using Ant you need to add this lines to your javac:
<!-- Javac lines, vars, source compiler flags -->
<javac srcdir="..." destdir="..." classpathref="..." debug="true" debuglevel="lines,vars,source" />
Then in your execution script you jave to add:
<!-- debug configurations: modify the port you want-->
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4060"/>
On the other hand, if you are using Maven same flags can be added in the , like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<!-- Necessary in order for the debug levels to be considered-->
<debug>true</debug>
<debugLevel>lines,vars,source</debugLevel>
</configuration>
</plugin>
</plugins>
</build>
In case of using Jetty, same as before... you need to have the following variable:
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
On the other hand, what you can check is setting the suspend flag in yes, it is "suspend=y". This won't start your app unless you connect a debugger.
Here you can check specific info about jboss:
http://webdev.apl.jhu.edu/~jcs/ejava-javaee/coursedocs/605-784-site/docs/content/html/devenv-jboss-setup.html#enable-jboss-debug
Hope to help
Hey I don't have a solution to this however I was able to set the port for server one along with host and process controllers as well.
How I did it : I added the "-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" to the JVM arguments on the jboss admin console.
Steps:
1) Login to admin console of jboss => localhost:9990/console
2) go to servers => select server 1 in the table.
3) Then add the debug string into JVM arguments text box.
Once you restart your server you'll see now the server one is listening on this port.
However problem came when I tried to run my eclipse in debug mode. Though on the sever I could see the connection was established through netstat however eclipse is not able to communicate to server 1 and it times out.
Important thing to be noticed is I'm able to run eclipse in debug mode if I do what you did in domain.conf file and use those ports; however then the control never comes to my breakpoint in eclipse.
You can enable remote debugging by adding jvm-options in $JBOSS_HOME$\domain\configuration\hosts.xml
Add the following configuration under <servers> -> <server> -> <jvm>
<jvm-options>
<option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/>
</jvm-options>
your server configuration in hosts.xml should look something similar to this
<servers>
<server name="Server1" group="Group1" auto-start="true">
<jvm name="Server1_JVM" debug-enabled="false">
<heap size="2048m" max-size="4096m"/>
<jvm-options>
<option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/>
</jvm-options>
</jvm>
<socket-bindings socket-binding-group="full-ha-sockets" port-offset="100"/>
</server>
</servers>
Hope this helps!

JBoss domain dynamic port offset configuration

I cannot seem to get configuring port-offsets via properties file on the domain managed setup to start multiple server instances in a server group.
I have the following configuration in host.xml:
<servers>
<server name="instance-one" group="main-server-group" auto-start="true">
<socket-bindings port-offset="${jboss.instance1.offset}"/>
</server>
<server name="instance-two" group="main-server-group" auto-start="true">
<!-- server-two avoids port conflicts by incrementing the ports in
the default socket-group declared in the server-group -->
<socket-bindings port-offset="${jboss.instance2.offset}"/>
</server>
</servers>
The properties are configured via properties file (custom-domain.properties):
jboss.domain.base.dir=custom-domain
jboss.instance1.offset=10300
jboss.instance2.offset=20300
And I try to startup the domain using
./domain.sh -P=custom-domain.properties
The problem is that jboss.instance1.offset and jboss.instance2.offset are not being applied to the corresponding properties in host.xml. If I have hardcoded values in the host.xml it appears to start up instance 1 and instance 2 on the hardcoded port offsets.
Does custom property configuration not work in domain setup?
Thanks for any help.

Loading properties from a file in a JBoss 6 Web Application

Can I dump a properties file somewhere in one of the JBoss 6 directories, and pick it up from the classpath?
Or even better, does anybody know the mechanism behind a configuration file like $JBOSS_HOME/server/default/deploy/jboss-logging.xml? Changes to this file seem to trigger an event, so that a running instance can process the modifications (without having to bounce the AS).
A possibility is to configure SystemPropertiesService in ./conf/jboss-service.xml.
This allows you to configure system properties in-place, or load them from a properties file:
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
name="jboss.util:type=Service,name=SystemProperties">
<!-- Load properties from each of the given comma seperated URLs -->
<attribute name="URLList">
http://somehost/some-location.properties,
./conf/somelocal.properties
</attribute>
<!-- Set propertuies using the properties file style. -->
<attribute name="Properties">
property1=This is the value of my property
property2=This is the value of my other property
</attribute>
</mbean>
</server>
For more details, refer to: http://docs.jboss.org/jbossas/admindevel326/html/ch10.html
They have made this even easier in JBoss EAP 6 (AS 7).
Pass Property File as Startup Parameter
This can be added within the main start up script or passed as parameter
./standalone.sh --properties=/Users/john.galt/dev/config/ds/jboss.properties
If these properties are read, they will be rendered in the server log as the first statement.
3:58:41,633 DEBUG [org.jboss.as.config] (MSC service thread 1-6) Configured system properties:
DSsettings.password = password
DSsettings.user-name = admin
DSsettings.connection-url = jdbc:oracle:fat:#activedb:1521:DEV
[Standalone] =
awt.nativeDoubleBuffering = true
NOTE: As these settings are logged in server log, ensure no clear text passwords are in the property files in production
Use passed in system properties
You could use these system properties with following syntax.
Example Usage in a data source file
<xa-datasource jndi-name="java:jboss/ds" pool-name="cPool" jta="true" enabled="true" use-ccm="true">
<xa-datasource-property name="URL">
${DSsettings.connection_url}
</xa-datasource-property>
<driver>oracle</driver>
...
<security>
<user-name>${DSsettings.user-name}</user-name>
<password>${DSsettings.password}</password>
</security>
...
</xa-datasource>
In JBoss 6 use: ./deploy/properties-service.xml
On JBoss AS7 properties-service.xml no longer exist, the below is the solution:
http://www.mastertheboss.com/jboss-server/jboss-configuration/how-to-inject-system-properties-into-jboss