If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Cognos SDk windows to linux migration error

Started by karthik12345, 05 Aug 2016 08:01:29 AM

Previous topic - Next topic

karthik12345

Hi all,
I am new for Cognos sdk, recently I got a requirement to migrate Cognos sdk from windows environment to Linux environment, in windows environment we used Cognos 8 sdk version and now we have installed Cognos 10.2.2 in Linux.
I need to migrate old .bat files to .sh files. I created sample java file in Linux server and I am trying to run this java file by using .sh file, the class file got created and if I run the class file I am getting below error
-bash-4.1$ java SDKExample

Exception in thread "main" java.lang.NoClassDefFoundError: com/cognos/developer/schemas/bibus/_3/ContentManagerService_ServiceLocator
        at SDKExample.connectToCognos(SDKExample.java:40)
        at SDKExample.main(SDKExample.java:26)
Caused by: java.lang.ClassNotFoundException: com.cognos.developer.schemas.bibus._3.ContentManagerService_ServiceLocator
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
below are the .sh file and java file which I am using

.sh file:

#!/bin/sh
#
#  Licensed Materials - Property of IBM

#  IBM Cognos Products: DOCS

#  (C) Copyright IBM Corp. 2005, 2010

#  US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
#  IBM Corp.
#
#  Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
#  Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
#
# Build the Java samples.

# REMOVE this when you edit this file.
echo You MUST edit this file before you can compile this application.


# *  *  *  *  *  *  *  *
# CHANGE the following environment variables to point to the
# Java Development Kit and IBM Cognos on your system.
# *  *  *  *  *  *  *  *

if [ "$CRN_HOME" = "" ] ; then
        CRN_HOME=/usr/cognos/cognos10
fi
if [ "$JAVA_HOME" = "" ] ; then
        JAVA_HOME=/c/j2sdk6
fi
JAVA_HOME=/usr/java/jdk1.7.0_80

echo "JAVE_HOME=[$JAVA_HOME]\tCRN_HOME=[$CRN_HOME]"
JAR_HOME="$JAVA_HOME/lib:$CRN_HOME/sdk/java/lib"
#JAVA_HOME=/usr/java/jdk1.7.0_80
JAVAC=$JAVA_HOME/bin/javac

# Build the CLASSPATH required to build the Java samples

CLASSPATH=$JAVA_HOME/lib/tools.jar:/applications/datawarehouse/cognos/cognos10/sdk/cms_samples/java/common_class/com/cognos/developer/schemas/bibus/_3
for jar in activation axis axisCognosClient commons-discovery-0.2 commons-logging-1.1 commons-logging-adapters-1.1 \
   commons-logging-api-1.1 dom4j-1.6.1 jaxen-1.1.1 jaxrpc mail saaj wsdl4j-1.5.1; do
  CLASSPATH="$CLASSPATH:$JAR_HOME/$jar.jar"
done
CLASSPATH="$CLASSPATH:../Common:../Security:../ReportParams:../HandlersCS:../ReportSpec:../ViewCMReports:../ViewCMPackages:../ExecReports:../runreport:../Scheduler:../ContentStoreExplorer"

echo "CLASSPATH=[$CLASSPATH]"

# Compile

$JAVAC -classpath "$CLASSPATH" SDKExample.java


SDKExample.java:

import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axis.client.Stub;
import org.apache.axis.message.SOAPHeaderElement;
import com.cognos.developer.schemas.bibus._3.BaseClass;
import com.cognos.developer.schemas.bibus._3.BiBusHeader;
import com.cognos.developer.schemas.bibus._3.ContentManagerService_PortType;
import com.cognos.developer.schemas.bibus._3.ContentManagerService_ServiceLocator;
import com.cognos.developer.schemas.bibus._3.PropEnum;
import com.cognos.developer.schemas.bibus._3.QueryOptions;
import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
import com.cognos.developer.schemas.bibus._3.Sort;
import com.cognos.developer.schemas.bibus._3.XmlEncodedXML;

public class SDKExample {
private static String dispatcherURL = "http://localhost:9300/p2pd/servlet/dispatch";
private static String nameSpaceID = "";
private static String userName = "";
private static String password = "";
private ContentManagerService_PortType cmService=null;

public static void main(String args[]) {
   SDKExample mainClass = new SDKExample(); // instantiate the class

   // Step 1: Connect to the Cognos services
   mainClass.connectToCognos (dispatcherURL);

   // Step 2: Logon to Cognos
   mainClass.logonToCognos(nameSpaceID, userName, password);

   // Step 3: Execute tasks
   mainClass.executeTasks();

   // Step 4: Logoff from Cognos
   mainClass.logoffFromCognos();
}

// Step 1: Connect to the Cognos services
private void connectToCognos(String dispatcherURL) {
   ContentManagerService_ServiceLocator cmServiceLocator =
        new ContentManagerService_ServiceLocator();

   try {
      URL url = new URL(dispatcherURL);
      cmService = cmServiceLocator.getcontentManagerService(url);
   } catch (Exception e) {
      e.printStackTrace();
   }
}

// Step 2: Logon to Cognos
private void logonToCognos(String nsID, String user, String pswd) {
   StringBuffer credentialXML = new StringBuffer();
   credentialXML.append("<credential>");
   credentialXML.append("<namespace>").append(nsID).append("</namespace>");
   credentialXML.append("<username>").append(user).append("</username>");
   credentialXML.append("<password>").append(pswd).append("</password>");
   credentialXML.append("</credential>");

   String encodedCredentials = credentialXML.toString();
   XmlEncodedXML xmlCredentials = new XmlEncodedXML();
   xmlCredentials.set_value(encodedCredentials);

   try {
      cmService.logon(xmlCredentials, null);
      SOAPHeaderElement temp = ((Stub)cmService).getResponseHeader(
         "http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");
      BiBusHeader CMbibus = (BiBusHeader)temp.getValueAsType(
         new QName ("http://developer.cognos.com/schemas/bibus/3/",
            "biBusHeader"));
      ((Stub)cmService).setHeader(
            "http://developer.cognos.com/schemas/bibus/3/",
         "biBusHeader", CMbibus);
   } catch (Exception ex) {
      ex.printStackTrace();
   }
}

// Step 3: Execute tasks
private void executeTasks() {
   PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName };
   BaseClass bc[] = null;
   String searchPath = "/content//package";

   try {
      SearchPathMultipleObject spMulti =
            new SearchPathMultipleObject(searchPath);
      bc = cmService.query(spMulti, props, new Sort[] {}, new QueryOptions());
   } catch (Exception e) {
      e.printStackTrace();
      return;
   }

   System.out.println("PACKAGES:\n");
   if (bc != null) {
      for (int i = 0; i < bc.length; i++) {
         System.out.println(bc.getDefaultName().getValue() + " - "
               + bc.getSearchPath().getValue());
      }
   }
}

// Step 4: Logoff from Cognos
private void logoffFromCognos() {
   try {
      cmService.logoff();
   } catch (Exception ex) {
      ex.printStackTrace();
   }
}
}

please advice me how to resolve the issue and what are the procedure i need to follow to migrate windows .bat scripts in Linux environment.

Thanks in advance,
Karhtee