Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to remove ReadOnly flag from JDBC and JNDI Data Sources in JasperReports Server


    akonkin
    • Features: Data Sources, JasperReports Server Version: v7.2, v6.0 Product: JasperReports® Server

    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.


    User Feedback

    Recommended Comments

    I could apply that change on my server and help me for dismiss the window error .rather when show the report doesn't execute an update from my function postgre only excute the query select.

    Link to comment
    Share on other sites

    Hello, I did the steps described but it didn't work, when it says restart the server, what should I do? I have it installed with bitnami

    Kind regards

    image.thumb.png.cd1c8e6b0181cb8f75c6d8057ab92c95.png

    Link to comment
    Share on other sites

    Yes you need to restart JasperServer to apply the changes.
    Under opt/bitnami/apache-tomcat/bin you should have 2 scripts shutdown.sh and startup.sh to stop and restart it.

    Link to comment
    Share on other sites



    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 account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...