Crystal Reports XI & Sun One 6.1 Web Server - Error Finding JNDI

Discussions

Web tier: servlets, JSP, Web frameworks: Crystal Reports XI & Sun One 6.1 Web Server - Error Finding JNDI

  1. I am trying to create a Crystal Reports XI report in a JSP using Sun One 6.1 Web server sp 5.

    At this point I am getting the error “Error finding JNDI name” on Sun One
    The application will run on Netbeans/Tomcat

    I have done the following:
    I edited CRConfig.xml
    <?xml version="1.0" encoding="utf-8"?>
    <CrystalReportEngine-configuration>

    <DataDriverCommon>
    <JavaDir>C:\Program Files\Java\j2re1.4.2_10\bin</JavaDir>
        <Classpath>C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;…</Classpath>

    <JDBC>
    <CacheRowSetSize>100</CacheRowSetSize>
    <JDBCURL>jdbc:oracle:thin:@10.10.10.10:1521:dev</JDBCURL>
    <JDBCClassName>oracle.jdbc.driver.OracleDriver</JDBCClassName>
    <JDBCUserName>lab_ro</JDBCUserName>
    <JNDIURL></JNDIURL>

    </JDBC>

    I created a report using JDBC (JNDI) connection and have the JNDI Connection set to the name of DATA.

    The report works just fine in Crystal Reports.

    Then in Netbeans I created an application and it runs in the Tomcat part of Netbeans
    In context.xml I have:
    <Context path="/BOEnterpriseTest3">
         <Resource name="jdbc/dev" auth="Container" type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@10.10.10.10:1521:dev"
        username="theuserid" password="thepassword" maxActive="20" maxIdle="10" maxWait="-1"/>
    </Context>

    In web.xml I have
    <web-app>
        <context-param>
            <param-name>crystal_image_uri</param-name>
            <param-value>crystalreportviewers11</param-value>
        </context-param>

    <taglib>
            <taglib-uri>/crystal-tags-reportviewer.tld</taglib-uri>
            <taglib-location>/WEB-INF/crystal-tags-reportviewer.tld</taglib-location>
        </taglib>
        <resource-ref>
            <description>jdbc:oracle:thin:@10.10.10.10:1521:dev</description>
            <res-ref-name>jdbc/dev10g</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Application</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
        <resource-ref>
            <description>jdbc:oracle:thin:@10.10.10.10:1521:dev</description>
            <res-ref-name>Data</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Application</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
    </web-app>

    in web-inf\sun-web.xml I have
    <sun-web-app>
        <resource-ref>
    <res-ref-name>jdbc/dev10g</res-ref-name>
    <jndi-name>Data</jndi-name>
    </resource-ref>
    </sun-web-app>

    I have copied all of Common Files\Business Objects\3.0\java\lib and Common Files\Business Objects\3.0\java\lib\external to the lib folder

    I have copied crystalreportviewers11 to the root of my web application

    I have tried to load the JNDI information and display the report
    <%@page pageEncoding="UTF-8"
            import="com.crystaldecisions.reports.reportengineinterface.*,
                    com.crystaldecisions.report.web.viewer.*,
                    javax.naming.*,
                    javax.sql.*,
                    java.sql.*"%>

    <%
    InitialContext initContext = new InitialContext();
    DataSource source = (DataSource) initContext.lookup("java:comp/env/jdbc/dev10g");
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
     
    try{
    // Look up our data source
      DataSource ds = (DataSource)initCtx.lookup("Data");
      out.println("found ds under jdbc/Data");
     
    }
    catch ( NamingException e ){
    // Look up our data source
      DataSource ds = (DataSource) initContext.lookup("java:comp/env/jdbc/dev10g");
      
      initCtx.bind("Data", ds);
     out.println("found ds under java:com/env:jdbc/Data - bound into root initial context for Crystal to find");
    }
    %>

    <%
    //Use the relative path to the report; the physical or full qualified URL cannot be used.
    String reportName = "useridincluded.rpt";
       
    //Database username and password
    String userName = "theuserid";
    String password = "thepassword";

    //check to see if the Report Source Session Variable already exist
    Object reportSource = session.getAttribute("Report1");

    // Create a new ConnectionInfos and ConnectionInfo object
    com.crystaldecisions.sdk.occa.report.data.ConnectionInfos connectionInfos = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfos();
    com.crystaldecisions.sdk.occa.report.data.ConnectionInfo connectionInfo = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfo();

    //Set username and password for the report's database
    connectionInfo.setUserName(userName);
    connectionInfo.setPassword(password);

    //Add object to collection
    connectionInfos.add(connectionInfo);

    //---------- Create a ReportClientDocument -------------
        com.crystaldecisions.reports.sdk.ReportClientDocument reportClientDocument = new com.crystaldecisions.reports.sdk.ReportClientDocument();
        
        //---------- Set the path to the location of the report soruce -------------

        //Open report.
        reportClientDocument.open(reportName, 0);

        //Get the report source
        reportSource = reportClientDocument.getReportSource();

    //---------- Create the viewer and render the report -------------

    //create the CrystalReportViewer object
    com.crystaldecisions.report.web.viewer.CrystalReportViewer crystalReportViewer = new com.crystaldecisions.report.web.viewer.CrystalReportViewer();

    //set the reportsource property of the viewer
    crystalReportViewer.setReportSource(reportSource);

    //set the DB logon into the viewer
    crystalReportViewer.setDatabaseLogonInfos(connectionInfos);

    //set viewer attributes
    crystalReportViewer.setOwnPage(true);
    crystalReportViewer.setOwnForm(true);
    crystalReportViewer.refresh();
      
    //set the CrystalReportViewer print mode
    //crystalReportViewer.setPrintMode(com.crystaldecisions.report.web.viewer.CrPrintMode.ACTIVEX);
    crystalReportViewer.setPrintMode(com.crystaldecisions.report.web.viewer.CrPrintMode.PDF);

    //process the report
    crystalReportViewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

    %>

    On the Sun One Web server
    On the Java Tab
    JDBC Connection Pools
    Pool Name = dev10g
    Class name = oracle.jdbc.pool.OracleDataSource
    User id = theuserid
    url = 10.10.10.10
    password=thepassword

    JDBC Resources
    JNDI Name=dev10g
    Pool = dev10g

    I get the error finding JNDI name – how do I tell Sun One where the JNDI is to make Crystal Reports work?
  2. Hi;

    If you don't get this working please take a look at Windward Reports as it is very easy to use.

    thanks - dave