Home
Analytics
JNDI error handling
SmokesMom
I have created a jdbc datasource using jndi in birt 2.1. I would like to "fake out" the database url and strictly use the jndi connection. I then want to catch any error when trying to connect through jndi and display an alternate error page/message to the end user. I'm not sure how to do this. Do I do it in the BIRT report designer using some kind of javascript in a beforeOpen or afterOpen event? Do I need to do it in my application that runs and renders the report? If so, where would I catch that exception? Any help would be appreciated. I have searched eclipse and the Birt exchange and haven't been able to find anything like this as of yet.
Thank you,
Find more posts tagged with
Comments
berk123
You can add the datasource with db URL, jndi url, and remove the properties you don't want to show as follows:
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="My_Data Source" id="26">
<property name="odaJndiName">java:MyDataSource</property>
</oda-data-source>
</data-sources>
SmokesMom
Ok. Thank you. I did that in the xml. But, that still does not tell me how and where to catch the exception if it can not connect to the database with the jndi. I need to catch this error and then handle it gracefully. I tried putting a try/catch in my java application that calls the report engine, but it didn't work. Any help would be appreciated.
Jul 10, 2008 11:47:27 FATAL DatasourceConnectionProvider - Could not find datasource: jdbc/datasourc
e/PROD
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.datasource.PROD' Resolved jdbc.datasource
; remaining name 'PROD'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:897)
SmokesMom
Has any one had to do this before? I really need to find a solution soon.
Thanks for your time.
SmokesMom
Please, please, please help. I know very little about java and I am truly struggling with this.
This is the error I get...
Jul 25, 2008 11:23:40 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$DriverClassLoader refreshURLs
INFO: JDBCDriverManager: found JAR file drivers/ojdbc14.jar. URL=bundleentry://22/drivers/ojdbc14.jar
Jul 25, 2008 11:23:40 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$DriverClassLoader refreshURLs
INFO: JDBCDriverManager: found JAR file drivers/postgresql-8.0-310.jdbc3.jar. URL=bundleentry://22/drivers/postgresql-8.0-310.jdbc3.jar
Jul 25, 2008 11:23:42 AM org.eclipse.birt.report.data.oda.jdbc.JDBCException JDBCException
FINE: odajdbc.CannotGetConn
Jul 25, 2008 11:23:42 AM org.eclipse.birt.report.data.oda.jdbc.JDBCException logSQLException
FINE: SQL Exception #1
java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$WrappedDriver.connect(JDBCDriverManager.java:787)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:185)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:146)
at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:149)
at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java:111)
at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.open(OdaConnection.java:235)
at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:140)
at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSource.java:133)
at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java:121)
at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource(DataSourceRuntime.java:206)
at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryExecutor.java:259)
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:202)
at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:396)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute
stuff cut out
(PDFReportLayoutEngine.java:104)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:215)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:145)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(Unknown Source)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(Unknown Source)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(Unknown Source)
at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(Unknown Source)
at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(Unknown Source)
at com.chw.rpt.servlets.ChwBirtEngineServlet.__doGet(ChwBirtEngineServlet.java:118)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
stuff cut out
(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Jul 25, 2008 11:23:42 AM org.eclipse.birt.data.engine.odaconsumer.ConnectionManager openConnection
SEVERE: Cannot open connection.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Failed to get connection.
SQL error #1: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
;
java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:154)
at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java:111)
at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.open(OdaConnection.java:235)
at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:140)
at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSource.java:133)
at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java:121)
at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource(DataSourceRuntime.java:206)
at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryExecutor.java:259)
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:202)
at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:396)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:145)
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:134)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:125)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:119)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:210)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1658)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:62)
at org.eclipse.birt.report.engine.executor.DataItemExecutor.execute(DataItemExecutor.java:70)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:35)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:67)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:72)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:72)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:72)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:72)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:72)
stuff cut out
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6724)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$WrappedDriver.connect(JDBCDriverManager.java:787)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:185)
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:146)
at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:149)
... 58 more
Jul 25, 2008 11:23:42 AM org.eclipse.birt.report.engine.data.dte.DteDataEngine doExecuteQuery
SEVERE: Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc
Failed to get connection.
SQL error #1: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
DKath
Hi SmokesMom,<br />
<br />
as far as I can tell (I did quite a lot of research on this topic) BIRT isn't really JNDI-capable. To me the lately introduced JNDI-Feature seems more like a little hack than a real feature.<br />
<br />
I found this article (<a class='bbc_url' href='
http://birtworld.blogspot.com/2007/01/birt-connection-pooling-continued.html'>http://birtworld.blogspot.com/2007/01/birt-connection-pooling-continued.html</a>)
which describes how to put a datasource into report generation programatically. By this means you could lookup your JNDI datasource yourself and handle any exception. <br />
<br />
It's not quite what you would have expected, but it might be an approach to solve your problem.<br />
<br />
Regards,<br />
D
SmokesMom
Hey thanks for your reply DKath. I appreciate it.
I'll need to do some more looking, but maybe that is a place to start.