Message Boards

Unable to connect oracle db as external DB in liferay 7.2

khaja moinuddin, modified 3 Years ago.

Unable to connect oracle db as external DB in liferay 7.2

New Member Posts: 17 Join Date: 12/4/15 Recent Posts
I am trying to connect oracle DB as external db i am getting null pointer Exception when the service is called  ,as the same configuration working in Liferay DXP  
Tried to connect through both the ways application server Server.xml and through portal-ext.properties but didn't work .Appreciate if any one can help on the thread.


After starting the server getting this error message 2020-06-09 07:11:44.451 WARN  [Portal Dependency Manager Component Executor--1][ModuleApplicationContext:551] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy] for bean with name 'liferayDataSource' defined in URL [bundleentry://1104.fwk1038002783/META-INF/spring/parent/ext-db-spring.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy cannot be found by com.assfc.acl.db.service_1.0.0
2020-06-09 07:11:44.782 ERROR [Portal Dependency Manager Component Executor--1][LogService:93] [Portal Dependency Manager Component Executor--1] Invocation of 'start' failed. 
java.lang.Exception: Unable to start com.assfc.acl.db.service
    at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.start(ModuleApplicationContextRegistrator.java:107)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.felix.dm.impl.InvocationUtil.invokeMethod(InvocationUtil.java:157)
    at org.apache.felix.dm.impl.InvocationUtil.invokeCallbackMethod(InvocationUtil.java:112)
    at org.apache.felix.dm.impl.ComponentImpl.invokeCallbackMethod(ComponentImpl.java:638)
    at org.apache.felix.dm.impl.ComponentImpl.invoke(ComponentImpl.java:1783)
    at org.apache.felix.dm.impl.ComponentImpl.invokeStart(ComponentImpl.java:1281)
    at org.apache.felix.dm.impl.ComponentImpl.performTransition(ComponentImpl.java:1232)
    at org.apache.felix.dm.impl.ComponentImpl.handleChange(ComponentImpl.java:1166)
    at org.apache.felix.dm.impl.ComponentImpl.lambda$start$2(ComponentImpl.java:502)
    at org.apache.felix.dm.impl.DispatchExecutor.runTask(DispatchExecutor.java:182)
    at org.apache.felix.dm.impl.DispatchExecutor.run(DispatchExecutor.java:165)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy] for bean with name 'liferayDataSource' defined in URL [bundleentry://1104.fwk1038002783/META-INF/spring/parent/ext-db-spring.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy cannot be found by com.ejada.atmc.acl.db.service_1.0.0
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1397)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:454)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at com.liferay.portal.spring.aop.AopConfigurableApplicationContextConfigurator$AopBeanFactoryPostProcessor._getPlatformTransactionManager(AopConfigurableApplicationContextConfigurator.java:189)
    at com.liferay.portal.spring.aop.AopConfigurableApplicationContextConfigurator$AopBeanFactoryPostProcessor.postProcessBeanFactory(AopConfigurableApplicationContextConfigurator.java:123)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:283)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:128)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
    at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.start(ModuleApplicationContextRegistrator.java:89)
    ... 17 more
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy cannot be found by com.ejada.atmc.acl.db.service_1.0.0
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:151)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.liferay.portal.spring.extender.internal.loader.ModuleAggregareClassLoader.loadClass(ModuleAggregareClassLoader.java:116)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:251)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:401)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1444)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1389)
    ... 29 more
Thanks in advance 
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Liferay CE does not support commercial databases.
If you want to use Oracle with Liferay CE, you need to install an extra plugin.
https://github.com/amusarra/liferay-portal-database-all-in-one-support
khaja moinuddin, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

New Member Posts: 17 Join Date: 12/4/15 Recent Posts
Hi Christoph
Thanks for your response i am using liferay EE .
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Sorry, I only glanced on your issue and oracle + CE not working is a "classic".
Maybe you run into this issue:
https://issues.liferay.com/browse/LPS-88444?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
Maybe try to add:
Import-Package:\
    com.liferay.portal.dao.jdbc.spring,\
    \
    org.springframework.jdbc.datasource,\
    \
    *
to the bnd file.
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
khaja moinuddin:

I am trying to connect oracle DB as external db i am getting null pointer Exception when the service is called  ,as the same configuration working in Liferay DXP  

... cannot be found by com.assfc.acl.db.service_1.0.0
    ... 17 more
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy cannot be found by com.ejada.atmc.acl.db.service_1.0.0
If the additional dependency that Christoph mentions doesn't help: please show your code. This doesn't point at Liferay classes, so nobody here has a clue what you're doing there.
khaja moinuddin, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

New Member Posts: 17 Join Date: 12/4/15 Recent Posts
Dear Alof
Thanks for you response ,
The additional dependency that Christoph mentioned didn't work for me
As i am trying to connect to oracle as external database during server startup i don't see any error related to external db connection.
I am connecting ext db from application server that is in server.xml .
During deploying the services i am getting the error which is attached (liferay_log)
also i had attached my spring.xml which i had created in the location  /META-INF/spring/parent/ext-db-spring.xml
and also server.xml
Thanks & Regards
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
I checked one of our projects where we have an external datasource (Liferay 7.2) and our spring ext looks pretty much the same. Our datasource is defined in portal-ext, but that shouldn't make a difference for that exception.
Since the LazyConnectionDataSourceProxy class is not found, I still believe that it you have to fix this by adding an import to the bnd file of the service (not the api). Ours looks this way:
Bundle-Name: xxx-external-db-service
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
-dsannotations-options: inherit
Import-Package: \
    com.liferay.portal.dao.jdbc.spring,\
    \
    org.springframework.jdbc.datasource,\
    \
    *
khaja moinuddin, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

New Member Posts: 17 Join Date: 12/4/15 Recent Posts
This is my bnd.bnd
Bundle-Name: DBACL-service
Bundle-SymbolicName: com.ejada.atmc.acl.db.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
Import-Package: \
    com.liferay.portal.dao.jdbc.spring,\
    org.springframework.jdbc.datasource,\
    *
Still i am facing the issue ,
khaja moinuddin, modified 3 Years ago.

RE: Unable to connect oracle db as external DB in liferay 7.2

New Member Posts: 17 Join Date: 12/4/15 Recent Posts
I have a query if i have two service builder gradle plugins do i need to define  ext-db-spring.xml  file for bothe the services ?as it will point to same datasource ,
in my current project of Liferay DXP it is only defined in one service builder plugin in another  is just  entities defined without columns attached is the service.xml which is working fine .Do i need to define datasource for fake entities as in DXP it is not defined .