RestApi extension in JBoss, sqljdbc.jar visibility

1
0
-1

Hello,
I am developing a rest api extension similar to the rest-api-sql-data-source example ( https://github.com/Bonitasoft-Community/rest-api-sql-data-source)
We use the Jboss bundle.
Due to limitations (sqlserver store procedure calls) I am not using the groovy.sql method, but the classic java approach.
So, in order to create the connection I have:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://serverName:1433;databaseName=dbName", "sa", "pswd");

resulting in NoClassDefFoundError exception

15:09:38,217 WARNING [org.restlet.Component.BonitaSPRestletApplication] (http--0.0.0.0-8086-2) Exception or error caught in server resource: java.lang.NoClassDefFoundError: Could not initialize class com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_67]
at java.lang.Class.forName(Class.java:190) [rt.jar:1.7.0_67]
at com.acs.rest.api.Index.doHandle(Index.groovy:71)
at org.bonitasoft.console.common.server.page.RestApiRendererExt.doHandle(RestApiRendererExt.java:33) [console-server-sp-7.3.2.jar:]
.
.
.

I tried adding a \lib folder with the sqljdbc.jar inside the spCallerRestAPI-1.0.1-SNAPSHOT.zip, with no success (and restarted the server) .
In JBoss there is no \lib folder as in Tomcat.

Any ideas where should the .jar be put?

1 answer

1
0
-1

Hi,

I reproduced the same behavior using your example. You can workaround it by using the Groovy class groovy.sql.Sql:

Properties p= new Properties() p.setProperty("user","USERNAME") p.setProperty("password","PASSWORD") Driver driver = new oracle.jdbc.OracleDriver() Sql sqlinstance = new Sql(driver.connect("jdbc:oracle:thin:@//DB_URL:1521/ORCL", p))

Connection conn = sqlinstance.getConnection()

Don't forget to add the JDBC driver in the lib folder of your REST Api and you should be good to go.

Cheers

Notifications