Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Error with Postgres connection #77

#1

HI,

I try to connect with JNDI to PostgreSQL database, but didn't succeed.

My environment:
-Windows 10/Oracle Linux
-JDK 17.04
-TOMCAT 10.1.16
-JRI 2.11.0

My configuration steps are. Could you help me what I done wrong or where is a configuration error:

  1. edited file with: %JRI_HOME%\JasperReportsIntegration\conf\application.properties

...
[datasource:pg_xy_db
type=jndi
name=pg_xy_db
...

  1. added pg jdbc driver: %TOMCAT_HOME%\lib\postgresql-42.7.3.jar

  2. edited file with: %TOMCAT_HOME%\webapps\jri\META-INF\context.xml

...
<Resource name="jdbc/pg_xy_db" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
maxActive="20"
initialSize="0"
minIdle="0"
maxIdle="8"
maxWait="10000"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="60000"
maxAge="600000"
testWhileIdle="true"
validationQuery="select user"
rollbackOnReturn="true"
url="jdbc:postgresql://localhost:5432/xy_db?currentSchema=xy_sch"
username="xy_usr"
password="xy_pwd"

...

  1. start tomcat

  2. run test db connection from URL http://localhost:8080/jri and get error page with following content:

HTTP Status 500 – Internal Server Error
Type Exception Report

Message Error while selecting user objects: ERROR: relation "dual" does not exist

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

Exception

java.lang.RuntimeException: Error while selecting user objects: ERROR: relation "dual" does not exist
Position: 352
de.oc.utils.Utils.throwRuntimeException(Utils.java:19)
de.oc.integration.jasper.webapp.Test.doGet(Test.java:131)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
Note The full stack trace of the root cause is available in the server logs.

Apache Tomcat/10.1.26

Thx

  • replies 1
  • views 147
  • likes 0
#2

Hi -

Below works fine for me when placed in tomcat/conf/context.xml (rather than jri/META-INF/context.xml)
I am using postgresql-42.7.4.jar, JRI 2.11.0, and JDK 8

<Resource name="jdbc/beedatabase" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" maxTotal="20" initialSize="0" minIdle="0" maxIdle="8" maxWaitMillis="10000" timeBetweenEvictionRunsMillis="30000" minEvictableIdleTimeMillis="60000" testWhileIdle="true" validationQuery="select user" maxAge="600000" rollbackOnReturn="true" url="jdbc:postgresql://localhost:5432/mydb" username="myuser" password="supersecert"/>