Couldn't find the specified JDBC driver class name: org.postgresql.Driver

419 views
Skip to first unread message

Viktor Wottschel

unread,
Aug 13, 2021, 11:52:43 AM8/13/21
to xnat_discussion
Hi all,
I'm trying to do a fresh install of XNAT 1.8.2.2 on CentOS 8.

I did a yum install of java-1.8.0-openjdk, installed Tomcat 9.0.52 by downloading the tar.gz from apache.org and copying the content to /use/share/tomcat and installed postgresql 13 using dnf install postgresql-server.

Postgres has a user and a database called xnat, tomcat itself is running but won't spin up the xnat webapp. 
When I look at the xnat log files, only spring.log has any content and it's complaining about a missing JDBC driver. However, this driver is in the WEB-INF/lib of the xnat webapp as well as in my /usr/share/java/.

I tried deactivating SELinux but it didn't make a different.

Any help would be greatly appreciated.

Many thanks,
Viktor

spring.log
        ... 115 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionFactory' defined in class path resource [org/nrg/xnat/configuration/OrmConfig.class]: Unsatisfied dependency expressed through method 'sessionFactory' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in org.nrg.xnat.initialization.DatabaseConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.nrg.framework.exceptions.NrgServiceException: Error [ConfigurationError]: Error [ConfigurationError]: Couldn't find the specified JDBC driver class name: org.postgresql.Driver
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1176)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1071)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
        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:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:211)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1134)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:658)
        ... 128 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in org.nrg.xnat.initialization.DatabaseConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.nrg.framework.exceptions.NrgServiceException: Error [ConfigurationError]: Error [ConfigurationError]: Couldn't find the specified JDBC driver class name: org.postgresql.Driver
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1176)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1071)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
        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:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:211)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1134)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
        ... 141 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.nrg.framework.exceptions.NrgServiceException: Error [ConfigurationError]: Error [ConfigurationError]: Couldn't find the specified JDBC driver class name: org.postgresql.Driver
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
        ... 154 common frames omitted
Caused by: org.nrg.framework.exceptions.NrgServiceException: Error [ConfigurationError]: Couldn't find the specified JDBC driver class name: org.postgresql.Driver
        at org.nrg.xnat.initialization.DatabaseConfig.getConfiguredDataSource(DatabaseConfig.java:94)
        at org.nrg.xnat.initialization.DatabaseConfig.dataSource(DatabaseConfig.java:45)
        at org.nrg.xnat.initialization.DatabaseConfig$$EnhancerBySpringCGLIB$$b65edc40.CGLIB$dataSource$3(<generated>)
        at org.nrg.xnat.initialization.DatabaseConfig$$EnhancerBySpringCGLIB$$b65edc40$$FastClassBySpringCGLIB$$28eb7d.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
        at org.nrg.xnat.initialization.DatabaseConfig$$EnhancerBySpringCGLIB$$b65edc40.dataSource(<generated>)
        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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
        ... 155 common frames omitted

ph_hba.conf
host    all             all             0.0.0.0/0               md5
local   all             all                                     md5
host    all             all             ::1/128                 md5

xnat-conf.properties
datasource.driver=org.postgresql.Driver
datasource.url=jdbc:postgresql://localhost/xnat
datasource.username=xnat
datasource.password=supersecretpassword

hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true

Herrick, Rick

unread,
Aug 13, 2021, 5:09:33 PM8/13/21
to xnat_di...@googlegroups.com

Rather than installing Tomcat in /usr/share/tomcat and trying to duplicate the deployment from CentOS 7, try installing somewhere like /opt/tomcat. Make sure that the user you’re using to run Tomcat also owns /opt/tomcat and everything below it.

 

How are you actually running Tomcat? Have you created a systemd unit for it, like /etc/systemd/system/tomcat.service? systemd has a lot of security features that can cause trouble even outside of SELinux (CentOS 8 has some on its own as well, but I’m not very familiar with what’s in there). For example, the unit file for tomcat9 on Ubuntu 20.04 includes these:

 

ReadWritePaths=/etc/tomcat9/Catalina/

ReadWritePaths=/var/lib/tomcat9/webapps/

ReadWritePaths=/var/log/tomcat9/

 

Without those entries, the Tomcat user can’t read and write to the webapps and log folders, even though the Tomcat user owns them and has write permissions there.

 

My guess (and the reason I suggested trying /opt/tomcat) is that CentOS has some security provisions for significant folders like /usr or /usr/share that are preventing the app from accessing the jar file. Of course, the application is running enough to get to the point where it’s trying to load the JDBC driver, so that’s weird… Anyway, I just set this up real quick, the same config you described but in /opt/tomcat and it ran fine, with one change required being to /var/lib/pgsql/data/pg_hba.conf (by default these use ident instead of md5):

 

host    all             all             127.0.0.1/32            md5

host    all             all             ::1/128                 md5

 

Change that, restart postgres, and XNAT started up fine.

 

-- 

Rick Herrick

Sr. Programmer/Analyst

Neuroinformatics Research Group

Washington University School of Medicine

Phone: +1 (314) 273-1645

 

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Viktor Wottschel <viktor.w...@gmail.com>
Date: Friday, August 13, 2021 at 10:52 AM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] Couldn't find the specified JDBC driver class name: org.postgresql.Driver

* External Email - Caution *

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/96fb6d72-f77f-4781-96f9-2d2040e29af7n%40googlegroups.com.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Viktor Wottschel

unread,
Sep 17, 2021, 2:49:25 AM9/17/21
to xnat_discussion
Apologies for not replying here earlier.

The installation location doesn't seem to matter too much. We have had several other XNAT instances running in /usr/share as well with no problems.
It also didn't work for me when I moved things to /opt with my current setup.

What did do the trick was a change from PostgreSQL 13 to 12.
Rick pointed out in a different thread that version 13 was not available for testing at the time of the last XNAT release, so there might simply be some minor incompatibilities.

Reply all
Reply to author
Forward
0 new messages