留言板
OSGI Sqlserver dependency
Im trying to use SQLServer JDBC driver as a dependency.
Trying to use the latest version: mssql-jdbc-6.2.2.jre8.jar
1. Didnt work putting it on lib/ext.
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.
pom.xml:
bnd.bnd:
I get this error when trying to start it:
Unresolved requirement: Import-Package: com.microsoft.aad.adal4j
Tried using Import-Package: !com.microsoft.aad.adal4j.* I tought I just needed to declare compiling dependencies. Are you guys adding all libs that keeps showing when trying to start? Every time that you need to add one lib you waste several hours trying to figure it out? Im asking it because I stopped using Liferay for a while after the dpx launch, now I will try it again.
Anyone have an example of a portlet with a sqlserver driver?
Trying to use the latest version: mssql-jdbc-6.2.2.jre8.jar
1. Didnt work putting it on lib/ext.
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.
pom.xml:
<dependency>
<groupid>com.microsoft.sqlserver</groupid>
<artifactid>mssql-jdbc</artifactid>
<version>6.2.2.jre8</version>
</dependency>
bnd.bnd:
-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
I get this error when trying to start it:
Unresolved requirement: Import-Package: com.microsoft.aad.adal4j
Tried using Import-Package: !com.microsoft.aad.adal4j.* I tought I just needed to declare compiling dependencies. Are you guys adding all libs that keeps showing when trying to start? Every time that you need to add one lib you waste several hours trying to figure it out? Im asking it because I stopped using Liferay for a while after the dpx launch, now I will try it again.
Anyone have an example of a portlet with a sqlserver driver?
Gustavo Oliveira:
Anyone have an example of a portlet with a sqlserver driver?
Just don't do it.
Leave the SQL server driver where it is and define a JNDI datasource to the target database.
Inside of your module, you just need to get the JNDI DataSource and can start leveraging it.
No bleed of the driver, the classes, the dependencies, ...
Ok, I will try it.
Thanks
Thanks
First I tested it with Tomcat and it worked but when I tried in Liferay I got the same error from this Thread:
https://web.liferay.com/pt/community/forums/-/message_boards/message/91115699
"Cannot instantiate class: org.apache.naming.java.javaURLContextFactory"
I tried both approches:
Context context = new InitialContext() and DataSourceFactoryUtil.initDataSource(properties);
I wonder how ppl is doing when they have to connect to another database. External web services? Use Liferay just as a client?
https://web.liferay.com/pt/community/forums/-/message_boards/message/91115699
"Cannot instantiate class: org.apache.naming.java.javaURLContextFactory"
I tried both approches:
Context context = new InitialContext() and DataSourceFactoryUtil.initDataSource(properties);
I wonder how ppl is doing when they have to connect to another database. External web services? Use Liferay just as a client?
Gustavo Oliveira:
I wonder how ppl is doing when they have to connect to another database.
By reading the documentation...
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/connecting-to-data-sources-using-jndi
Hi
I resolved this issue by this changes :
In bnd.bnd (Finding all !packages was very very painful ... I hate OSGI when i have to use third party libraries)
I resolved this issue by this changes :
In bnd.bnd (Finding all !packages was very very painful ... I hate OSGI when i have to use third party libraries)
-includeresource:\
@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,\
@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.*,\
*
and in Build.gradledependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib"
compileOnly group: "javax.portlet", name: "portlet-api"
compileOnly group: "javax.servlet", name: "javax.servlet-api"
compileOnly group: "jstl", name: "jstl"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '7.4.0.jre8'
compileOnly group: 'com.microsoft.azure', name: 'adal4j', version: '1.6.4'
compileOnly group: 'com.microsoft.azure', name: 'azure-keyvault', version: '1.2.2'
compileOnly group: 'com.microsoft.rest', name: 'client-runtime', version: '1.6.15'
compileOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.11.0'
compileOnly group: 'com.squareup.okio', name: 'okio', version: '1.14.0'
}