Forum: Building VoltDB Applications

Post: Jboss connection config for voltdb?

Jboss connection config for voltdb?
Munkhdalai
Jul 9, 2014
Hello all,

My j2ee application(it has 3 web applications) is deployed on jboss server and connects MySQL . The application does lot of transactions.

I got a time problem then i decided to move my database to volt. Then i installed Volt on my virtual machine and i created empty database on the vm.

But i am trying to change following connection on the jboss server.

standalone.xml
.....
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
....

module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

i added another module.xml for voldtb

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.voltdb">
<resources>
<resource-root path="voltdb-4.4.1.jar"/>
</resources>
<dependencies>...</dependencies>
</module>

But i don't know which class will be given for <xa-datasource-class>? Also what dependencies will be required for previous module.xml?
anish
Jul 9, 2014
Hi,

Can you tell me which version of JBoss you are using?

We have not verified this but can you use org.hsqldb_voltpatches.jdbc.pool.JDBCXADataSource as classname?

I will have more answers once I know the version of JBoss you are using.

Thanks
Anish
vtkstef
Jul 9, 2014
Hi,

XA datasources imply that you are configuring a distributed transaction datasource. VoltDB does not support JXTA nor XA transactions. The transaction boundary in VoltDB is the store procedure invocation (within a store procedure you can issue multiple SQL statements). VoltDB JDBC driver (org.voltdb.jdbc.Driver) does not support commit() which is a requirement for XA and JXTA (<local-tx-datasource>) datasources. How are you using the xa-datasource with MySQL? Is it for a OR Mapper (Hibernate, JPA)? Or are you doing straight JDBC calls?

Ciao
Stefano
Munkhdalai
Jul 10, 2014
Hi,

Thnks for replies,

anish, jboss_mx_7.1.3 version is used for my web app.

vtkstef, xa-datasource is not used and i removed that.
in standalone.xml

<datasource jta="true" jndi-name="java:/SYS.CORE" pool-name="SYS.CORE" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:voltdb://localhost:21212</connection-url>
<connection-property name="characterEncoding">
utf8
</connection-property>
<connection-property name="connectionCollation">
utf8_general_ci
</connection-property>
<connection-property name="useUnicode">
true
</connection-property>
<driver>voltdb</driver>
<security>
<user-name>admin</user-name>
<password>voltdb</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="voltdb" module="com.voltdb">
<driver-class>org.voltdb.jdbc.Driver</driver-class>
</driver>
</drivers>


in module.xml

<module xmlns="urn:jboss:module:1.0" name="com.voltdb">
<resources>
<resource-root path="voltdbclient-4.4.1.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

But i got a following error from jboss when i deployed to the server.

Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.<init>(File.java:392) [rt.jar:1.7.0]
at org.voltdb.jdbc.Driver.tryToFindPropsFile(Driver.java:211)
at org.voltdb.jdbc.Driver.connect(Driver.java:106)
... 31 more
Munkhdalai
Jul 16, 2014
Pls, Comment VoltDB Experts? :D
anish
Jul 17, 2014
Hi,

What are you trying to accomplish. Is it an existing application you are trying to run on VoltDB? Do you use hibernate and transactions which is not supported using simple JDBC interface and you need to write Stored Procedures to get benefit of it.

export VOLTDB_JDBC_PROPERTIES=/tmp/p.properties
touch /tmp/p.properties
start jboss

This may get u unstuck from this error but what you are trying to accomplish will help us guide you if you will be hitting any further challenging issues.

Anish
anish
Jul 17, 2014
your module file should be like below.

<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="com.voltdb">

<resources>
<resource-root path="voltdbclient-4.5.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="sun.jdk" />
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Munkhdalai
Jul 18, 2014
Hi,

First of all thnks for reply anish,

I am trying to change my application's db from mysql to voltdb. Yes, it is existing web application. The application is using jpa2, ejb.

I believe when i write Stored Procedures, i will some benefits on the voltdb. But the application is not small application and if i will write stored procedures for volt, it requires more time and additional efforts.
Also application has many entity classes which generate tables on the database. Also entity Classes included relationships such as one-to-one, one-to-many ...
i am in a doubt it works well on the voltdb.

Firstly time, i only wanna move to voltdb without to much work then i will do more greater work such as stored procedure, query optimize, maybe change ejb and jpa etc.
Munkhdalai
Jul 18, 2014
Back to problem,

i think my module.xml is correct and the problem rises from tryToFindPropsFile function because voltdb.properties file couldn't create correctly. Also i created empty voltdb.jdbcproperties file on same director with voltdbclient-4.5.jar.

But i still got problem.


What elements are saved in voltdb.djbcproperties file? Can i set default values for elements?
anish
Jul 18, 2014
export VOLTDB_JDBC_PROPERTIES=/tmp/p.properties
touch /tmp/p.properties
start jboss

This should fix your problem of driver not loading. If not let me know and I can get a fix out for you.
Munkhdalai
Jul 21, 2014
My voltdb is installed on the centos machine and i am trying to connect from windows using jboss. I only copied voltdb-client...jar file to jboss module.

Also tmp director doesn't excited in my windows.
Jboss tmp director's path(Is it C:\installition\jboss_mx_7.1.3\standalone\tmp).

How to register or set properties file to my windows?
anish
Jul 21, 2014
You can set a variable in your jboss startup script. standalone.bat
set VOLTDB_JDBC_PROPERTIES=C:\voltdb.jdpcproperties
create that file in C:\ and keep it empty.

Let me know if this works.
Anish
Munkhdalai
Jul 23, 2014
i set VOLTDB_JDBC_PROPERTIES=C:\voltdb.jdpcproperties in standalone.bat. But i still got the error and it is gonna my headache.
Munkhdalai
Jul 24, 2014
try {
Properties properties = new Properties();
file = new File("voltdb.jdbcproperties");
FileOutputStream fileOut = new FileOutputStream(file);
properties.store(fileOut, null);
fileOut.close();
tmp = file.getName();
} catch (FileNotFoundException e) {
e.printStackTrace();
tmp = null;
} catch (IOException e) {
e.printStackTrace();
tmp = null;
}

filename = tmp;

i added previous a litte coding to Driver class then my problem was solved.
anish
Jul 24, 2014
Thanks. That file is not needed to use the driver and JBoss resource loading causes uncaught exception in our code. We will be fixing it soon. Other contains such as tomcat should be fine and the Driver is in use in production under tomcat without changes.

We have already created a ticket to address this issue.

Thanks for your feedback.

Anish