Adding pooled connection datasource in JBoss 7 - java

I am changing from Glassfish to Jboss 7. I have configured a datasource in the Glassfish server which is pooled at the server, but not XA. I am trying this, but each time I open admin web gui the driver element is truncated to <driver name="postgresql" .. />. Something must be wrong since I can't log on to my application. How can I configure a datasource which is pooled on JBoss 7?
<drivers>
<driver name="postgresql" module="org.postgresql">
<datasource-class>org.postgresql.ds.PGConnectionPoolDataSource</datasource-class>
</driver>
</drivers>
This is the module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.2-1002.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

In you domain.xml/standalone.xml you can specify your datasource:
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>

Related

How to switch from default H2 DB of jBPM to another Database like MariaDB?

I've installed MariaDB connector in jBPM 7.53 Final with .jar file and configured MariaDB database locally. Checked in management console and saw that datasources and JDBC connectors look good (MariaDBDS is enabled), but an error showing in runtime "Boot errors occurred during the start of server".
Failure description: {"WFLYCTL0412: Required services that are not
installed:" =>
["jboss.jdbc-driver.mariadb-java-client-2_7_1_jar"],"WFLYCTL0180:
Services with missing/unavailable dependencies" =>
["jboss.driver-demander.java:jboss/MariaDBDS is missing
[jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]","org.wildfly.data-source.MariaDBDS
is missing [jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]"]}
Missing dependencies: jboss.driver-demander.java:jboss/MariaDBDS is
missing [jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]
org.wildfly.data-source.MariaDBDS is missing
[jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]
I have configured MariaDB Java connector in the jBPM standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:5.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mariadb://localhost:3306/mysql</connection-url>
<driver-class>org.mariadb.jdbc.Driver</driver-class>
<driver>mariadb-java-client-2.7.1.jar</driver>
<security>
<user-name>root</user-name>
<password>admin</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver name="mariadb" module="org.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
and I have copied the MariaDB Java connector to JBPM_HOME/modules/com/mariadb/main/mariadb-java-client-2.7.1.jar and configured the module.xml like this:
<module xmlns="urn:jboss:module:1.1" name="org.mariadb">
<resources>
<resource-root path="mariadb-java-client-2.7.1.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Also, in Business-Central to new process instance appeared this attention:
enter image description here
What I am missing or change in these steps? Any idea if jBPM works with the external DB or not?
#KrenarR have you set up these properties under system-properties as well?
<property name="org.kie.server.persistence.ds" value="java:jboss/MariaDBDS"/>
<property name="org.kie.server.persistence.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
You can also add the driver as a core module by means of jboss_cli:
module add --name=org.mariadb --resources=mariadb-java-client-2.7.1.jar --dependencies=javax.api,javax.transaction.api
Also check this line in the datasource:
<driver>mariadb-java-client-2.7.1.jar</driver>
I think it should be just the driver name you have defined:
<driver>mariadb</driver>
You can refer to the documentation Switch to another database
from jbpm.org for detailed steps.

JBoss and MySQL New missing/unsatisfied dependencies

I'm a Java and JBoss newbie struggling to get JBoss AS 7.0.1 working with mySQL 5.5 on my Windows 10 machine.
I get the following error when I start JBoss:-
16:19:39,480 INFO [org.jboss.as.controller] (Controller Boot Thread) Service status report
New missing/unsatisfied dependencies:
service jboss.jdbc-driver.com_mysql (missing)
This is what I've done
1 created directory jboss-as-7.0.1.Final\modules\com\mysql\main
2 Files there: module.xml and mysql-connector-java-5.1.26-bin.jar (downloaded from official mysql site)
3 Content of module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql" slot="main">
<resources>
<resource-root path="mysql-connector-java-5.1.39-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
4 Relevant parts from jboss-as-7.0.1.Final\standalone\configuration\standalone.xml:
<datasources>
<datasource jndi-name="java:/jbossdbDS" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/jbossdb
</connection-url>
<driver>
com.mysql
</driver>
<security>
<user-name>
root
</user-name>
<password>
password
</password>
</security>
<timeout>
<idle-timeout-minutes>
0
</idle-timeout-minutes>
<query-timeout>
600
</query-timeout>
</timeout>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="H2DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
</connection-url>
<driver>
h2
</driver>
<pool>
<prefill>
false
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
sa
</user-name>
<password>
sa
</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>
org.h2.jdbcx.JdbcDataSource
</xa-datasource-class>
</driver>
</drivers>
</datasources>
You have mentioned the mysql jar file name in modules as
mysql-connector-java-5.1.26-bin.jar
But in your module.xml it is incorrectly configured as
mysql-connector-java-5.1.39-bin.jar
Pls Correct your module.xml
Your driver configured in datasource with name
<driver>
com.mysql
</driver>
Update that to your correct driver name as
<driver>
mysql
</driver>
Thanks for the responses.
Turns out the mysql-connector-java-5.1.39-bin.jar file was corrupt, the java.sql.Driver file inside it was empty. Not sure how that happened!

connection pool on jboss 7.0.2 don't work

I trying to do a pool connection on JBoss, I saw many things on the internet about this, but nothing work....
<?xml version="1.0" encoding="UTF-8"?>
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/db_test" pool-name="db_testDS">
<connection-url>jdbc:sqlserver://----------;databaseName=db_test</connection-url>
<driver>MSSQL</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>us***</user-name>
<password>mo***</password>
</security>
</datasource>
<drivers>
<driver name="MSSQL" module="com.microsoft.sqlserver.jdbc.SQLServerDriver">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
when I enter on JBoss admin db_test don't apear
what is worng?
Please refer the link.
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/Example_Microsoft_SQLServer_Datasource1.html
Select appropriate database drivers and you will get the correct configuration.
Following is the configuration for MS SQL Server
The example below is a Microsoft SQLServer datasource configuration. The datasource has been enabled, a user has been added, and validation options have been set.
<datasources>
<datasource jndi-name="java:/MSSQLDS" pool-name="MSSQLDS">
<connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase</connection-url>
<driver>sqlserver</driver>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"></valid-connection-checker>
</validation>
</datasource>
<drivers>
<driver name="sqlserver" module="com.microsoft">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</datasources>
================================================================================
The example below is a module.xml file for the Microsoft SQLServer datasource above.
================================================================================
<module xmlns="urn:jboss:module:1.1" name="com.microsoft">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

Not able to connect to MySql database while running the web application in JBOSS

I have a web application which runs successfully in Tomcat server and it uses MySql database. Now, I am trying to run it on JBOSS 7, but the DB connection is not happening. No error in C:\jboss-eap-6.2\standalone\log\server.log file. Not sure where else can I see some error messages.
My standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/Matix" pool-name="Matix" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/Matix</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
**My module.xml under the path: C:\jboss-eap-6.2\modules\com\mysql\main (Also, not sure if the path is correct) **
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
I put mysql-connector-java-5.0.8-bin.jar under the path C:\jboss-eap-6.2\modules\com\mysql\main
I have not done any changes in my web.xml and my JDBC Connection code. Are those required?
What else I am missing? Please help.
EDIT
** part of Java Code **
public class LoginAction implements ServletResponseAware {
public String login() {
String result_type_Is = "";
result_type_Is = this.checkAuthorization(con);
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.write(result_type_Is);
}
}
private String checkAuthorization(Connection con) {
try {
// Checking DB Authentication
// Returns SUCCESS or WRONG
}
catch (Exception e) {
//..........
return FAIL;
} finally {
// Closing all connections
}
return result;
}
JS Code
var display = login_request.responseText;
if (display == "SUCCESS") {
// redirect to home page
}
else{
//Show DB conn failure msg
}

Unable to define oracle datasource on Jboss AS 7

I'm using Jboss AS 7.1.1.final and I'm trying to add an oracle Datasource:
<datasource jndi-name="java:jboss/datasources/DefaultDS"
pool-name="DefaultDS"
enabled="true"
use-java-context="true">
<connection-url>jdbc:oracle:oci#TNS_NAME</connection-url>
<driver>oracle</driver>
<security>
<user-name>username</user-name>
<password>pwd</password>
</security>
</datasource>
And the driver:
<driver name="oracle" module="com.oracle.ojdbc">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
But when I start the server I get:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.data-source.java:jboss/datasources/DefaultDS]
I have a module under modules/com/oracle/ojdbc/main:
<module xmlns="urn:jboss:module:1.0" name="com.Oracle.ojdbc">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
and of course the jar is there.
Can someone please tell me what am I doing wrong here?
Add this to define driver: for xa datasource
<driver name="oracleDriver" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.OracleXADataSource</xa-datasource-class>
</driver>
for non-xa-------
<driver name="oracleDriver" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
</driver>
Got the answer:
In the drivers section, I defined the driver as sitting in module "com.oracle.ojdbc" but the module itself is actually defined with capital 'O' in 'Oracle' so it should be "com.Oracle.ojdbc"
Add this to define driver: for xa datasource
<driver name="oracleDriver" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.OracleXADataSource
for non-xa-------
<driver name="oracleDriver" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
</driver>
Path for the ojdbc jar in my case was : D:\ProgramFiles\JBoss6.4\modules\com\oracle\jdbc7\main where D:\ProgramFiles\JBoss6.4\ is the JBOSS HOME directory.
in the main folder, need to have following files.
ojdbc7.jar
module.xml
Entry for Module would look like below:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.jdbc7">
<properties>
<property name="jboss.api" value="unsupported"/>
</properties>
<resources>
<resource-root path="ojdbc7.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
You can define datasource from admin interface, find good tutorial below
http://middlewaremagic.com/jboss/?p=350

Categories