[SOLVED] HTTP Status 500 – Internal Server Error, fresh install, Debian 11+PostgreSQL

I’ve installed a new instanse of XWiki and PostgreSQL 14.
Used fresh installed OS.
xwiki-tomcat9-postgresql deb package was used.
APP and DB server are separated.
Instalation passed without errors, I’ve checked the connection to the DB from APP server by loggin under xwiki user from terminal - everything looks fine.

psql -U xwiki -h 10.40.63.231 -d postgres
Password for user xwiki:
psql (15.0 (Debian 15.0-1.pgdg110+1), server 14.5 (Debian 14.5-2.pgdg110+2))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type “help” for help.

postgres=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------±---------±---------±------------±------------±-----------±----------------±----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
xwiki | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =Tc/postgres +
| | | | | | | postgres=CTc/postgres+
| | | | | | | xwiki=C/postgres
(4 rows)

postgres=> \du
List of roles
Role name | Attributes | Member of
-----------±-----------------------------------------------------------±----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
xwiki | | {}

postgres=>

After install I updated the tomcat9 config:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
JAVA_OPTS=“-Djava.awt.headless=true -Xmx2048m”
JAVA_OPTS=“${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom”

But at the 50% of initialization I’ve got errors:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message Failed to execute the action with name [view]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Failed to execute the action with name [view]
com.xpn.xwiki.web.LegacyActionServlet.service(LegacyActionServlet.java:116)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122)
org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:61)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)

Root Cause

com.xpn.xwiki.XWikiException: Error number 11007 in 0: Failed to extract Entity Resource Reference from URL [http://10.40.22.248:8080/xwiki/bin/view/Main/]
com.xpn.xwiki.XWiki.initializeResourceFromURL(XWiki.java:1106)
com.xpn.xwiki.XWiki.getXWiki(XWiki.java:952)
com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:379)
com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:289)
com.xpn.xwiki.web.LegacyActionServlet.service(LegacyActionServlet.java:114)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122)
org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:61)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
… etc → look at the attachment
Error 500 XWiki.txt (42.9 KB)

In Catalina.out there are to lines at the beginig of initialisation:

[2022-10-16 05:55:18] [info] 2022-10-16 05:55:18,553 [XWiki initialization] ERROR c.x.x.s.DBCPConnectionProvider - Could not create a DBCP pool. There is an error in the Hibernate configuration file, please review it.
[2022-10-16 05:55:18] [info] java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user “xwiki”)

I tried to research the similar themes about “HTTP Status 500 – Internal Server Error”, but didn’t find appropriate solution.

I suppose that problem somewhere in connection to the PostgreSQL.
Pg_hba.conf:

TYPE DATABASE USER ADDRESS METHOD

“local” is for Unix domain socket connections only

local all all peer

IPv4 local connections:

host all all 127.0.0.1/32 scram-sha-256
host all all 10.40.22.0/24 md5
host all all 192.168.22.0/24 md5

IPv6 local connections:

host all all ::1/128 scram-sha-256

Allow replication connections from localhost, by a user with the

replication privilege.

local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256

Finaly tomcat9 process was killed by OOM killer after 1 hour of standby in this state:

● tomcat9.service - Apache Tomcat 9 Web Application Server
Loaded: loaded (/lib/systemd/system/tomcat9.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/tomcat9.service.d
└─xwiki-tomcat9-systemd.conf
Active: failed (Result: oom-kill) since Sun 2022-10-16 13:33:53 EDT; 4h 40min ago
Docs: Apache Tomcat 9 (9.0.89) - Documentation Index
Process: 663 ExecStartPre=/usr/libexec/tomcat9/tomcat-update-policy.sh (code=exited, status=0/SUCCESS)
Process: 671 ExecStart=/bin/sh /usr/libexec/tomcat9/tomcat-start.sh (code=killed, signal=KILL)
Main PID: 671 (code=killed, signal=KILL)
CPU: 34min 22.004s

Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: at org.postgresql.Driver.connect(Driver.java:291)
Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:52)
Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:374)
Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:106)
Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:649)
Oct 16 12:38:28 MGD-XWIKI-APP tomcat9[671]: … 47 common frames omitted
Oct 16 13:33:53 MGD-XWIKI-APP systemd[1]: tomcat9.service: A process of this unit has been killed by the OOM killer.
Oct 16 13:33:53 MGD-XWIKI-APP systemd[1]: tomcat9.service: Main process exited, code=killed, status=9/KILL
Oct 16 13:33:53 MGD-XWIKI-APP systemd[1]: tomcat9.service: Failed with result ‘oom-kill’.
Oct 16 13:33:53 MGD-XWIKI-APP systemd[1]: tomcat9.service: Consumed 34min 22.004s CPU time.

Any ideas, what shuold I check or fix in that case?

PS: great thanks in advance.
hibernate.cfg.xml.txt (16.1 KB)
pg_hba.conf.txt (997 Bytes)

Hi,

Http Error 500 is a generic error message saying there’s a problem on the server, so it won’t help you to search for that for finding a solution.
Now according to your catalina.out logs, the error is pretty explicit:

[2022-10-16 05:55:18] [info] java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user “xwiki”)

So sounds like you provided a wrong password for connecting to your DB in your hibernate.cfg.xml configuration.

Hello Surli,
yes, you are right.

The problem was in the connection string that I have inputed at wizard dialog during the install - I didn;t input the connection port (5432) for pSQL cause it was a default value. It didn’t affect on the install process but lead to the connection error during the XWiki initialization.

It was solved by the manual indicating of the port in a connection string in the hibernate.cfg.xml
‘<‘property name=“hibernate.connection.url”’>‘jdbc:postgresql://10.40.22.231:5432/xwiki’<’/property’>’

Perhaps this case would be a useful addon to the instruction:

Not very used to the postgres package but what you describe is very strange as the template file we provide (and then filled with dbconfig values) contains

<property name="hibernate.connection.url">jdbc:postgresql:_DBC_DBNAME_</property>

so you should ends up with something like

<property name="hibernate.connection.url">jdbc:postgresql:xwiki</property>

Hello tmortagne,

I’ve tryed your format for the connection line:

jdbc:postgresql://10.40.22.231:xwiki

It leads to the error in the tomcat9.service status:

JDBC URL must contain a / at the end of the host or port: jdbc:postgresql://10.40.22.231:xwiki
2022-10-18 00:32:12,447 [XWiki initialization] ERROR c.x.x.s.DBCPConnectionProvider - Could not create a DBCP pool. There is an error in the Hibernate configuration file, please review it.

Connection string that works:

jdbc:postgresql://10.40.22.231:5432/xwiki

PS: just for reminder - in this case we deal with separate instances of app and db servers.

That’s not what I indicated.

That’s not really what the xwiki-tomcat9-pgsql package is designed for, since it install a postgresql server as dependency. Your use case would usually be covered by xwiki-tomcat9-common in which you provide your own hibernate configuration (the postgresql jdbc connector is provided in xwiki-common).

Ok, I see the difference in the packages description now.
But it was not clear from the first reading of the Installation instruction:

Using PostgreSQL

It’s as simple as the MySQL installation, you only need to choose the right virtual package.

sudo apt-get install xwiki-tomcat9-pgsql

After you’ve made sure to update the memory settings (see below), you can now point your favorite browser to the following URL to use your wiki: http://localhost:8080/xwiki

PostgreSQL is slightly different than MySQL in the handling of databases and in the manual configuration, but everything should work on the first try.

Especially in the case when the install wizard successfully creates data base and user at an external host.

Anyway, the problem was solved, thank you for involving.

It was actually not the case before AFAIK, it seems dbconfig added remote postgres server support (which is not the case for MySQL/MariaDB for example unless it changed very recently too).