Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Wrong schema referenced in Service Builder portlet
I am moving some code from a working 7.0 GA5 environment to 7.1.1 GA2
and facing more hurdles than I expected. The latest is that after
building a service builder module and deploying the jars, it appears
that it is looking for the tables in the base Liferay MySQL database.
The service builder data-source value point to a JNDI resource that is
properly configured in server.xml and context.xml and spring-ext.xml.
The code was orginally imported from a 7.0 workspace (mistake...) so I
went ahead and created a pristine service builder module project and
then just copied the service.xml file from my working 7.0 module.
After building and deploying the modules I went over to jsonws
api panel and ran one of the API's. I get an
error: 'lportal711.person' doesn't exist
The table is in a different database on a different server as
defined in server.xml ( it's in an Aurora DB in AWS). lportal711 is
the local database for this particular instance of Liferay. So, is
there an issue with JNDI connections for the 7.1.1 service builder?
Snippets are:
spring-ext.xml:
<bean
class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean"
id="liferayDataSourceFactory">
<property name="propertyPrefix" value="custom."
/>
<property name="properties">
<props>
<prop
key="custom.jndi.name">jdbc/BSFAurora_data</prop>
</props>
</property>
</bean>
<bean
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
id="liferayDataSource">
<property
name="targetDataSource"
ref="liferayDataSourceFactory" />
</bean>
<alias alias="BSFAurora_data"
name="liferayDataSource" />
And in the service.xml:
<entity name='Person' table='Person'
local-service='true' remote-service='true' data-source='BSFAurora_data'>
And server.xml:
<Resource name="jdbc/BSFAurora_data"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
testWhileIdle="true"
.........[other connection stuff here]
/>
And context.xml:
<ResourceLink global="jdbc/BSFAurora_data"
name="jdbc/BSFAurora_data" type="javax.sql.DataSource"/>
This configuration works fine in LR7.0 GA5 on Tomcat 8 and I checked
to see if there were breaking changes with JNDI in the LR7.1 docs and
also in the Tomcat 9 changes. Nothin....
Ideas here? The whole move to 7.1.1 has been about as painful
as the 6.0.6 to 7.0 move was...I thought the big challenges were
behind me....
Replying to your own post is the kiss of death because there will be an assumption that the problem was responded to and solved. It isn't. I am just documenting what I have tried.
I walked through the instructions found here in detail, multiple times with no joy. I was encouraged for a short time when I used the portal-ext.properties approach to configure the JNDI connection because when I deployed the module I saw that the dialect for the database loaded whereas when I use the context.xml/server.xml I did NOT see the dialect statement appear when the module was deployed. It is almost as though the database connection is ignored when the JNDI connection is through the context/server xml approach. In any case, using the portal-ext.properties approach and deploying the module and seeing that the correct dialect was being loaded didn't resolve the problem. I still saw the same error looking the file table in the wrong schema.
Is anyone out there using JNDI to connect service builder modules to external databases in 7.1.1 and have success? It is almost as though this scenario hasn't been tested or used because it clearly isn't working. I can't imagine that this isn't an issue with other folks taking this approach. I'd sure like to hear of a success story and how it was accomplished.
Pete
Hi Pete,
I have the same issue : service builder with external datasource define by JNDI. Worked in 7.1 GA1 and failed in GA2.
I confirm that the services are lookin towards the portal database and not the external one.
I was hoping that using a portal-ext.properties would resolved the trouble but your post indicate that the trouble is also present.
I generate a simple new service builder and it doesn't change anything. Very bad, as I have to choose a version of Liferay for a starting project.
If I found any clue I will post here (and if you find a solution, please give advice too).
Christophe
I reverted back to my LR 7 GA5 instance only because it was simpiler for now. I'd rather be on the latest version when I decide to "jump" but since LR7 GA5 CE has been so stable for me, I stuck there.
I'll follow the progress and if do find some way to work around it, I'll let you know.
Powered by Liferay™