Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-116180

Entity tables aren't created in Service Builder module's external database

    Details

      Description

      A Service Builder module's entity tables should be created in the data source configured for that module.

      Steps:

      1. Create a maria DB database called external
        create database external character set utf8;
      2. Add a portal-ext.properties file that specifies your external database and db host (e.g., hostname/external) and restart the server.
        jdbc.ext.driverClassName=org.mariadb.jdbc.Driver
        jdbc.ext.url=jdbc:mariadb://hostname/external?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
        jdbc.ext.username=root
        jdbc.ext.password=my-secret-pw
        
      1. Unzip the attached Liferay Workspace. It contains the guestbook application Service Builder modules (api, service, web). The service module provides a DataSourceProvider class called
        com.liferay.docs.guestbook.internal.DataSourceProviderImpl

        This file configures the module's services to use that datasource:

        com-liferay-docs-guestbook/modules/guestbook/guestbook-service/src/main/resources/META-INF/services/com.liferay.portal.kernel.dao.jdbc.DataSourceProvider
      2. Build the services:
        gw buildService
      3. Build the module JARs:
        gw deploy

        The JARs are created in the workspace's

        bundles/osgi/modules

        folder.

      4. Copy the JARs to your Liferay Home/deploy folder.

      Expected Result:
      The entity tables GB_Guestbook and GB_GuestbookEntry are created in the external database.

      Actual Results:
      The entity tables are created in the default database.

      5. Add the widget (Widget > Social > Guestbook) to a page.

      Expected Result:

      • The Guestbook portlet renders

      Actual Results:

      • Portlet message in UI: "Portlet is temporarily unavailable"
      • Console message:
        ERROR [http-nio-8080-exec-6][JDBCExceptionReporter:234] Table 'external.guestbook' doesn't exist
        ...
        Caused by: org.mariadb.jdbc.internal.common.QueryException: Table 'external.guestbook' doesn't exist
        

      A Simpler Sample: is at https://github.com/jhinkey/liferay-blade-samples/tree/service-builder-dsp/gradle/apps/service-builder/dsp
      It has a table called country in namespace DSPCOUNTRY.

        Attachments

          Activity

            People

            • Assignee:
              support-lep@liferay.com SE Support
              Reporter:
              james.hinkey James Hinkey
              Participants of an Issue:
              Recent user:
              James Hinkey
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                5 weeks, 5 days ago

                Packages

                Version Package