Docker, Contentbox, NullPointerException, Autodiscover and cfdbinfo

Last night I tried to get a docker setup going. I created a stack with a fresh MySQL setup and the ortussolutions/contentbox:lucee5 image. I’m 100% certain the MySQL (Maria) is spinning up correctly as I can connect to it separately. It seemed no matter what I tried, I continued to get this error:

ERROR (5.9.1+00767)
                                                                                                                                                                                  
java.lang.NullPointerException                                                                                                                                                    


/modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Grammars/AutoDiscover.cfc: line 7                                                                           
5: 
6:     function autoDiscoverGrammar() {
7:         cfdbinfo( type = "Version", name = "local.dbInfo" );                                                                                                                   
8: 
9:         switch ( dbInfo.DATABASE_PRODUCTNAME ) {
called from /modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Grammars/AutoDiscover.cfc: line 28                                                              
called from /modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Schema/SchemaBuilder.cfc: line 427
called from /modules/commandbox-migrations/modules/cfmigrations/models/QBMigrationManager.cfc: line 170
called from /modules/commandbox-migrations/modules/cfmigrations/models/QBMigrationManager.cfc: line 21                                                                            
called from /modules/commandbox-migrations/modules/cfmigrations/models/MigrationService.cfc: line 68
called from /modules/commandbox-migrations/commands/migrate/install.cfc: line 23
called from /system/services/CommandService.cfc: line 443
called from /system/services/CommandService.cfc: line 245
called from /system/Shell.cfc: line 862
called from /system/Bootstrap.cfm: line 124

Let me go on to add that while writing this post, I thought "let me try the super-quick, H2, no compose installation instructions y’all have here:
docker run -p 8080:8080 -e EXPRESS=true -e INSTALL=true ortussolutions/contentbox

Now, I am using Windows, because I’m testing locally, but this should work. It does not, however, and gives this error response:

ERROR (5.9.1+00767)

user lacks privilege or object not found: tables in statement [SELECT 1 FROM "information_schema"."tables" WHERE "table_name" = ? AND "table_schema" = ?]


/modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Grammars/BaseGrammar.cfc: line 116
114:         data.query = javacast( "null", "" );
115:         if ( !arguments.pretend ) {
116:             var q = queryExecute( data.sql, data.bindings, data.options );
117:             data.executionTime = getTickCount() - startTick;
118:             data.query = isNull( q ) ? javacast( "null", "" ) : q;
called from /modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Grammars/AutoDiscover.cfc: line 30
called from /modules/commandbox-migrations/modules/cfmigrations/modules/qb/models/Schema/SchemaBuilder.cfc: line 434
called from /modules/commandbox-migrations/modules/cfmigrations/models/QBMigrationManager.cfc: line 170
called from /modules/commandbox-migrations/modules/cfmigrations/models/QBMigrationManager.cfc: line 21
called from /modules/commandbox-migrations/modules/cfmigrations/models/MigrationService.cfc: line 68
called from /modules/commandbox-migrations/commands/migrate/install.cfc: line 23
called from /system/services/CommandService.cfc: line 443
called from /system/services/CommandService.cfc: line 245
called from /system/Shell.cfc: line 862
called from /system/Bootstrap.cfm: line 124

Please note, this is a completely fresh download of the image, too.

Any thoughts on this? I can clean up my original docker-compose.yml for public posting if y’all need to see that for why it fails repeatedly but my concern is that the “quick version” doesn’t work either, in nearly the same place.

I don’t want to use Wordpress! UGH!

If you could post your Dockerfile that would be helpful. It looks like something is returning null when requesting the dbInfo

I am encountering exactly the same issue and messages.
I am using the official Dockerfile found in the github repo at https://github.com/Ortus-Solutions/docker-contentbox.

@CaptainPalapa Could you fix the issue?

No, I gave up. There’s SO much to love about Coldbox, etc. but if you don’t work with it every day, or have the time to devote to resolving issues, it can be daunting. I’ve been using Coldbox in one form or another since 2007, but the vast array of complementing features and tools… well, I haven’t kept up.

I really want to add ContentBox to our site, instead of the lame not-blog I have going on now, but… I just don’t have the time to futz with it, considering it’s not my full-time job. Everytime I’ve gone down a “I’m going to use Contentbox” path, I run into issues, unfortunately. So many people are using it, that it MUST be me.

One thing I noticed about the error is that is is coming from the migration attempt to setup the ContentBox database.

You can see from the error that it is attempting to discover what DBMS grammar it should use.

In order to do that, it uses cfdbinfo, which requires schema admin privileges in SQL Server.

If you set the default grammar to SqlServerGrammar@qb in your .cfmigrations.json file in the root of the project, it will skip the dbinfo checks and, hopefully, should help you get past the error.

OK, After quite a lot of trial / error / testing, I could finally make it work!
First, the cfdbinfo error was due to some missing variables in the .env file. Basically, what I did is start from the default .env file from the official contentbox github repo and add the Docker image specific variables. So here is my final .env

#################################################################
#Docker image specifics
#################################################################
EXPRESS=false
INSTALL=false  #<= make it true to begin with. Turn it to false after the initial install of ContentBox
REMOVE_CBADMIN=false
CONTENTBOX_MIGRATE=true
#################################################################
# App Name and Environment
#################################################################
APPNAME=ContentBox Modular CMS
# This can be development, staging, production or custom.
ENVIRONMENT=production
# The password for the CFML Engine Administrator
CFCONFIG_ADMINPASSWORD=<!---SECRET--->
# The ColdBox Reinit password
COLDBOX_REINITPASSWORD=<!---SECRET--->
# How long do admin sessions last (In Minutes)
COLDBOX_SESSION_TIMEOUT=60
# Development CBDebugger
CBDEBUGGER_ENABLED=false

#################################################################
# ContentBox ORM Settings
# --------------------------------
# This is used to configure the ORM via env settings usually for
# different RDBMS settings or options
#################################################################
# Dialect choices:
# 	MySQL, Hypersonic 	=> org.hibernate.dialect.MySQL5InnoDBDialect,
# 	PostgreSQL 			=> PostgreSQL
# 	Microsoft SQL 		=> org.hibernate.dialect.SQLServer2008Dialect
# 	Oracle 				=> Oracle10g
# 	Derby 				=> Derby
ORM_DIALECT=MySQL
# Log sql to the console or not
ORM_LOGSQL=false
# Sql Script to execute after ORM is initialized
ORM_SQL_SCRIPT=
# Activate secondary cache or disable it
ORM_SECONDARY_CACHE=false
ORM_SECONDARY_CACHE_PROVIDER=ehcache

#################################################################
# ContentBox Datsource and Migrations Variables
# ----------------------------------------------------------------
# These settings configure the datasource connection to your database
# Please make sure you read the comments as there are differences
# between Adobe and Lucee. Uncomment your rdbms of choice, the options are:
# - MySQL 5.7
# - MySQL 5.8
# - PostgreSQL
# - Microsoft SQL
# - Custom Database
#################################################################

######################################################
# MySQL 8 DB Driver
######################################################
DB_CLASS=com.mysql.cj.jdbc.Driver
DB_DRIVER=MySQL
DB_BUNDLEVERSION=8.1.0
DB_BUNDLENAME=com.mysql.cj
## DB Location
DB_HOST=haproxy
DB_PORT=3306
DB_CONNECTIONSTRING=jdbc:mysql://haproxy:3306/contentbox_docker?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useLegacyDatetimeCode=true
## DB Credentials
DB_DATABASE=contentbox_docker
DB_NAME=contentbox_docker
DB_USER=contentbox
DB_PASSWORD=<!---SECRET--->

################################################################
# JWT Information
# --------------------------------
# You can seed the JWT secret below or you can also leave it empty
# and ContentBox will auto-generate one for you that rotates
# everytime the application restarts or expires
#################################################################
JWT_SECRET=

Note that I am using an external MySQL (actually MariaDB) database and that I have removed from the above .env file all the variables pertaining to the other DB drivers.
Not sure which one(s) of these variable(s) were actually the missing ones (in other words, which one did the trick, I don’t know, but it works for me with this .env file).

Another thing I did is update the Dockerfile to remove some warnings and use a version of lucee 6 that woks with my app.

Here is my current Dockerfile

# Seed it on a specific CommandBox Image Version
# https://hub.docker.com/r/ortussolutions/commandbox/tags
ARG BASE_IMAGE=ortussolutions/commandbox
FROM ${BASE_IMAGE}

# Labels
LABEL version="@version@"
LABEL maintainer="Jon Clausen <jclausen@ortussolutions.com>"
LABEL maintainer="Luis Majano <lmajano@ortussolutions.com>"
LABEL repository="https://github.com/Ortus-Solutions/docker-contentbox"

# Incoming Secrets/Vars From Build Process
ARG IMAGE_VERSION=6.0.1
ARG TAGS=ortussolutions/contentbox:test
ARG BOX_SERVER_APP_CFENGINE=lucee@6.0.4+10

# Copy over our app resources which brings lots of goodness like session distribution,
# db env vars, caching, etc.
COPY ./resources/app/ ${BUILD_DIR}/contentbox-app

# Copy over ContentBox build scripts
COPY ./build/*.sh ${BUILD_DIR}/contentbox/

# Make them executable just in case.
RUN chmod +x ${BUILD_DIR}/contentbox/*.sh

# Install ContentBox and Dependencies
RUN ${BUILD_DIR}/contentbox/contentbox-setup.sh

#Debug missins type property in mail settings
COPY ./resources/debug/settings.cfc ${APP_DIR}/modules/contentbox/modules/contentbox-admin/handlers/settings.cfc

# ContentBox Run
SHELL ["/bin/bash", "-c"]
CMD ${BUILD_DIR}/contentbox/contentbox-run.sh

# WARM UP THE SERVER
RUN ${BUILD_DIR}/util/warmup-server.sh

# Healthcheck environment variables
ENV HEALTHCHECK_URI="http://127.0.0.1:${PORT}/index.cfm"

# Our healthcheck interval doesn't allow dynamic intervals - Default is 20s intervals with 15 retries
HEALTHCHECK --interval=30s --timeout=30s --retries=2 --start-period=60s CMD curl --fail ${HEALTHCHECK_URI} || exit 1

With this version of lucee, I initially had an issue connecting to the database. This one was solved by adding a few things to the .cfconfig.json file. So first, I changed the docker-compose.yml file so to extract the .cfconfig.json file from the container

version: "3"

services:
  contentbox:
    image: o2l03.private:5000/contentbox #using a custom image from the Dockerfile above
    restart: always
    env_file:
      - .contentbox.env
    volumes: 
      # Persist Custom Module (Themes, Widgets, Media, Modules)
      - /mnt/gluster/contentbox-docker/contentbox-module:/app/modules_app/contentbox-custom:z
      # Custom ColdBox Modules
      - /mnt/gluster/contentbox-docker/modules_app:/app/modules_app:z
      # Access .cfconfig.json to tune Lucee server
      - /mnt/gluster/contentbox-docker/.cfconfig.json:/app/.cfconfig.json:z
    ports:
      - 192.168.65.2:8003:8080
      - 127.0.0.1:8003:8080
    networks: 
      - default
     
networks:
  default:
    name: o2lplatform-docker

Side note, my mariadb database is currently not containerized, so I have no DB service in my docker-compose file.

Finally, here is the datasource portion of my .cfconfig.json

"datasources" : {
		"contentbox":{
            		"allow":"511",
			"allowAlter":true,
            		"allowCreate":true,
            		"allowDelete":true,
            		"allowDrop":true,
            		"allowGrant":true,
            		"allowInsert":true,
            		"allowRevoke":true,
            		"allowSelect":true,
            		"allowUpdate":true,
			"alwaysSetTimeout":"true",
            		"blob":"true",
			"class":"${DB_CLASS}",
            		"clob":"true",
            		"connectionLimit":"100",
            		"connectionTimeout":"1",
            		"custom":"useUnicode=true&characterEncoding=UTF8&serverTimezone=UTC&useLegacyDatetimeCode=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true",
            		"database":"${DB_DATABASE:contentbox}",
            		"dbdriver":"${DB_DRIVER}",
			"host":"${DB_HOST:127.0.0.1}",
			"id":"mysql",
			"liveTimeout":"5",
			"metaCacheTimeout":"60000",
			"paramDelimiter":"&",
            		"paramLeadingDelimiter":"?",
            		"paramSeparator":"=",
           	 	"password":"${DB_PASSWORD}",
            		"port":"${DB_PORT:3306}",
            		"storage":"false",
            		"username":"${DB_USER}",
			"validate":"false"
		}
	}

Hope it helps…

Damien

1 Like