RE: Liferay 7.1 - Not able to connect external database

Abhishek Mehta, modified 7 Years ago. New Member Posts: 13 Join Date: 11/7/13 Recent Posts

I have followed steps from blog to connect external database and I am not getting success.

I get following error,

 

com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query

 

and in console I get following error,

ERROR [http-nio-8080-exec-13][JDBCExceptionReporter:234] Invalid object name 'TableName'.

 

I was able to connect with external database in Liferay 7.0 but same thing is not working in Liferay 7.1

 

Can someone please help to check what is missing.

 

Thank you in advance.

 

thumbnail
Nagendra Kumar Busam, modified 7 Years ago. Liferay Master Posts: 678 Join Date: 7/7/09 Recent Posts
Can you please attach your service.xml
Sacha Piccardi, modified 6 Years ago. New Member Posts: 3 Join Date: 9/3/19 Recent Posts
Hi, I'm facing with the same problem on Liferay 7.2-ga1 following the same blog (https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/connecting-service-builder-to-external-databases) and this example (https://github.com/liferay/liferay-blade-samples/blob/7.2/liferay-workspace/apps/service-builder/jdbc/jdbc-service/src/main/resources/META-INF/spring/module-spring.xml).
I tried to put the
ext-spring.xml
 and the
module-spring.xml
 in these path:
  1. src/main/resources/META-INF/spring/parent
  2. src/main/resources/META-INF/spring
    
In the case (2) the service builder removes the
module-spring.xml 
file
 every time I activate the "
buildService
" gradle task.I suspect that the problem is that the service builder version I'm using is ignoring the
extDatasource 
defined in the
ext-spring.xml
file. 
This suspect is confirmed by the fact that when i debug the 
setDataSource(DataSource dataSource)
of my "
MyEntityPersistenceImpl
" the
dataSource
object points to the portal default dataSource and not the
extDatasource.

 Furthermore I noticed that the classes generated by the service builder are annotated with @Component and @Reference liferay's annotations. So maybe  this causes liferay to completely ignore every .xml spring-bean files.
So how can I resolve? Can anyone help me?
Thank you in advance.