• FEATURES
  • PRICING
  • MARKETPLACE
  • CASE STUDIES
  • BLOG
  • OpenSpecimen cannot connect to MySQL Database

    Hello all,

    I am trying to deploy a new instance of the Community version of OpenSpecimen on github using CentOS 7. I am running Apache in the front of the server (port 80) and redirecting via mod_proxy to Tomcat 7 (port 8080). I am able to access Tomcat just fine from a browser, so I know that I have set up Apache correctly. I have followed the instructions at the How to build from source code confulence article, but for some reason the application cannot connect to my local mysql database. I know this due to the following error in Tomcat:

    Oct 12, 2017 12:54:23 PM org.apache.catalina.core.ApplicationContext log
    INFO: SessionListener: contextDestroyed()
    Oct 12, 2017 12:54:23 PM org.apache.catalina.core.ApplicationContext log
    INFO: ContextListener: contextDestroyed()
    Oct 12, 2017 12:54:33 PM org.apache.catalina.core.ApplicationContext log
    INFO: No Spring WebApplicationInitializer types detected on classpath
    Oct 12, 2017 12:54:33 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    Oct 12, 2017 12:54:38 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘de-liquibase’ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: liquibase.exception.DatabaseException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
    … 25 more
    Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:363)
    … 27 more
    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
    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 com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2570)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2306)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:839)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:49)
    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 com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)
    at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
    … 30 more
    Caused by: java.lang.NullPointerException
    at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3281)
    at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1940)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1866)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2488)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2521)
    … 44 more

    I can see that the error clearly states “Could not create connection to database server.” I have checked the mysql logs, and I am not seeing any log in attempt at all. I have also checked the tomcat logs and it doesn’t look like it’s trying to access the $TOMCAT_HOME/conf/context.xml file. This is my tag in context.xml:

    I have checked with netstat -nap that the mysql port 3306 is listening at 127.0.0.1:3306. I have ensured that the mysql-connector-java.jar file is in the correct place ($TOMCAT_HOME/lib). I have tried changing the URL in the context.xml file to be 127.0.0.1:3306 instead of localhost with no luck in correcting the error. Do you have any insight as to why OpenSpecimen is not receiving the correct MySQL information?

    Thanks,
    David Kraemer

    Hello @David_Kraemer

    This appears to be because of using incorrect encoding. Can you please ensure the JVM system property “file.encoding” is set to UTF-8 i.e. -Dfile.encoding=UTF-8 as JVM argument.

    Thanks,
    Vinayak

    Hi there Vinayak,

    Thanks for the response. It doesn’t look like that has solved the issue. I’ve added “-Dfile.encoding=UTF-8” to my JAVA_OPTS in tomcat.conf, as well as in the Connector in server.xml. Checking the environment language, by running “env | grep LANG” reads as en_US.UTF-8.

    Hi all,

    So I decided to re-deploy the whole application from scratch, and it looks like everything is working properly in terms of the above errors (I didn’t do anything different in the configuration?). However, now I am running into another issue:

    Oct 13, 2017 10:08:41 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultSpecimenLabelPrinter’ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is com.krishagni.catissueplus.core.common.errors.OpenSpecimenException: null id in com.krishagni.catissueplus.core.common.domain.PrintRuleConfig entry (don’t flush the Session after an exception occurs)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: com.krishagni.catissueplus.core.common.errors.OpenSpecimenException: null id in com.krishagni.catissueplus.core.common.domain.PrintRuleConfig entry (don’t flush the Session after an exception occurs)
    at com.krishagni.catissueplus.core.common.errors.OpenSpecimenException.serverError(OpenSpecimenException.java:136)
    at com.krishagni.catissueplus.core.common.TransactionalInterceptor.doWork(TransactionalInterceptor.java:91)
    at com.krishagni.catissueplus.core.common.TransactionalInterceptor.ajc$inlineAccessMethod$com_krishagni_catissueplus_core_common_TransactionalInterceptor$com_krishagni_catissueplus_core_common_TransactionalInterceptor$doWork(TransactionalInterceptor.java:1)
    at com.krishagni.catissueplus.core.common.TransactionalInterceptor.startTransaction(TransactionalInterceptor.java:64)
    at com.krishagni.catissueplus.core.biospecimen.services.impl.DefaultSpecimenLabelPrinter.afterPropertiesSet(DefaultSpecimenLabelPrinter.java:142)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
    … 25 more

    I’m not sure what it is referring to regarding the ‘defaultSpecimenLabelPrinter’? There’s no mention of this in the deployment instructions?

    David, It seems like you are taking the code from the master. Instead, can you take from the last released version:

    The master being the latest might not be always the greatest! :slight_smile:

    ~Sri

    I’m using the command “git clone --depth 10 https://github.com/krishagni/openspecimen.git” which is what the clone link provides in the link you gave above. Is that incorrect?

    The documentation is updated for getting the code from the tag.

    https://openspecimen.atlassian.net/wiki/x/MwcR

    ~Sri

    Hello Sri,

    I tried to deploy the community edition a couple of times and always run into some strange issues, which finally always lead to a not running installation.
    I tried it with openSuse, Debian and Fedora.
    Are you sure, this documentation is uptodate?
    Also tried v7.2.RC1
    and v6.3.RC8

    Or is there another installation guide, maybe?

    Best regards
    Stefan

    Yes, it is up to date and many centers have used it to install the CE. Can you post the issues you faced?

    ~Sri

    Thanks for your reply :slight_smile:

    I was wondering because some of the described versions of the prerequsited programs are not available.
    The pre-requisites download page http://www.openspecimen.org/prerequisites/ isn’t available, too.

    So maybe some of my issues are because of the not matching versions.
    What I recognised is, that libpng-dev is a requirement. And it only works with Node10. With all versions above the installation fails.

    Running npm install ends with some “depracated” and “version mismatch” warnings, but without any errors.
    Bower, too, ends with some “Code incompatibilities may occur” warnings.
    But even with that, gradle deploy ends up with a deployed openspecimen.war file with a corespondending folder in tomcat webapps directory.

    After starting tomcat it always ends with this Exception

     16-Dec-2020 14:00:28.006 INFORMATION [main] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
    16-Dec-2020 14:00:28.142 INFORMATION [main] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
    16-Dec-2020 14:00:29.852 SCHWERWIEGEND [main] org.apache.catalina.core.StandardContext.listenerStart Fehler beim Senden der 'Context Initialized' Benachrichtigung an den Listener aus der Klasse [org.springframework.web.context.ContextLoaderListener]
            org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSourceFactory]
                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
                    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
                    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
                    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
                    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
                    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742)
                    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
                    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
                    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
                    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
                    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
                    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4678)
                    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139)
                    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
                    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
                    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
                    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
                    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
                    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848)
                    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
                    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
                    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
                    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
                    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576)
                    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
                    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
                    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
                    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
                    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
                    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
                    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
                    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
                    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
                    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
                    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
                    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
                    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
                    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
                    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
                    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
                    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
                    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
                    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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
                    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
           Caused by: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSourceFactory]
                    at org.apache.naming.factory.ResourceFactory.getDefaultFactory(ResourceFactory.java:53)
                    at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:92)
                    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:857)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:160)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:160)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:160)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
                    at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
                    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
                    at javax.naming.InitialContext.lookup(InitialContext.java:417)
                    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
                    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
                    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
                    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
                    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
                    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
                    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
                    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689)
                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
                    ... 53 more
            Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSourceFactory
                    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
                    at java.lang.Class.forName0(Native Method)
                    at java.lang.Class.forName(Class.java:264)
                    at org.apache.naming.factory.ResourceFactory.getDefaultFactory(ResourceFactory.java:50)
                    ... 75 more
    16-Dec-2020 14:00:29.856 INFORMATION [main] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
    

    The class “org.apache.commons.dbcp.BasicDataSourceFactory” is available in the WEB-INF/lib directory.
    Copying the file to the TOMCAT_HOME/lib directory leads to a crashing tomcat.

    Any advice is highly appreciated.

    resource [/WEB-INF/applicationContext.xml] check this XML for incorrect paths towards the class … maybe your directory Structure different from the one the repository defines.

    Hello Simon,

    thank you for your advice.
    I am not sure, what I have to look for.

    The dataSource-Bean is defined like this

     <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="${datasource.jndi}"/>
      </bean>
    

    org.springframework.jndi.JndiObjectFactoryBean is found in spring-context-4.3.19.RELEASE.jar in the WEB-INF/lib directory.

    Sorry i guess this is WAY WAY WAY too late …
    But you have to give Tomcat a to begin with. I do this by adding a “context.xml” file within the conf.
    In there i define my java sql connector class and where to find the DB (a container running mysql in my case).

    <?xml version="1.0" encoding="UTF-8"?> WEB-INF/web.xml WEB-INF/tomcat-web.xml ${catalina.base}/conf/web.xml
    <Resource name="jdbc/openspecimen" driverClassName="com.mysql.cj.jdbc.Driver" url="jdbc:mysql://172.18.0.2:3306/openspecimen" auth="Container" maxActive="100" password="aPASSWORD" maxWait="10000" username="openspecimen" maxIdle="30" type="javax.sql.DataSource"/>
    
    <Environment name="config/openspecimen" value="pathToProperties" type="java.lang.String"/>
    
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->