Skip to Content

JSP report viewer failing on some reports

We recently migrated to BOXIr2 from CE10 and when we migrated our reports we noticed that many of our older reports that were created almost 10 years ago are failing with the following error:

ApplicationException: message = java.lang.NoSuchMethodError: com.crystaldecisions.Utilities.Environment: method hasJava2D()Z not found class = unknown method = unknown id = unknown

We can run these reports from Crystal Reports XI with no problems. We only get this error when running report from the report viewer jsp.

Has anyone seen this error before?

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Oct 14, 2008 at 07:04 PM

    This is the code we use to build the custom viewer:

    /**

    Class to build a customer Crystal reports viewer

    @originalAuthor xxxxx

    @see ReportTag

    @maintenanceLog (4/29/2005 02:00:00 PM) : Class created

    */

    public class Viewer {

    public static CrystalReportViewer getViewer(IEnterpriseSession enterpriseSession, int reportId) throws ApplicationException {

    CrystalReportViewer viewer = new CrystalReportViewer();

    try {

    viewer.setEnterpriseLogon(enterpriseSession);

    IReportSourceFactory factoryPS = (IReportSourceFactory) enterpriseSession.getService("PSReportFactory");

    Object reportSource = factoryPS.openReportSource(reportId,Locale.ENGLISH);

    viewer.setReportSource(reportSource);

    viewer.setDisplayPage(true);

    viewer.setDisplayGroupTree(true);

    viewer.setDisplayToolbar(true);

    viewer.setOwnPage(true);

    } catch (Exception e) {

    ApplicationException ae = new ApplicationException();

    throw ae;

    }

    return viewer;

    }

    }

    Add comment
    10|10000 characters needed characters exceeded

    • I'd recommend the following:

      1. Delete all the jars from your application.

      2. Re-copy the XI Release 2 jars int your application.

      3. Ensure that MetafileRenderer.jar is included, and that ReportViewer.jar is not.

      This ensures that (1) you're not mixing CE10 and XI Release 2 jars, and (2) the required class and method the exception is complaining about is there.

      I strongly recommend steps 1 and 2.

      Sincerely,

      Ted Ueda

  • avatar image
    Former Member
    Oct 14, 2008 at 03:58 PM

    Hello Doug,

    Which viewer are you using to view your code ? Can you specify the code snippet that your are using to view the report ?

    Thanks,

    Chinmay

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2008 at 06:55 PM

    Chinmay,

    We are using a custom report viewer we built using the Business Objects JAVA SDK.

    Here is the JAVA code behind the custom JSP tag:

    public class ReportViewerTag extends BodyTagSupport {

    private static String name = ReportViewerTag.class.getName();

    private static Logger logger = Logger.getLogger(name);

    private String appName;

    private String dbType;

    private String refreshEnabled;

    /**

    Launch a Crystal Reports viewer for a specified report name and optionally set login and parameter information

    @param none

    @return int standard end tag flag

    @maintenanceLog (7/11/2005 12:30:00 PM) :Method created

    */

    public int doStartTag() throws JspException {

    String method = "doStartTag()";

    ConnectionInfo connInfo = null;

    // obtain Crystal connection from connection tag and then find report id

    // from Crystal server by report name

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

    HttpSession session = pageContext.getSession();

    // obtain any parameters which control the functioning of the viewer

    if (refreshEnabled == null) {

    refreshEnabled = "true";

    }

    logger.debug("refreshEnabled = "+refreshEnabled);

    // retrieve Crystal Enterprise connection info

    connInfo = (ConnectionInfo) session.getAttribute(Constants.CONNECTION_INFO);

    IEnterpriseSession enterpriseSession = connInfo.getEnterpriseSession();

    CrystalReportViewer viewer = null;

    if (logger.isDebugEnabled()) {

    logger.debug("================= Request Parameters ================");

    HttpUtility.listParameters(request);

    logger.debug("================= Session Attributes ================");

    HttpUtility.listSessionAttributes(session);

    logger.debug("================= End Request/Session Parameters ================");

    }

    // check to see if reportId has already been found from server - this

    // can occur if viewer is redisplayed for parameter entry

    int reportId = 0;

    ArrayList parmList = new ArrayList();

    String reportIdString = request.getParameter(Constants.REPORT_ID);

    if (reportIdString != null) {

    reportId = Integer.parseInt(reportIdString);

    }

    // if report Id not yet determined, retrieve passed parameters

    // else retrieve parameters from session

    if (reportIdString == null) {

    String reportName = request.getParameter(Constants.REPORT_NAME);

    logger.debug("report name = "+reportName);

    try {

    logger.debug("before getReportObject, connInfo = "+connInfo);

    IInfoObject reportObject = ReportQuery.getReportObject(connInfo.getIStore(), reportName);

    logger.debug("before session.setAttribute()");

    session.setAttribute("REPORT_OBJECT", reportObject);

    // reportId = ReportQuery.getReportId(connInfo.getIStore(), reportName);

    logger.debug("report id = "+reportId);

    } catch (Exception e) {

    logger.error(e.toString());

    JspException je = new JspException(e.toString());

    throw je;

    }

    // build parameter list from entered parameters on first display of viewer

    Enumeration parmEnum = pageContext.getRequest().getParameterNames();

    while (parmEnum.hasMoreElements()) {

    String parmName = (String) parmEnum.nextElement();

    String[] parmValue = (String[]) request.getParameterValues(parmName);

    ParameterBean parmBean = new ParameterBean(parmName, parmValue);

    parmList.add(parmBean);

    }

    session.setAttribute(Constants.PARM_LIST, parmList);

    } else {

    // rebuild parameter list from page attributes

    parmList = (ArrayList) session.getAttribute(Constants.PARM_LIST);

    // retrieve viewer from session

    viewer = (CrystalReportViewer) session.getAttribute(Constants.REPORT_VIEWER);

    }

    // print list of all parameters specified on launch of viewer page

    if (logger.isDebugEnabled()) {

    ReportUtility.printParameterList(parmList);

    }

    // if report has already been displayed, obtain viewer from session instead

    // of creating a new one

    if (ReportUtility.isReportComplete(request)) {

    logger.debug("report already completed - processing report control");

    // restore the current Crystal Enterprise session into the viewer

    // NOTE: Crystal Enterprise sessions are recreated (logon, logoff) for

    // each display of the viewer to release connections as freqeuently

    // as possible

    viewer.setEnterpriseLogon(enterpriseSession);

    if (logger.isDebugEnabled()) {

    ReportUtility.printViewerInfo(viewer);

    }

    try {

    logger.debug("processing HTTP request, request: "+request.toString());

    logger.debug("processing HTTP request, response: "+response.toString());

    logger.debug("processing HTTP request, pageContext: "+pageContext.toString());

    logger.debug("processing HTTP request, servletContext: "+pageContext.getServletContext().toString());

    viewer.processHttpRequest(request, response, pageContext.getServletContext(), null);

    return EVAL_BODY_INCLUDE;

    } catch (Exception e) {

    logger.error("Error redisplaying viewer: " + e.getMessage());

    }

    // catch all return

    return EVAL_BODY_INCLUDE;

    }

    // new request - create viewer, set attributes and place in session

    if (reportIdString == null) {

    try {

    // Initialize the viewer.

    viewer = new CrystalReportViewer();

    viewer.setEnterpriseLogon(enterpriseSession);

    // obtain a report source from Crystal Enterprise for the viewer

    IReportAppFactory rptAppFactory = ReportUtility.getReportSource(enterpriseSession);

    IInfoObject reportObject = (IInfoObject) session.getAttribute("REPORT_OBJECT");

    ReportClientDocument clientDoc = rptAppFactory.openDocument(reportObject, 0, Locale.ENGLISH);

    viewer.setReportSource(clientDoc.getReportSource());

    session.setAttribute("ReportSource", clientDoc.getReportSource());

    // IReportSource reportSource = ReportUtility.getReportSource(enterpriseSession, reportId);

    // viewer.setReportSource(reportSource);

    // session.setAttribute("ReportSource", reportSource);

    // set display settings for the viewer

    viewer.setDisplayPage(true);

    viewer.setDisplayGroupTree(true);

    viewer.setDisplayToolbar(true);

    viewer.setOwnPage(true);

    viewer.setHasRefreshButton(Boolean.valueOf(refreshEnabled).booleanValue());

    logger.debug("viewer - refreshButton="+viewer.hasRefreshButton());

    viewer.setDisplayGroupTree(false);

    viewer.setName("Some Report");

    ConnectionInfos connInfos = new ConnectionInfos();

    com.crystaldecisions.sdk.occa.report.data.ConnectionInfo reportConnInfo = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfo();

    // set database user id and password of report from user id and password in session object

    String dbUser = (String) session.getAttribute(Constants.REPORT_DB_USER);

    if (dbUser != null) {

    String dbPassword = (String) session.getAttribute(Constants.REPORT_DB_PASSWORD);

    reportConnInfo.setUserName(dbUser);

    reportConnInfo.setPassword(dbPassword);

    connInfos.addElement(reportConnInfo);

    viewer.setDatabaseLogonInfos(connInfos);

    }

    // set any report parameters from input parameters

    Fields parmFields = viewer.getParameterFields();

    if (logger.isDebugEnabled()) {

    logger.debug("Prior to setting parameters (new viewer)");

    ReportUtility.listParameters(parmFields);

    logger.debug("Entered parameters -->");

    ReportUtility.printParameterList(parmList);

    }

    // update the parameters on the viewer based on whether prompt

    // parameters were entered

    // if no prompt parameters were entered, update any report parameters that match

    // the name of incoming parameters

    String prompt0 = (String) request.getParameter("prompt0");

    if (prompt0 == null) {

    logger.debug("no prompt0 entered - do by name");

    ReportUtility.setViewerParametersByName(parmFields, parmList);

    } else {

    logger.debug("prompt0 entered - do by prompt#'s");

    ReportUtility.setViewerParameters(parmFields, parmList);

    }

    logger.debug("after checking for prompt0");

    if (logger.isDebugEnabled()) {

    logger.debug("After setting parameters (new viewer)");

    ReportUtility.listParameters(parmFields);

    }

    // determine if application login to database is to be performed

    // (set login info on viewer)

    if (this.appName == null) {

    } else {

    ConnectionInfos dbInfo = new ConnectionInfos();

    com.crystaldecisions.sdk.occa.report.data.ConnectionInfo dbConn = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfo();

    try {

    HMApplicationConfig hmac = HMApplicationConfigFactory.create(appName);

    logger.debug("Application Name/Db type: "appName"/"+dbType);

    String securityFile = hmac.getHMEnvironment().getProperty(dbType+"_SECURITY_FILENAME");

    logger.debug("Security File Name: "+securityFile);

    HMSecurityFile file = new HMSecurityFile(securityFile);

    dbConn.setUserName(file.getLogonId());

    dbConn.setPassword(file.getPassword());

    dbInfo.add(dbConn);

    } catch (Exception e) {

    logger.error("Exception when setting database login info on viewer: "+e.toString());

    }

    viewer.setDatabaseLogonInfos(dbInfo);

    }

    // update parameters for report through the viewer

    viewer.setParameterFields(parmFields);

    String currentURI = request.getRequestURI();

    int parmMarkerPos = currentURI.indexOf("?");

    if (parmMarkerPos > -1) {

    viewer.setURI(request.getRequestURI() + "&ReportID=" + reportId);

    } else {

    viewer.setURI(request.getRequestURI() + "?ReportID=" + reportId);

    }

    // save viewer in session for subsequent user request on the viewer

    session.setAttribute(Constants.REPORT_VIEWER, viewer);

    // Destroy the viewer.

    // viewer.dispose();

    } catch (Exception e) {

    e.printStackTrace();

    logger.error("Error: " + e.getMessage());

    }

    }

    // Make the viewer render the page - default redirect to render page

    try {

    viewer.processHttpRequest(request, response, pageContext.getServletContext(), null);

    } catch (Exception e) {

    logger.error("Exception displaying viewer: "+e.toString());

    JspException je = new JspException(e.toString());

    throw je;

    }

    return EVAL_BODY_INCLUDE;

    }

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 15, 2008 at 02:29 PM

    I think I found my problem.

    With my migration I replaced all the CE10 jars from my Websphere app server classpath with all the BOXI jars.

    With the CE10 jars the MetafileRenderer.jar had the com.crystaldecisions.Utilities.Environment class and in this class was the hasJava2D()Z method. In the new BOXI jars this same class seems to appear in two jars. The MetafileRenderer.jar and the ReportViewer.jar although neither has the method hasJava2D()Z in it.

    Does anyone know why this isn't included with the BOXI jars and is there any way I can get my reports to work?

    Do I have to recreate the reports in Crystal Reports XI?

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 17, 2008 at 04:01 PM

    Ted,

    you were correct. The MetafileRenderer.jar was missing the method. The only way I'm able to get this to work is to replace the BOXI MetafileRenderer.jar with the older CE10 version.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded