Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

JasperReportsIntegration connection test not working with JNDI #5

#1

I am using JasperReportsIntegration 2.4.0 with Tomcat 7 and Oracle- XE11gR2.

I am not able to run a basic connectivity test using the JNDI. The logs indicate -

org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Test] in context with path [/JasperReportsIntegration] threw exception
java.lang.NullPointerException
        at de.oc.integration.jasper.webapp.Test.doGet(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

The /usr/share/tomcat/webapps/JasperReportsIntegration/WEB-INF/conf/application.properties file has the following lines -

[datasource:jndi_test]
type=jndi
name=hr

And, the file /usr/share/tomcat/webapps/JasperReportsIntegration/META-INF/context.xml has the following content -

<Resource name="jdbc/jndi_test" auth="Container" type="javax.sql.DataSource"
              driverClassName="oracle.jdbc.OracleDriver"
              maxActive="20" maxIdle="10" maxWait="-1"
              initialSize="10" minIdle="3" validationQuery="select user from dual"
              testWhileIdle="true" testOnBorrow="true" timeBetweenEvictionRunsMillis="300000"
              numTestsPerEvictionRun="100" minEvictableIdleTimeMillis="10000"

              url="jdbc:oracle:thin:@127.0.0.1:1521:XE"
              username="hr"
              password="password"
              />
  • replies 11
  • views 4.2K
  • likes 0
#2

Hi,

since you are using an Oracle Connection, I would suggest you use the jdbc approach and not the jndi approach, at lot easier to configure:

#====================================================================
# JDBC datasource configuration
# http://www.orafaq.com/wiki/JDBC#Thin_driver
# type=jndi|jdbc
#====================================================================
[datasource:default]
type=jdbc
name=default
url=jdbc:oracle:thin:@127.0.0.1:1521:XE
username=my_oracle_user
password=my_oracle_user_pwd

Does that help?

Cheers,
~Dietmar.

#3

Hi @ajitabhpandey,

did the jdbc connection configuration work?
If so, please mark it as "answer" to indicate that the ticket is closed.

Thanks
~Dietmar.

daust added the waiting for reply from reporter label
#4
#5

Yes, that is what I have been using. The disadvantage here is I can not specify the number of connections min/max open for the database. As I mentioned in one of the other questions I posted, I think we are running out of database connections and I would like to use a pool of open connections which can be used by JasperReportsIntegration and hence looking at JNDI.

Hi @ajitabhpandey ,

I think you have been using version 2.5.x, there was a problem with the Oracle JDBC drivers. Thus, the connections didn't get cleaned up properly. For release 2.6 I have changed the jdbc connection to using the Oracle Universal Connection Pool (UCP). The connections get cleaned up properly now.

Currently, I have hardcoded 5 connections and 50 max. These are parallel running connections:
poolDataSource.setInitialPoolSize(5);
poolDataSource.setMinPoolSize(5);
poolDataSource.setMaxPoolSize(50);

I can make it configurable later on, but for now it should work well in most cases.

#7

Please give it a try and test with (pre-release) version 2.6.0.

#8

Not sure if same issue, but we add all of our JNDI entries to /tomcat/conf/context.xml
Adding to JasperReportsIntegration/META-INF/context.xml does not seem to pick up the JNDI for us.
When added to /tomcat/conf/context.xml it works fine for me.
Best,
David

#9

Hi @DavidGhedini,

please check the settings for the <Host parameter. https://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Standard_Implementation

You should at least have deployXML=true. If it is false (the default), it will not pick up the JNDI settings from META-INF/context.xml.

My test settings are:

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"
          deployXML="true" 
          copyXML="false">

I was playing with copyXML, too. If true, it will copy the context.xml file to $CATALINA_HOME/conf/Catalina/localhost/jri.xml (or whatever the name of the war-file is).

In 2.6.0 and 2.6.1 I omitted the initial context.xml file from the META-INF directory in the war file. In 2.6.2 it will be there.

Does that help?
Thanks
~Dietmar.

#10

Hi @daust -
For the current JRI Publisher release we'll stick with inserting PGSQL, MSSQL, and MySQL into /tomcat/conf/context.xml
I've updated our Release numbers to match your own (if that's OK).
When it changes in 2.6.2, we'll update the module accordingly. We have an editor for the /conf/context.xml file in the current release, so we will add an editor for /app.xml in next release as well.
Thanks again,
David

#11

Hi @DavidGhedini ,

sounds good.

Please make sure to test with the configuration copyXML="false">, because in release 2.6.2 the (empty) file jri.xml will be created. Make sure, it doesn't cause any issues, although I believe it won't.

Best,
~Dietmar.

#12

Hi @daust
I've tested with 2.6.2 and it works fine.
Best,
David