Alfresco by default connecting to MySQL

cancel
Showing results for 
Search instead for 
Did you mean: 
logicallimit
Active Member II

Alfresco by default connecting to MySQL

Jump to solution

I just set up a fresh Alfresco Community 6.2 on a VM of centos 7.

Problem is that, I have set alfresco.global.properties file to connect to PostgreSQL but in logs it shows that it is trying to connect with MySQL.  I have copied the driver jar file postgresql-42.2.6.jar to the lib folder of tomcat as well as to the shared/lib folder inside tomcat home directory. I used the version postgresql-42.2.11.jar also but same error is thrown.

How can I make it connect to PostgresSQL. Am I missing something?

I have set following databse settings in alfresco.global.properties file

Spoiler
#
# MySQL connection
#
#db.driver=org.gjt.mm.mysql.Driver
#db.url=jdbc:mysql://localhost/alfresco?useUnicode=yes&characterEncoding=UTF-8

#
# Oracle connection
#
#db.driver=oracle.jdbc.OracleDriver
#db.url=jdbcSmiley Surprisedracle:thin:@localhost:1521:alfresco

#
# SQLServer connection
# Requires SNAPSHOT isolation mode
# Enable TCP protocol on fixed port 1433
# Prepare the database with:
# ALTER DATABASE alfresco SET ALLOW_SNAPSHOT_ISOLATION ON;
#
#db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#db.url=jdbc:sqlserver://${db.host}:${db.port};databaseName=${db.name};lockTimeout=1000;
#db.txn.isolation=4096

#
# PostgreSQL connection (requires postgresql-8.2-504.jdbc3.jar or equivalent)
#
db.driver=org.postgresql.Driver
db.url=jdbcSmiley Tongueostgresql://localhost:5432/alfresco

 Following is the log of alfresco.log

Spoiler
2020-03-30 01:11:30,837 WARN [org.springframework.web.context.support.XmlWebApplicationContext] [localhost-startStop-1] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.CustomEditorConfigurer#0' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'customPropertyEditorRegistrar' while setting bean property 'propertyEditorRegistrars' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customPropertyEditorRegistrar' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'NamespaceService' while setting bean property 'namespaceService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dictionaryDAO' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'tenantService' while setting bean property 'tenantService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantService' defined in URL [jar:file:/usr/local/tomcat-8_5_53/webapps/alfresco/WEB-INF/lib/alfresco-repository-7.134.1.jar!/alfresco/mt/mt-context.xml]: Cannot resolve reference to bean 'tenantAdminDAO' while setting bean property 'tenantAdminDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantAdminDAO' defined in class path resource [alfresco/dao/dao-context.xml]: Cannot resolve reference to bean 'repoSqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repoSqlSessionTemplate' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot resolve reference to bean 'repoSqlSessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repoSqlSessionFactory' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot resolve reference to bean 'dialectResourceLoader' while setting bean property 'resourceLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectResourceLoader' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot create inner bean 'org.springframework.beans.factory.config.PropertyPathFactoryBean#f42c403' of type [org.springframework.beans.factory.config.PropertyPathFactoryBean] while setting bean property 'dialectClass'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPathFactoryBean#f42c403' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialect': FactoryBean threw exception on object creation; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'
2020-03-30 01:11:30,901 ERROR [org.springframework.web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.CustomEditorConfigurer#0' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'customPropertyEditorRegistrar' while setting bean property 'propertyEditorRegistrars' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customPropertyEditorRegistrar' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'NamespaceService' while setting bean property 'namespaceService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dictionaryDAO' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'tenantService' while setting bean property 'tenantService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantService' defined in URL [jar:file:/usr/local/tomcat-8_5_53/webapps/alfresco/WEB-INF/lib/alfresco-repository-7.134.1.jar!/alfresco/mt/mt-context.xml]: Cannot resolve reference to bean 'tenantAdminDAO' while setting bean property 'tenantAdminDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantAdminDAO' defined in class path resource [alfresco/dao/dao-context.xml]: Cannot resolve reference to bean 'repoSqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repoSqlSessionTemplate' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot resolve reference to bean 'repoSqlSessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repoSqlSessionFactory' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot resolve reference to bean 'dialectResourceLoader' while setting bean property 'resourceLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectResourceLoader' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Cannot create inner bean 'org.springframework.beans.factory.config.PropertyPathFactoryBean#f42c403' of type [org.springframework.beans.factory.config.PropertyPathFactoryBean] while setting bean property 'dialectClass'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPathFactoryBean#f42c403' defined in class path resource [alfresco/ibatis/ibatis-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialect': FactoryBean threw exception on object creation; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:399)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:159)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1681)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1433)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:171)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:70)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:614)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1823)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

 

1 Solution

Accepted Solutions
narkuss
Established Member II

Re: Alfresco by default connecting to MySQL

Jump to solution

Alfresco is not picking up your alfresco-global.properties file. How did you install Alfresco?

In an "old school" installation, tomcat bundle must be modified a bit to pick up you properties file from tipical shared/classes route. Check that you have properly set up catalina.properties file @ tomcat/conf, specify shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar.

Hope it helps

View solution in original post

7 Replies
narkuss
Established Member II

Re: Alfresco by default connecting to MySQL

Jump to solution

Alfresco is not picking up your alfresco-global.properties file. How did you install Alfresco?

In an "old school" installation, tomcat bundle must be modified a bit to pick up you properties file from tipical shared/classes route. Check that you have properly set up catalina.properties file @ tomcat/conf, specify shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar.

Hope it helps

angelborroy
Alfresco Employee

Re: Alfresco by default connecting to MySQL

Jump to solution

I guess your alfresco-global.properties is not being loaded.

Did you configure Tomcat to load the "shared/classes" folder? Usually this is done with the alfresco.xml file located in "tomcat/conf/Catalina/localhost" folder.

Hyland Developer Evangelist
afaust
Master

Re: Alfresco by default connecting to MySQL

Jump to solution

Minor correction to @angelborroy 's answer. The shared/classes folder is typically configured within tomcat/conf/catalina.properties - the tomcat/conf/Catalina/localhost/alfresco.xml file can be used to configure an external directory as an extension to the classpath of Alfresco, but that (in the past) typically mapped to <installRoot>/modules/platform.

Technically, it can be used to configure shared/classes as well, but that would be against common Tomcat conventions and might confuse people more familiar with Tomcat than Alfresco.

logicallimit
Active Member II

Re: Alfresco by default connecting to MySQL

Jump to solution

Thanks @narkuss for the pointer. I had made this entry in the catalina.properties file already.

But that gave me a pointer to the actual problem. And the problem was in the environment variable.

I did echo to check the value of environment variable "CATALINA_BASE", and it was blank. And that is why, tomcat was not able to load the shared folder's alfresco-global.properties file. "shared.loader" property in catalina.properties file uses this env variable to build path to /shared/classes folder. Since it was blank so the path to /shared/classes was not getting completely build and therefore ultimately alfresco-global.properties file was not getting loaded.

In the file /etc/systemd/system/tomcat.service, I was setting environment ariables as follows:

Environment=CATALINA_HOME=/usr/local/tomcat-8_5_53

Environment=CATALINA_BASE=/usr/local/tomcat-8_5_53

Don't know why it didn't work.

I replaced it with following and it worked like a charm.

export CATALINA_HOME=/usr/local/tomcat-8_5_53
export CATALINA_BASE=/usr/local/tomcat-8_5_53

But yes remember to change things as tomcat user or if changing as root, then run command

chown -R tomcat:tomcat /usr/local/tomcat-8_5_53

otherwise access related issue would come up.

 

However, I see a repeated error in log file which I am further looking into.

ERROR [org.alfresco.repo.content.transform.LocalTransformServiceRegistry] [QuartzScheduler_Worker-2] 02300021 Failed to connect or to read the response from T-Engine on http://localhost:8093/transform/config

 

logicallimit
Active Member II

Re: Alfresco by default connecting to MySQL

Jump to solution

@angelborroyYes you are right. It was not getting loaded due to CATALINA_BASE being not set.

logicallimit
Active Member II

Re: Alfresco by default connecting to MySQL

Jump to solution

Thanks @afaust  for the extra information. That was also pretty useful to track down to the root cause of my problem.

EddieMay
Alfresco Employee

Re: Alfresco by default connecting to MySQL

Jump to solution

Hi @logicallimit,

Great that you've resolved your issue. Thanks also for your detailed explanation of the solution - helps others with a similar problem.

Cheers, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!