OSGI Sqlserver dependencyOSGI Sqlserver dependencyhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=990650642024-03-29T07:15:41Z2024-03-29T07:15:41ZRE: OSGI Sqlserver dependencyNader Jafarihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1175521942019-10-24T10:39:43Z2019-10-24T10:39:43ZHi David<br />for using JNDI to conect MSQL i should add all dependencies to global library finally as i understand.Nader Jafari2019-10-24T10:39:43ZRE: OSGI Sqlserver dependencyNader Jafarihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1175518342019-10-24T10:27:59Z2019-10-24T10:27:59Z<html><head></head><body>Hi<br>I resolved this issue by this changes :<br>In bnd.bnd (Finding all !packages was very very painful ... I hate OSGI when i have to use third party libraries)<br><br><pre><code>-includeresource:\
&nbsp;&nbsp; @mssql-jdbc-7.4.0.jre8.jar,@adal4j-1.6.4.jar,@client-runtime-1.6.15.jar,@azure-keyvault-1.2.2.jar,@okhttp-3.11.0.jar,\
&nbsp;&nbsp; @okio-1.14.0.jar
Import-Package:\
!afu.org.checkerframework.*,\
!com.google.gson.*,\
!com.fasterxml.jackson.datatype.joda.*,\
!com.google.common.*,\
!com.microsoft.azure.*,\
!com.nimbusds.*,\
!net.jcip.*,\
!android.*,\
!rx.*,\
!retrofit2.*,\
!net.minidev.*,\
!org.antlr.*,\
!org.apache.*,\
!org.conscrypt.*,\
!org.joda.time.*,\
!org.osgi.service.jdbc.*,\
*
</code></pre>and in Build.gradle<br><br><pre><code>dependencies {
&nbsp;&nbsp; &nbsp;compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
&nbsp;&nbsp; &nbsp;compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib"
&nbsp;&nbsp; &nbsp;compileOnly group: "javax.portlet", name: "portlet-api"
&nbsp;&nbsp; &nbsp;compileOnly group: "javax.servlet", name: "javax.servlet-api"
&nbsp;&nbsp; &nbsp;compileOnly group: "jstl", name: "jstl"
&nbsp;&nbsp; &nbsp;compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '7.4.0.jre8'
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.microsoft.azure', name: 'adal4j', version: '1.6.4'
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.microsoft.azure', name: 'azure-keyvault', version: '1.2.2'
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.microsoft.rest', name: 'client-runtime', version: '1.6.15'
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.11.0'
&nbsp;&nbsp; &nbsp;compileOnly group: 'com.squareup.okio', name: 'okio', version: '1.14.0'
}
</code></pre></body></html>Nader Jafari2019-10-24T10:27:59ZRE: OSGI Sqlserver dependencyDavid H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=991376262017-11-21T21:08:23Z2017-11-21T21:08:23Z<div class="quote-title">Gustavo Oliveira:</div><blockquote>I wonder how ppl is doing when they have to connect to another database.</blockquote><br /><br />By reading the documentation... <br /><br /><a href="https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/connecting-to-data-sources-using-jndi">https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/connecting-to-data-sources-using-jndi</a>David H Nebinger2017-11-21T21:08:23ZRE: OSGI Sqlserver dependencyGustavo Oliveirahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=991215782017-11-21T18:35:39Z2017-11-21T18:35:39ZFirst I tested it with Tomcat and it worked but when I tried in Liferay I got the same error from this Thread:<br /><br />https://web.liferay.com/pt/community/forums/-/message_boards/message/91115699<br /><br /><strong>"Cannot instantiate class: org.apache.naming.java.javaURLContextFactory"</strong><br /><br />I tried both approches:<br /><br /><em>Context context = new InitialContext() </em> and <em>DataSourceFactoryUtil.initDataSource(properties);</em><br /><br />I wonder how ppl is doing when they have to connect to another database. External web services? Use Liferay just as a client?Gustavo Oliveira2017-11-21T18:35:39ZRE: OSGI Sqlserver dependencyGustavo Oliveirahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=990914732017-11-21T15:32:13Z2017-11-21T15:32:13ZOk, I will try it.<br /><br />ThanksGustavo Oliveira2017-11-21T15:32:13ZRE: OSGI Sqlserver dependencyDavid H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=990815452017-11-21T14:20:08Z2017-11-21T14:20:08Z<div class="quote-title">Gustavo Oliveira:</div><blockquote>Anyone have an example of a portlet with a sqlserver driver?</blockquote><br /><br />Just don't do it.<br /><br />Leave the SQL server driver where it is and define a JNDI datasource to the target database.<br /><br />Inside of your module, you just need to get the JNDI DataSource and can start leveraging it.<br /><br />No bleed of the driver, the classes, the dependencies, ...David H Nebinger2017-11-21T14:20:08ZOSGI Sqlserver dependencyGustavo Oliveirahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=990650632017-11-21T12:59:30Z2017-11-21T12:59:30Z<html><head></head><body>Im trying to use SQLServer JDBC driver as a dependency.<br><br>Trying to use the latest version: mssql-jdbc-6.2.2.jre8.jar<br><br>1. Didnt work putting it on lib/ext.<br>2. Before adding a lib I run mvn dependency:tree to check all the libs I will have to declare in the bnd. This version doesnt have compile dependencies.<br><br>pom.xml:<br><pre><code>
<dependency>
<groupid>com.microsoft.sqlserver</groupid>
<artifactid>mssql-jdbc</artifactid>
<version>6.2.2.jre8</version>
</dependency>
</code></pre><br><br>bnd.bnd:<br><pre><code>
-includeresource:\
lib/mssql-jdbc-6.2.2.jre8.jar=mssql-jdbc-6.2.2.jre8.jar;
Bundle-ClassPath: \
.,\
lib/mssql-jdbc-6.2.2.jre8.jar
</code></pre><br><br>I get this error when trying to start it:<br> Unresolved requirement: Import-Package: com.microsoft.aad.adal4j<br><br>Tried using Import-Package: !com.microsoft.aad.adal4j.* I tought I just needed