Building an application using BO SDK

user2517028 picture user2517028 · Mar 27, 2014 · Viewed 7.2k times · Source

I think my problem is simple, but I'm not really experienced in this domain.
I'm trying to build a JSP manually without any environment, using TOMCAT. So I used this structure for my page:

my-webapp
|-- WEB-INF
|   |-- lib
|   |   |-- ajar.jar
|   |   |-- bjar.jar
|   |   `-- zjar.jar
|-- b.swf
`-- index.jsp

The libraries in the WEB-INF/lib are copied from BusinessObjects location java/lib, and the code in the JSP page:

<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.occa.security.ILogonTokenMgr"%>

<%! String defaultToken =null; %>
<%
    try
    {
        String systemName = "XXXXX";
        String userName = "XXXXX";
        String password = "XXXXXX";
        String authType = "LDAP";

        IEnterpriseSession enterpriseSession=null;
        ISessionMgr enterpriseSessionMgr = CrystalEnterprise.getSessionMgr();
        enterpriseSession = enterpriseSessionMgr.logon(userName, password, systemName, authType);
        ILogonTokenMgr logonTokenMgr = enterpriseSession.getLogonTokenMgr();
        defaultToken = logonTokenMgr.getDefaultToken();
    }
    catch(Exception e)
    {
        out.println(e);
    }
%>

// THEN THE HTML PAGE WITH defaultToken assigned

When running the page, I get this error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 27

24:  
25: IEnterpriseSession enterpriseSession=null;
26:  
27: ISessionMgr enterpriseSessionMgr = CrystalEnterprise.getSessionMgr();
28:  
29: enterpriseSession = enterpriseSessionMgr.logon(userName, password, systemName, authType);
30: 


root cause

    java.lang.NoClassDefFoundError: com/businessobjects/sdk/aspect/LoggingContextAspect
        com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr(CrystalEnterprise.java:1)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:723)


The purpose of the page is to have a Xcelsius dashboard with hard-coded credentials, so that the users don't have to have accounts on the platform to access the report.

Answer

IvanJijon picture IvanJijon · Mar 28, 2014

I strongly recommend you to read this post, it's excellent : "Getting started with BusinessObjects java SDK". I started from zero, and it was really helpful.

Be careful, you need to copy your .jar files to a directory where Tomcat can find them, a directory specified int the classpath. I just copied them to the Tomcat's "/lib" folder, not the best idea but it worked.

Here's how to properly add a directory to Tomcat's classpath.

May I suggest you to use eclipse?

In eclipse I did two things for my application to work :

  • Create a java library with all the BO SDK .jar files and add this library to my project's Java build path, so I can use the SDK when I develop
  • When you deploy the application in Tomcat, copy the .jar files in the classpath of the Tomcat server so it can find the SDK Classes you are using

I hope I have been helpful and sorry for my English.