0

I deployed moqui and mantle to docker environment, I used docker-compose to set up two docker comainter, tomcat and mariadb, and link them together.

The datasource conf is

<entity-facade crypt-pass="MoquiDefaultPassword:CHANGEME">
    <datasource group-name="transactional" database-conf-name="mysql" schema-name="">
        <inline-jdbc>
            <xa-properties user="moqui" password="moqui" pinGlobalTxToPhysicalConnection="true" serverName="192.168.1.237" port="3400" databaseName="CJZCDefault" autoReconnectForPools="true"
                useUnicode="true" encoding="UTF-8"/>
        </inline-jdbc>
    </datasource>

    <datasource group-name="tenantcommon" database-conf-name="mysql" schema-name="">
        <inline-jdbc>
            <xa-properties user="moqui" password="moqui" pinGlobalTxToPhysicalConnection="true" serverName="192.168.1.237" port="3400" databaseName="CJZCDefault" autoReconnectForPools="true"
                useUnicode="true" encoding="UTF-8"/>
        </inline-jdbc>
    </datasource>
</entity-facade>

When start tomcat docker container,

run java -jar moqui-2.0.0.war -load 

to load the data first, then start tomcat with

catalina.sh run

the first time data loading fails, the detail log is in below, but the second data loading success which triggered by tomcat.

if no explicitly run war package loading, it fails when tomcat trigger it, and no data is initialized in database.

It runs completely fine in the enviornment with tomcat (not in docker) with a docker mariadb.

Maybe i got some some environment wrong. if anyone meet same problem, then it may be worthy to dig deep.

Creating network "thirdparty_default" with the default driver
Creating thirdparty_db-qa_1
Creating thirdparty_server-qa_1
[cjzcAdmin@HZ-CJZC-SF-web01 third-party]$ sudo docker logs -f thirdparty_server-qa_1
Using temporary directory: /usr/local/tomcat/webapps/ROOT/execwartmp
Determined runtime from existing runtime directory: runtime
Canonicalized runtimePath: /usr/local/tomcat/webapps/ROOT/runtime
Loading data with args [{load=}]
15:42:39.490  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Initializing Moqui ExecutionContextFactoryImpl
 - runtime directory: /usr/local/tomcat/webapps/ROOT/runtime
 - runtime config:    /usr/local/tomcat/webapps/ROOT/runtime/conf/MoquiProductionConf.xml
15:42:39.575  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component tools              at file:/usr/local/tomcat/webapps/ROOT/runtime/base-component/tools
15:42:39.575  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component webroot            at file:/usr/local/tomcat/webapps/ROOT/runtime/base-component/webroot
15:42:39.585  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component mantle-udm         at file:/usr/local/tomcat/webapps/ROOT/runtime/component/mantle-udm
15:42:39.598  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component mantle-usl         at file:/usr/local/tomcat/webapps/ROOT/runtime/component/mantle-usl
15:42:39.598  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component moqui-zh_CN-addon  at file:/usr/local/tomcat/webapps/ROOT/runtime/component/moqui-zh_CN-addon
15:42:39.600  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added component zc-3plservices     at file:/usr/local/tomcat/webapps/ROOT/runtime/component/zc-3plservices
15:42:39.600  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Components after depends-on sort: [tools, webroot, mantle-udm, mantle-usl, moqui-zh_CN-addon, zc-3plservices]
15:42:39.621  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Merging MoquiConf.xml file from component zc-3plservices
15:42:39.648  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Merging runtime configuration at /usr/local/tomcat/webapps/ROOT/runtime/conf/MoquiProductionConf.xml
15:42:40.102  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Initializing worker ThreadPoolExecutor: queue limit 65535, pool-core 4, pool-max 16, pool-alive 60s
15:42:40.151  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Added JARs from component zc-3plservices: [zc-3plservices-0.0.1.jar]
15:42:40.192  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Not loading disabled ToolFactory with class: org.moqui.impl.tools.JackrabbitRunToolFactory
15:42:40.204  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Loading ToolFactory with class: org.moqui.jcache.MCacheToolFactory
15:42:40.217  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Loading ToolFactory with class: org.moqui.impl.tools.H2ServerToolFactory
15:42:40.253  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Cache Facade initialized
15:42:40.675  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Resource Facade initialized
15:42:40.698  WARN         main                      b.t.Configuration Cannot get the unique server ID for this JVM ('bitronix.tm.serverId'). Make sure it is configured and you use only US-ASCII characters. Will use IP address instead (unsafe for production usage!).
15:42:40.889  INFO         main .moqui.i.c.ExecutionContextFactoryImpl Transaction Facade initialized
Error loading or running Moqui.loadData with args [{load=}]: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
    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 MoquiStart.main(MoquiStart.java:114)
Caused by: java.util.ServiceConfigurationError: org.moqui.context.ExecutionContextFactory: Provider org.moqui.impl.context.ExecutionContextFactoryImpl could not be instantiated
    at java.util.ServiceLoader.fail(ServiceLoader.java:232)
    at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.moqui.Moqui.loadData(Moqui.java:79)
    ... 5 more
Caused by: bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named DEFAULT_transactional_DS
    at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:90)
    at org.moqui.impl.context.TransactionInternalBitronix.getDataSource(TransactionInternalBitronix.groovy:130)
    at org.moqui.impl.entity.EntityDatasourceFactoryImpl.init(EntityDatasourceFactoryImpl.groovy:82)
    at org.moqui.impl.entity.EntityFacadeImpl.initAllDatasources(EntityFacadeImpl.groovy:191)
    at org.moqui.impl.entity.EntityFacadeImpl.<init>(EntityFacadeImpl.groovy:120)
    at org.moqui.impl.context.ExecutionContextFactoryImpl.initEntityFacade(ExecutionContextFactoryImpl.groovy:687)
    at org.moqui.impl.context.ExecutionContextFactoryImpl.<init>(ExecutionContextFactoryImpl.groovy:196)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: Class [com.mysql.jdbc.jdbc2.optional.MysqlXADataSource] not found
    at MoquiStart$StartClassLoader.loadClass(MoquiStart.java:496)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at bitronix.tm.utils.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:80)
    at bitronix.tm.resource.common.XAFactoryHelper.createXAFactory(XAFactoryHelper.java:42)
    at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:94)
    at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:99)
    at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:86)
    ... 20 more
========== Shutting down Moqui Executable (closing jars, etc) ==========
14-Jul-2016 15:42:44.446 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.36
14-Jul-2016 15:42:44.447 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 9 2016 13:55:50 UTC
14-Jul-2016 15:42:44.448 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.36.0
14-Jul-2016 15:42:44.448 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
14-Jul-2016 15:42:44.448 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.10.0-327.22.2.el7.x86_64
14-Jul-2016 15:42:44.448 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
14-Jul-2016 15:42:44.448 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-8-openjdk-amd64/jre
14-Jul-2016 15:42:44.452 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_91-8u91-b14-1~bpo8+1-b14
14-Jul-2016 15:42:44.452 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
14-Jul-2016 15:42:44.452 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
14-Jul-2016 15:42:44.453 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
14-Jul-2016 15:42:44.454 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent An older version 1.1.32 of the APR based Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of 1.1.33
14-Jul-2016 15:42:44.454 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.1.32 using APR version 1.5.1.
14-Jul-2016 15:42:44.454 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
14-Jul-2016 15:42:44.548 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1k 8 Jan 2015)
14-Jul-2016 15:42:44.734 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
14-Jul-2016 15:42:44.761 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
14-Jul-2016 15:42:44.769 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1219 ms
14-Jul-2016 15:42:44.811 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
14-Jul-2016 15:42:44.811 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.36
14-Jul-2016 15:42:44.893 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/ROOT.war
14-Jul-2016 15:42:48.139 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
15:42:49.948  INFO -startStop-1       o.moqui.i.w.MoquiContextListener Loading Webapp 'webroot' (Moqui Root Webapp) on ROOT, located at: /usr/local/tomcat/webapps/ROOT/
15:42:50.314  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Initializing Moqui ExecutionContextFactoryImpl
 - runtime directory: /usr/local/tomcat/webapps/ROOT/runtime
 - runtime config:    /usr/local/tomcat/webapps/ROOT/runtime/conf/MoquiDevConf.xml
15:42:50.376  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component tools              at file:/usr/local/tomcat/webapps/ROOT/runtime/base-component/tools
15:42:50.376  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component webroot            at file:/usr/local/tomcat/webapps/ROOT/runtime/base-component/webroot
15:42:50.378  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component mantle-udm         at file:/usr/local/tomcat/webapps/ROOT/runtime/component/mantle-udm
15:42:50.383  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component mantle-usl         at file:/usr/local/tomcat/webapps/ROOT/runtime/component/mantle-usl
15:42:50.383  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component moqui-zh_CN-addon  at file:/usr/local/tomcat/webapps/ROOT/runtime/component/moqui-zh_CN-addon
15:42:50.384  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added component zc-3plservices     at file:/usr/local/tomcat/webapps/ROOT/runtime/component/zc-3plservices
15:42:50.385  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Components after depends-on sort: [tools, webroot, mantle-udm, mantle-usl, moqui-zh_CN-addon, zc-3plservices]
15:42:50.405  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Merging MoquiConf.xml file from component zc-3plservices
15:42:50.430  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Merging runtime configuration at /usr/local/tomcat/webapps/ROOT/runtime/conf/MoquiDevConf.xml
15:42:50.955  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Initializing worker ThreadPoolExecutor: queue limit 65535, pool-core 4, pool-max 16, pool-alive 60s
15:42:50.994  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Added JARs from component zc-3plservices: [zc-3plservices-0.0.1.jar]
15:42:51.008  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Not loading disabled ToolFactory with class: org.moqui.impl.tools.JackrabbitRunToolFactory
15:42:51.013  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Loading ToolFactory with class: org.moqui.jcache.MCacheToolFactory
15:42:51.021  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Loading ToolFactory with class: org.moqui.impl.tools.H2ServerToolFactory
15:42:51.036  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Cache Facade initialized
15:42:51.443  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Resource Facade initialized
15:42:51.535  WARN -startStop-1                      b.t.Configuration Cannot get the unique server ID for this JVM ('bitronix.tm.serverId'). Make sure it is configured and you use only US-ASCII characters. Will use IP address instead (unsafe for production usage!).
15:42:51.853  WARN -startStop-1                      b.t.j.DiskJournal active log file is unclean, did you call BitronixTransactionManager.shutdown() at the end of the last run?
15:42:51.884  INFO -startStop-1 .moqui.i.c.ExecutionContextFactoryImpl Transaction Facade initialized
15:42:52.929  INFO -startStop-1           o.moqui.i.e.EntityFacadeImpl Loaded 12 Entity ECA rules from 3 .eecas.xml files
15:42:52.944  INFO -startStop-1                    o.m.i.e.EntityCache Entity Cache initialized, distributed cache invalidate enabled: false
Jimmy Shen
  • 240
  • 1
  • 12

1 Answers1

0

I am running Moqui, deployed on Apache Tomcat server, connected to a PostgreSQL. Both application and database servers are in separate containers. The situation is slightly different, but analogical enough to post a few notes.

DB Driver

First thing I noticed in your error stack trace is, that there is (probably) a problem with connecting to a database.

Class [com.mysql.jdbc.jdbc2.optional.MysqlXADataSource] not found

Check your driver for connecting to the database. As I wrote, I am using PostgreSQL and the first thing I install is a PostgreSQL JDBC Driver. Then I copy the driver's JAR file into moqui/runtime/lib directory, so that the application can use it during runtime, in my case as follows:

cp /var/tmp/postgresql-9.2-1002.jdbc4.jar /opt/vi/moqui/runtime/lib

Linking containers

What works for me is using the Link feature of Docker. The container for the database server is named simply pg. That is the name you see after running the latter command in the last column of the output:

docker ps -a

When running the application server's container, use the link parameter to establish a link between those two containers, in my case:

docker run -it --name srv05 --link pg:pg -p 443:8443 -p 80:8080 tomcat:8.5

The --link parameter says, that the pg container (available from the docker host) will be available under the same name (pg) in the newly created container.

In the MoquiConf file, replace the IP address (192.168.1.237) with the pg (you can name it differently, of course, I am just following my case). You can check you can connect to the (container of) database server (using your logical name) from inside your application server's (newly created) container by a simple ping command.

ping pg

For more info on linking containers, check the following: https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/

Hope it helps.

mrovnanik
  • 123
  • 9
  • For the issue Class [com.mysql.jdbc.jdbc2.optional.MysqlXADataSource] not found, I solved it by adding oracle jdk as tomcat jre. for issue connection refused, it happened because although the docker compose ensure tomcat container starts after mariadb container, but when tomcat catalina runs, the mariadb mysql service is not ready yet, so connection is refused. To force tomcat container wait and catalina run after mariadb service 3306 port is ready, I add https://github.com/aanand/docker-wait/blob/master/wait, and command for tomcat container is /bin/bash -c "/wait && catalina.sh run" – Jimmy Shen Jul 15 '16 at 00:39
  • Maybe Class [com.mysql.jdbc.jdbc2.optional.MysqlXADataSource] not found issue is also caused by connection refused of failing to connect to mariadb. so jdk for tomcat may not be necessary. – Jimmy Shen Jul 15 '16 at 00:47
  • Here is complete Dockerfile for moqui runtime https://github.com/shendepu/docker-moqui-mantle. – Jimmy Shen Jul 15 '16 at 05:15
  • It's a bit different deployment strategy to the one I use. Good to here you are rolling again. – mrovnanik Jul 15 '16 at 07:29