Problem Statement:
If you try to run a report that executes insert/delete/update operators you may get the error that I quote below:
ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
JasperReports Server creates read-only connections by default for JDBC/JNDI data sources to protect your data.
Also there are some JDBC drivers, like for Snowflake, that cannot use read only connections. There will be failures like the following when you test a JDBC connection:
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Could not create a validated object, cause: null atorg.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:114) atcom.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcDataSourceService.testConnection(JdbcDataSourceService.java:85)[/code]
To address this, you can change the configuration so that JasperReports Server no longer creates read-only connections.
JDBC data sources in JasperReports Server use DBCP connection pools and defaultReadOnly is set at pool level.
JdbcReportDataSourceServiceFactory is configured via Spring and you can add a property to set defaultReadOnly to false in the applicationContext.xml file under deployed JasperReports Server WEB-INF directory.
From:
<bean id="jdbcDataSourceServiceFactory" class="com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory"> <property name="pooledJdbcDataSourceFactory"> <ref bean="dbcpJdbcDataSourceFactory"/> </property> <property name="poolTimeout" value="900"/></bean>[/code]
to:
<bean id="jdbcDataSourceServiceFactory" class="com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory"> <property name="pooledJdbcDataSourceFactory"> <ref bean="dbcpJdbcDataSourceFactory"/> </property> <property name="poolTimeout" value="900"/> <property name="defaultReadOnly" value="false"/></bean>[/code]
For JNDI connections (which we warmly recommend), you would have to refer to the application server documentation.
For Tomcat, defaultReadOnly="false" has to be added to the Resource entry in conf/Catalina/<host>/jasperserver-pro.xml
The Application server should be restarted to apply the adjustment that has been done.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now