0
votes

BIRT report can be generated using hard coded Jdbc connections. But I had to generate 20+ reports. But jdbc url and credentials has to be changed in all reports when it's moved to production server which bit cumbersome.

Hence I thought to keep everything in one single place using JNDI data source option. If JNDI data source is created, then container such as Tomcat can manage connection pool etc. I did following steps in order to do that, but it always returning error as "jdbc url is null".

  1. Created JNDI data source in bonita.xml

<Resource name="ds/businessdb" auth="Container" type="javax.sql.DataSource" maxActive="5" maxIdle="-1" maxWait="10000" username="root" password="password" driverClassName="com.mysql.cj.jdbc.Driver" url="jdbc:mysql://<ip>:3306/db"/>

  1. Added entry in birt web application's web.xml <resource-ref> <description>Resource reference to a factory forjava.sql.Connection</description> <res-ref-name>ds/businessdb</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>

  2. Then in the BIRT report design I used the JNDI url as

    java:comp/env/ds/businessdb

It returns as jdbc url is null.

1

1 Answers

0
votes

Afaik, for Tomcat datasource, you need

  1. entry in tomcat/server.xml
    <Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" ...

  2. entry in tomcat/context.xml
    <ResourceLink type="javax.sql.DataSource" name=...

  3. make sure that your database driver JAR is available for server on runtime.

(I don't know what is bonita.xml)

You could also check that your Tomcat datasource is configured correctly by writing a mini application doing some request to DB and running it on your server.