alkacon / opencms-core

The Java open source content management system by Alkacon Software
http://www.opencms.org
GNU Lesser General Public License v2.1
520 stars 575 forks source link

problem to connect opencms docker to external database AWS #770

Closed alvaromartmunoz closed 9 months ago

alvaromartmunoz commented 11 months ago

Hi all!.

i trying to run opencms on EC2 instance AWS. I decide to run a rds database to save all files externally and i get the following error:

=== START OPENCMS SHELL === Installing modules from /config/update-core-modules.ocsh using OpenCms home /usr/local/tomcat/webapps/ROOT Trouble reading script file "/config/update-core-modules.ocsh", using SDTIN instead. No OpenCms home folder given. Trying to guess...

OpenCms WEB-INF path: "/usr/local/tomcat/webapps/ROOT/WEB-INF". OpenCms property file: "/usr/local/tomcat/webapps/ROOT/WEB-INF/config/opencms.properties".


The following critical error occurred: Critical error during OpenCms initialization: Unable to initialize connection pool "default". Is the database up and running? Giving up, unable to start OpenCms.

org.opencms.main.CmsInitException: Critical error during OpenCms initialization: Unable to initialize connection pool "default". Is the database up and running? at org.opencms.db.CmsDriverManager.newPoolInstance(CmsDriverManager.java:6356) at org.opencms.db.CmsDriverManager.newInstance(CmsDriverManager.java:660) at org.opencms.db.CmsSecurityManager.init(CmsSecurityManager.java:3535) at org.opencms.db.CmsSecurityManager.newInstance(CmsSecurityManager.java:172) at org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:1692) at org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:2578) at org.opencms.main.CmsShell.(CmsShell.java:569) at org.opencms.main.CmsShell.main(CmsShell.java:676) Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:168) at com.zaxxer.hikari.util.PropertyElf.lambda$setTargetFromProperties$0(PropertyElf.java:59) at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603) at java.base/java.util.Properties.forEach(Properties.java:1446) at com.zaxxer.hikari.util.PropertyElf.setTargetFromProperties(PropertyElf.java:54) at com.zaxxer.hikari.HikariConfig.(HikariConfig.java:139) at org.opencms.db.CmsDbPoolV11.createHikariConfig(CmsDbPoolV11.java:249) at org.opencms.db.CmsDbPoolV11.(CmsDbPoolV11.java:138) at org.opencms.db.CmsDriverManager.newPoolInstance(CmsDriverManager.java:6349) ... 7 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:153) ... 15 more Caused by: java.lang.RuntimeException: Failed to load driver class 1 in either of HikariConfig class loader or Thread context classloader at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:490) ... 20 more Exception in thread "main" java.lang.NullPointerException at java.base/java.lang.Throwable.printStackTrace(Throwable.java:657) at java.base/java.lang.Throwable.printStackTrace(Throwable.java:648) at org.opencms.main.CmsShell.execute(CmsShell.java:826) at org.opencms.main.CmsShell.execute(CmsShell.java:741) at org.opencms.main.CmsShell.main(CmsShell.java:686) === END OPENCMS SHELL ===

I have the next docker-compose.yml:

version: '3.7' services: opencms: image: alkacon/opencms-docker:15.0 container_name: opencms init: true restart: always ports:

and i can connect succesfully to mysql rds database. image

Anyone can help me¿? I think it´s related with this issue: Use external database #12 but don´t get me the solution. Thanks

asgerjensen commented 10 months ago

Hmm, we have something like this. We use RDS and opencms is hosted in kubernetes.

opencms.properties:db.pool.default.jdbcDriver=com.mysql.cj.jdbc.Driver
opencms.properties:db.pool.default.jdbcUrl=jdbc:mysql://ZZZZZ.eu-north-1.rds.amazonaws.com:3306/qa
opencms.properties:db.pool.default.jdbcUrl.params=?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
opencms.properties:db.pool.default.user=XXXXX
opencms.properties:db.pool.default.password=XXXXX
opencms.properties:db.pool.default.poolUrl=opencms:default
opencms.properties:db.pool.default.v11.maximumPoolSize=40
opencms.properties:db.pool.default.v11.connectionTestQuery=
opencms.properties:db.pool.default.v11.dataSource.useLocalSessionState=true
opencms.properties:db.pool.default.v11.dataSource.cacheResultSetMetadata=true
opencms.properties:db.pool.default.v11.dataSource.cachePrepStmts=true
opencms.properties:db.pool.default.v11.dataSource.useServerPrepStmts=true
opencms.properties:db.pool.default.v11.dataSource.prepStmtCacheSqlLimit=2048
opencms.properties:db.pool.default.v11.dataSource.maintainTimeStats=false
opencms.properties:db.pool.default.v11.dataSource.prepStmtCacheSize=250
opencms.properties:db.pool.default.v11.dataSource.rewriteBatchedStatements=true
opencms.properties:db.pool.default.v11.dataSource.elideSetAutoCommits=true
opencms.properties:db.pool.default.v11.dataSource.useLocalTransactionState=true
opencms.properties:db.pool.default.v11.dataSource.cacheServerConfiguration=true

Aside from maybe granting the kuberentes server the proper rights to access RDS, i dont seem to remember us doing anything weird in this regard.

gWestenberger commented 9 months ago

We can't help you with this. I suspect that something is overwriting / corrupting the opencms.properties file, but that is purely a guess - we have no expertise with AWS.