Database connectivity Issue

54 views
Skip to first unread message

Keith Jones

unread,
Jun 17, 2019, 9:21:26 AM6/17/19
to DSpace Technical Support
Hi All,

I'm trying to move an installation of Dspace 5.3 to a new Centos 7
server. I've installed all the software required and have everything
running. I'm able to compile the Dspace software, which goes without a
problem. I test the database connection and it works fine. When I
deploy the xmlui into the webapps area of Tomcat, I'm getting the
following error:

SEVERE: Exception sending context destroyed event to listener instance
of class org.dspace.app.util.DS
paceContextListener
java.lang.IllegalStateException: The connection attempt failed.
at org.dspace.storage.rdbms.DatabaseManager.getDataSource(DatabaseManager.java:655)
at org.dspace.storage.rdbms.DatabaseManager.getConnection(DatabaseManager.java:629)
at org.dspace.core.Context.init(Context.java:121)
at org.dspace.core.Context.<init>(Context.java:95)
at org.dspace.app.util.AbstractDSpaceWebapp.deregister(AbstractDSpaceWebapp.java:97)
at org.dspace.app.util.DSpaceContextListener.contextDestroyed(DSpaceContextListener.java:146)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5165)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5829)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:149)
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.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
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: org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:
152)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:32)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnec
tionFactory.java:75)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java
:582)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
at org.dspace.storage.rdbms.DatabaseManager.initialize(DatabaseManager.java:1336)
at org.dspace.storage.rdbms.DatabaseManager.getDataSource(DatabaseManager.java:650)
... 19 more
Caused by: java.net.SocketException: Permission denied (connect failed)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at org.postgresql.core.PGStream.<init>(PGStream.java:62)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:
76)
... 35 more

Any help would be appreciated.

Thanks
Keith

Ayuka Phanuel

unread,
Jun 17, 2019, 9:26:39 AM6/17/19
to Keith Jones, DSpace Technical Support
Confirm your database credentials (name, url, password, username) added to your local.cfg or dspace.cfg



--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/CAJ6iCzMqLuYnomow3ngk2HPSMH_ybkg0Qj34E%3D_0J9QdLvd7LQ%40mail.gmail.com.

Keith Jones

unread,
Jun 17, 2019, 9:37:09 AM6/17/19
to Ayuka Phanuel, DSpace Technical Support
Hi,
I checked the dspace.cfg file and the information is correct.

I've run this:

-bash-4.2$ ../bin/dspace database test

Attempting to connect to database using these configurations:
- URL: jdbc:postgresql://localhost:5432/dspace
- Driver: org.postgresql.Driver
- Username: dspace
- Password: [hidden]
- Schema:

Testing connection...
Connected successfully!

Tony Brian Albers

unread,
Jun 18, 2019, 12:26:19 AM6/18/19
to ayukap...@gmail.com, mad...@udel.edu, dspac...@googlegroups.com
What does getenforce say? This might be SELinux doing its job ;)

Check /var/log/audit/audit.log for stuff related to tomcat/catalina,
pgsql etc.

Check the pgsql logs, they usually have some pointer as to where it
goes wrong. Also check the tomcat logs.

And an important thing:

The password stated in dspace.cfg or local.cfg must be entered as
follows:

db.password = un@b0mb3R?

make sure the spaces are there and be careful that your password
doesn't contain = or localized characters (german umlaut etc.)

also try to connect to pgsql directly from the CLI as the dspace user
like so:

[dspace@rigel config]$ psql -U dspace -W -d dspace
Password for user dspace: 
psql (9.5.14)
Type "help" for help.

dspace=>> \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access
privileges   
-----------+----------+----------+-------------+-------------+---------
--------------
 dspace    | dspace   | UTF8     | C           | C           | 
 postgres  | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | 
 template0 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
=c/postgres          +
           |          |          |             |             |
postgres=CTc/postgres
 template1 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
=c/postgres          +
           |          |          |             |             |
postgres=CTc/postgres
(4 rows)

dspace=>

HTH

/tony
--
Tony Albers - Systems Architect - IT Development
Royal Danish Library, Victor Albecks Vej 1, 8000 Aarhus C, Denmark
Tel: +45 2566 2383 - CVR/SE: 2898 8842 - EAN: 5798000792142

Keith Jones

unread,
Jun 26, 2019, 9:52:22 AM6/26/19
to Tony Brian Albers, ayukap...@gmail.com, dspac...@googlegroups.com
Hi Thanks for the information:

I used the getenforce and the result says: Enforcing.

Checking the audit log gives me this error:

type=AVC msg=audit(1561555586.173:6325): avc: denied { name_connect
} for pid=15077 comm="java" des
t=5432 scontext=system_u:system_r:tomcat_t:s0
tcontext=system_u:object_r:postgresql_port_t:s0 tclass=t
cp_socket permissive=0
type=SYSCALL msg=audit(1561555586.173:6325): arch=c000003e syscall=42
success=no exit=-13 a0=35 a1=7f6
7977312f0 a2=1c a3=224 items=0 ppid=1 pid=15077 auid=4294967295 uid=53
gid=53 euid=53 suid=53 fsuid=53
egid=53 sgid=53 fsgid=53 tty=(none) ses=4294967295 comm="java"
exe="/usr/lib/jvm/java-1.8.0-openjdk-1
.8.0.212.b04-0.el7_6.x86_64/jre/bin/java"
subj=system_u:system_r:tomcat_t:s0 key=(null)

Running the CLI dspace database command gives me this result:
dspace databse test

Attempting to connect to database using these configurations:
- URL: jdbc:postgresql://localhost:5432/dspace
- Driver: org.postgresql.Driver
- Username: dspace
- Password: [hidden]
- Schema:

Testing connection...
Connected successfully!

Also when I run the command to connect to postgres, it runs fine as well:
As the dspace use I run the psql command, and get this:

psql (9.2.24)
Type "help" for help.

dspace=>

Run \l command and get this:

List of databases
Name | Owner | Encoding | Collate | Ctype | Access
privileges
-----------+----------+----------+------------+------------+-----------------------
dspace | dspace | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | LATIN1 | en_US | en_US |
template0 | postgres | LATIN1 | en_US | en_US |
=c/postgres +
| | | | |
postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(4 rows)

I'm still not able to get the xmlui running.

Thanks
Keith
Reply all
Reply to author
Forward
0 new messages