Wednesday, August 19, 2015

BIRT rptlibrary using JNDI datasource

Today it is a judgement day for me as I have to face yet another issue in my BIRT viewer implementation. The problem was related to a wide-spread data sources in each and every report I have in my application. Now the challenge was to fix this blunder in more effective and efficient fashion.

The Problem:

Our project was using BIRT viewer to preview actual report before it gets exported to PDF or any other format. We have several number of reports which were using their own datasources. Difficulty was while deployment of solution on server. We have to change all datasources by modifying each .rptdesign file.

Solution:

Finally we have start thinking about the solution and arrived at a stepping stone to create an .rptlibrary file and add following properties under your
 <oda-data-source></oda-data-source>
tag.

<property name="odaDriverClass">{JDBC DRIVER NAME}</property>
            <property name="odaURL">{JDBC URL}</property>
            <property name="odaUser">{JDBC USER}</property>
            <encrypted-property name="odaPassword" encryptionID="base64">{JDBC PASSWORD}</encrypted-property>

This approach really did the trick and we finally took a sigh of relief from all difficulties we faced while deploying application.

After spending some lenient days, this BIRT deployment again started throttling us. This time it was more of a configuration issue. We had our datasource declared at several places and we had to bring everything at a single place. Finally we came up with JNDI approach and used JNDI data source declared in context.xml file of $TOMCAT_HOME/conf.context.xml in BIRT .rptlibrary file

This is how you would do it

$TOMCAT_HOME/conf/context.xml

<Resource auth="Container" driverClassName="{DIRVER NAME}" maxActive="20" maxIdle="2" maxWait="-1"
 name="/{DS NAME}" password="{DB PASSWORD}" removeAbandoned="true" removeAbandonedTimeout="20"
 type="javax.sql.DataSource" url="{JDBC URL}" username="{DB USER NAME}"
 validationQuery="select true;"/>

.rptlibrary file

add following line in your <oda-data-source></oda-data-source> tag

 <property name="odaJndiName">java:comp/env/{DS NAME}</property>
  

No comments:

Post a Comment