Wildfly 8.0 Passing parameters to standalone.xml file - jboss

We are using wildfly 8.0 version for our legacy application. We are trying to pass datasource value as parameter in standalone.xml file but wildfly is throwing error as it's not recognizing $ sign.
standalone.xml
${DB_URL}
can anyone explain how to pass parameters in wildfly 8.0 server. We are starting our server as service.
service wildfly start
Here is snippet of standalone.xml
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasource jta="false" jndi-name="java:jboss/postgresDSPC" pool-name="postgresDSPC" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>${DB_URL}</connection-url>
<driver>postgresql</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>50</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>
Here is the value I see when I read using jboss-cli
"connection-url" => {
"type" => STRING,
"description" => "The JDBC driver connection URL",
"expressions-allowed" => true,
"nillable" => false,
"min-length" => 1L,
"max-length" => 2147483647L,
"access-type" => "read-write",
"storage" => "configuration",
"restart-required" => "no-services"
},
Thanks
Rakesh

For environmental variables you will have to use the env. prefix. e.g.
${env.DB_URL}

Related

Widlfly 20: Web.xml and standalone.xml configs for datasource

I have a ejb-based application deployed initially in jboss AS 5.0 that i'm upgrading to wildfly 20, the problem is that i cant resolve correctly the datasources defined in web.xml in the datasource section in standalone.xml
<resource-ref>
<res-ref-name>Midd2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<mapped-name>jdbc/SybaseDB</mapped-name>
</resource-ref>
<resource-ref>
<res-ref-name>Midd</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<mapped-name>jdbc/SybaseDS2</mapped-name>
</resource-ref>
My datasources in standalone.xml
<datasource jndi-name="java:/jdbc/SybaseDB" pool-name="SybaseDB">
<connection-url>jdbc:sybase:XXXX.XXXX.XXXX.XXXX/database</connection-url>
<driver-class>com.sybase.jdbc3.jdbc.SybDriver</driver-class>
<driver>
jconn3.jar
</driver>
<security>
<user-name>x</user-name>
<password>y</password>
</security>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
</pool>
</datasource>
<datasource jndi-name="java:/jdbc/SybaseDS2" pool-name="SybaseDS2">
<connection-url>jdbc:sybase:XXXX.XXXX.XXXX.XXXX/database</connection-url>
<driver-class>com.sybase.jdbc3.jdbc.SybDriver</driver-class>
<driver>
jconn3.jar
</driver>
<security>
<user-name>x</user-name>
<password>y</password>
</security>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
</pool>
</datasource>
But i'm getting
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.naming.context.java.module.Midd.Midd.env.Midd2 is missing [jboss.naming.context.java.module.Midd.Midd.env.jdbc.SybaseDB]",
"jboss.naming.context.java.module.Midd.Midd.env.Midd is missing [jboss.naming.context.java.module.Midd.Midd.env.jdbc.SybaseDS2]"
]
I've read a lot of docs in google but nothing that could help
Have you tried using the annotation to inject the data source?
#Resource(name = "jdbc/SybaseDB")
private DataSource dataSource1;
#Resource(name = "jdbc/SybaseDS2")
private DataSource dataSource2;
Where do you put the jconn3.jar?

Wildfly Default data source class name

I am using WildFly 11, I am trying to understand when we configure a data source with a specific driver and we don't set the data source class name explicitly, which actual implementation of javax.sql.DataSource does WF ends up using ?
<datasource jndi-name="java:jboss/datasources/myDB" pool-name="myDB" enabled="true" use-java-context="true" spy="false">
<connection-url>jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf8&useSSL=false</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
</validation>
</datasource>
my application certainly works and I can see the interaction with the DB just fine, however I am not sure which actual datasource implementation is in use, I tried to configure a logger against MySQL packages that contains the default data sources, but nothing seems to get logged as a result.
WildFly is using ironjacamar (http://www.ironjacamar.org/) as its datasource implementation.

How/where to get jms jndi configuration values in jboss to configure in cast iron studio

Can anybody help me to configure jms jndi properties in Cast Iron studio for accessing jms queue. I'm using jboss. How/where to get jms jndi properties in jboss? Also it's asking for jndi provider details such as username, password, provider name, value, and connection factory. Where to get these details?
try this
<datasource jndi-name="java:/project name" pool-name="project namre" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:#databaseIP port service name</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>10</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>

jta=true or xa-datasource in Jboss EAP 7

I'm trying to configure SQLSERVER datasource in standalone.xml. In my project i'm using JTA and i founded configuration with and others with . What is the difference ? I'm using this:
<datasource jta="true" jndi-name="java:jboss/datasources/mydatabase" pool-name="seguDS" enabled="true" use-java-context="true">
<connection-url>jdbc:jtds:sqlserver://192.168.40.16/mydatabase;instance=clust02</connection-url>
<driver>jtds-1.3.1.jar</driver>
<new-connection-sql>select 1</new-connection-sql>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
</pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
</validation>
<timeout>
<set-tx-query-timeout>true</set-tx-query-timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
This works for me but i'm afraid if it correct or i should change to XA-DATASOURCE.
When you create a local-tx datasource in JBoss EAP 6.x or JBoss EAP 7, it defaults "jta" attribute to "true". This would help the local-tx resource to enlist in a global transaction. The "jta" attribute enables JTA integration for non-xa datasources only (https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html-single/Administration_and_Configuration_Guide/index.html#Datasource_Parameters1).
If your application uses global transactions, i.e. it needs a transaction manager to coordinate a distributed transaction across multiple resource managers, then you need XA Datasource.

Environment variables in JBoss datasource

I have a JBoss server running and want to deploy a service.
The service connects to a database which is configured in the following xml file
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jta="false" jndi-name="java:/PMBootStrapDS"
pool-name="PMBootStrapDS" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/i2b2</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql-9.2-1002.jdbc4.jar</driver>
<security>
<user-name>i2b2pm</user-name>
<password>demouser</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</datasources>
To deploy it on different systems easily, I want to bind the database location to an environment variable.
I tried something like this
<connection-url>jdbc:postgresql://${env.MY_DB_LOCATION}/i2b2</connection-url>
but it doesn't work.
Any suggestions on how to solve this issue?
Make sure you have property substitution enabled in your standalone.xml.
Look for the following subsytem in standalone.xml, and make sure the values are set to true
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>
EDIT: This is only supported for eap6 and jboss 7.1.2 (or later)