How to solve Can't find symbol error?
I am trying to use a Java program provided by IBM . See code below. When I try to compile this program,
C:\Temp>"C:\Program Files (x86)\Java\jdk1.6.0_25\bin\javac.exe" GetOrphanMyFolde
rs.java
I am getting the error
GetOrphanMyFolders.java:96: cannot find symbol
symbol : variable PropEnum
location: class GetOrphanMyFolders
PropEnum.canBurst ,
^
GetOrphanMyFolders.java:97: cannot find symbol
symbol : variable PropEnum
location: class GetOrphanMyFolders
PropEnum.capabilities ,
^
I am a Java noob, what is the reason for this error? The program I'm using is here
/**
* Licensed Material - Property of IBM
* © Copyright IBM Corp. 2012
*
* GetOrphanMyFolders.java
*
* Description: Technote 1340789 - SDK Sample: How to recover the My Folders of users that no longer exist in the Authentication Provider
*
* Tested with: IBM Cognos BI 10.1.1, IBM Java 5.0, Axis 1.4
*
*/
import java.util.Vector;
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.CopyOptions;
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.SearchPathSingleObject;
import com.cognos.developer.schemas.bibus._3.Sort;
import com.cognos.developer.schemas.bibus._3.UpdateActionEnum;
import com.cognos.developer.schemas.bibus._3.XmlEncodedXML;
public class GetOrphanMyFolders
{
//TODO: change the following variables depending on your installation and setup
//--- begin changes ----
private static String dispatcherURL = "http://localhost:9300/p2pd/servlet/dispatch";
//Change the next three variables to a valid namespace ID as defined in Cognos Configuration and NOT the namespace name
//Provide a valid user ID and password if Anonymous is disabled
private static String nameSpaceID = "Cognos";
private static String userName = "admin";
private static String password = "password";
// define where you are copying the orphaned my folders to
private static String targetLocation = "/content/folder[@name='OrphanedMyFolders']";
//--- end changes ---
//Services to be used in the sample
private ContentManagerService_PortType cmService = null;
private String[] getAllMyFoldersSearchPaths(String namespaceID)
{
String listOfAccountSP [] = null;
PropEnum props[] = new PropEnum[] {PropEnum.searchPath, PropEnum.defaultName, PropEnum.portalPage};
Sort sOpt[] = new Sort[]{};
QueryOptions qOpt = new QueryOptions();
try
{
// get the template user Account object.
BaseClass template[] = cmService.query(new SearchPathMultipleObject("//folder"), props, sOpt, qOpt);
listOfAccountSP = new String [template.length];
for (int x=0;x<template.length;x++)
{
if ( template[x].getSearchPath().getValue().indexOf(")/folder[@name='My Folders']")>0 )
{
listOfAccountSP[x]=template[x].getSearchPath().getValue();
}
}
}
catch (Exception e)
{
System.out.println(e);
e.printStackTrace();
}
return listOfAccountSP;
}
private PropEnum[] getAllPropEnum ()
{
PropEnum properties[] = new PropEnum[]{
PropEnum.active,
PropEnum.actualCompletionTime,
PropEnum.actualExecutionTime ,
PropEnum.advancedSettings ,
PropEnum.ancestors ,
PropEnum.asOfTime ,
PropEnum.base ,
PropEnum.brsAffineConnections,
PropEnum.brsMaximumProcesses ,
PropEnum.brsNonAffineConnections,
PropEnum.burstKey ,
PropEnum.businessPhone,
PropEnum.canBurst ,
PropEnum.capabilities ,
PropEnum.capacity ,
PropEnum.closeConnectionCommands,
PropEnum.closeSessionCommands ,
PropEnum.configuration ,
PropEnum.connections ,
PropEnum.connectionString ,
PropEnum.consumers ,
PropEnum.contact ,
PropEnum.contactEMail ,
PropEnum.contentLocale ,
PropEnum.creationTime ,
PropEnum.credential ,
PropEnum.credentialNamespaces ,
PropEnum.credentials ,
PropEnum.cubeContentName ,
PropEnum.dailyPeriod ,
PropEnum.data ,
PropEnum.dataBlocks ,
PropEnum.dataSize ,
PropEnum.dataType ,
PropEnum.defaultDescription ,
PropEnum.defaultName ,
PropEnum.defaultOutputFormat ,
PropEnum.defaultScreenTip ,
PropEnum.defaultTriggerDescription,
PropEnum.deployedObject ,
PropEnum.deployedObjectAncestorDefaultNames,
PropEnum.deployedObjectClass ,
PropEnum.deployedObjectDefaultName,
PropEnum.deployedObjectStatus ,
PropEnum.deployedObjectUsage ,
PropEnum.deploymentOptions ,
PropEnum.description ,
PropEnum.disabled ,
PropEnum.dispatcherID ,
PropEnum.dispatcherPath ,
PropEnum.displaySequence ,
PropEnum.email ,
PropEnum.endDate ,
PropEnum.endType ,
PropEnum.eventID ,
PropEnum.everyNPeriods ,
PropEnum.executionFormat ,
PropEnum.executionLocale ,
PropEnum.executionPageDefinition ,
PropEnum.executionPageOrientation ,
PropEnum.executionPrompt ,
PropEnum.faxPhone ,
PropEnum.format ,
PropEnum.gateway ,
PropEnum.givenName ,
PropEnum.governors ,
PropEnum.hasChildren ,
PropEnum.hasMessage ,
PropEnum.hasPrompts ,
PropEnum.height ,
PropEnum.homePhone ,
PropEnum.horizontalElementsRenderingLimit,
PropEnum.identity ,
PropEnum.isolationLevel,
PropEnum.lastConfigurationModificationTime,
PropEnum.lastPage ,
PropEnum.loadBalancingMode,
PropEnum.locale ,
PropEnum.location,
PropEnum.members ,
PropEnum.message ,
PropEnum.metadataModel ,
PropEnum.mobilePhone ,
PropEnum.model ,
PropEnum.modelName ,
PropEnum.modificationTime ,
PropEnum.monthlyAbsoluteDay ,
PropEnum.monthlyRelativeDay ,
PropEnum.monthlyRelativeWeek ,
PropEnum.name ,
PropEnum.namespaceFormat ,
PropEnum.objectClass ,
PropEnum.openConnectionCommands ,
PropEnum.openSessionCommands ,
PropEnum.options ,
PropEnum.output ,
PropEnum.owner ,
PropEnum.ownerPassport ,
PropEnum.packageBase ,
PropEnum.page ,
PropEnum.pageOrientation ,
PropEnum.pagerPhone ,
PropEnum.parameters ,
PropEnum.parent ,
PropEnum.paths ,
PropEnum.permissions ,
PropEnum.policies ,
PropEnum.portalPage ,
PropEnum.position ,
PropEnum.postalAddress ,
PropEnum.printerAddress ,
PropEnum.productLocale ,
PropEnum.qualifier ,
PropEnum.recipients ,
PropEnum.recipientsEMail ,
PropEnum.related ,
PropEnum.replacement ,
PropEnum.requestedExecutionTime ,
PropEnum.retentions ,
PropEnum.rsAffineConnections ,
PropEnum.rsMaximumProcesses ,
PropEnum.rsNonAffineConnections ,
PropEnum.rsQueueLimit ,
PropEnum.runAsOwner ,
PropEnum.runningState ,
PropEnum.runOptions ,
PropEnum.screenTip ,
PropEnum.searchPath ,
PropEnum.searchPathForURL ,
PropEnum.sequencing ,
PropEnum.serverGroup ,
PropEnum.source ,
PropEnum.specification ,
PropEnum.startAsActive ,
PropEnum.startDate ,
PropEnum.state ,
PropEnum.status ,
PropEnum.stepObject ,
PropEnum.surname ,
PropEnum.target ,
PropEnum.taskID ,
PropEnum.timeZoneID ,
PropEnum.triggerDescription ,
PropEnum.triggerName ,
PropEnum.type ,
PropEnum.unit ,
PropEnum.uri ,
PropEnum.usage ,
PropEnum.user ,
PropEnum.userCapabilities ,
PropEnum.userCapability ,
PropEnum.userName ,
PropEnum.version ,
PropEnum.verticalElementsRenderingLimit ,
PropEnum.viewed ,
PropEnum.weeklyFriday ,
PropEnum.weeklyMonday ,
PropEnum.weeklySaturday ,
PropEnum.weeklySunday ,
PropEnum.weeklyThursday ,
PropEnum.weeklyTuesday ,
PropEnum.weeklyWednesday ,
PropEnum.width ,
PropEnum.yearlyAbsoluteDay,
PropEnum.yearlyAbsoluteMonth,
PropEnum.yearlyRelativeDay ,
PropEnum.yearlyRelativeMonth,
PropEnum.yearlyRelativeWeek ,
};
return properties;
}
private String[][] getAllCIs(String namespaceID)
{
String listOfCIs [][] = null;
String searchPath = "CAMID('"+namespaceID+"')//account";
PropEnum props[] = new PropEnum[] {PropEnum.searchPath, PropEnum.defaultName, PropEnum.portalPage};
Sort sOpt[] = new Sort[]{};
QueryOptions qOpt = new QueryOptions();
try
{
// get the template user Account object.
BaseClass template[] = cmService.query(new SearchPathMultipleObject(searchPath), props, sOpt, qOpt);
listOfCIs = new String [2] [template.length];
for (int x=0;x<template.length;x++)
{
listOfCIs[0][x]=template[x].getSearchPath().getValue();
listOfCIs[1][x]=template[x].getDefaultName().getValue();
}
}
catch (Exception e)
{
System.out.println(e);
e.printStackTrace();
}
return listOfCIs;
}
private void moveMF2PF(String path, String targetLocation)
{
String userSearchPaths = path ;
PropEnum props[] = getAllPropEnum();
String user = path.substring(0, path.indexOf("/folder[@name='My Folders']"));
try
{
//Query the Content Store for all objects in My Folders for user userName
BaseClass bc[] = cmService.query(new SearchPathMultipleObject(userSearchPaths), props, new Sort[]{}, new QueryOptions());
if (bc != null && bc.length > 0)
{
//copy the folder to Public Folders and rename
String[] newName={user};
CopyOptions opt = new CopyOptions();
opt.setUpdateAction(UpdateActionEnum.replace);
opt.setRecursive(true);
cmService.copyRename(bc,new SearchPathSingleObject(targetLocation),newName,opt);
}
else
System.out.println("User " + user+" did not have My Folders. It could be that they have not logged on yet");
}
catch (Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
/**
* Establish a connection to Cognos BI and initialize the different services
*/
private void connectToCognos()
{
ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
try
{
cmService = cmServiceLocator.getcontentManagerService(new java.net.URL(dispatcherURL));
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Logon to Cognos BI using valid credentials information
*/
private void logon(String nameSpaceID, String userName, String password)
{
StringBuffer credentialXML = new StringBuffer();
credentialXML.append("<credential>");
credentialXML.append("<namespace>").append(nameSpaceID).append("</namespace>");
credentialXML.append("<username>").append(userName).append("</username>");
credentialXML.append("<password>").append(password).append("</password>");
credentialXML.append("</credential>");
String encodedCredentials = credentialXML.toString();
XmlEncodedXML xmlCredentials = new XmlEncodedXML();
xmlCredentials.set_value(encodedCredentials);
try
{
cmService.logon(xmlCredentials, null);
getSetHeaders();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
private void getSetHeaders()
{
String BiBus_NS = "http://developer.cognos.com/schemas/bibus/3/";
String BiBus_H = "biBusHeader";
BiBusHeader CMbibus = null;
SOAPHeaderElement temp = ((Stub)cmService).getResponseHeader(BiBus_NS, BiBus_H);
try
{
CMbibus = (BiBusHeader)temp.getValueAsType(new QName (BiBus_NS, BiBus_H));
}
catch (Exception e)
{
e.printStackTrace();
}
if (CMbibus != null)
{
((Stub)cmService).setHeader(BiBus_NS, BiBus_H, CMbibus);
}
}
/**
* This is the main class, which connects to Cognos BI and calls the
* method doWork(), containing the specific code for this sample
*/
public static void main(String args[])
{
GetOrphanMyFolders mainClass = new GetOrphanMyFolders();
mainClass.connectToCognos();
// If Anonymous is disabled, then logon
if (nameSpaceID.length() > 0)
{
mainClass.logon(nameSpaceID, userName, password);
}
//get all the CAMIDs related to the My Folders searchpath
String[] listOfMyFolders = mainClass.getAllMyFoldersSearchPaths(nameSpaceID);
String[][] listOfCamIds = mainClass.getAllCIs(nameSpaceID);
Vector<String> orphanedMyFolders = new Vector<String>();
// find a my folder that does not have an existing owner from the ldap
boolean found = false;
for (int i = 0; i < listOfMyFolders.length; i++)
{
if (listOfMyFolders[i] != null )
{
if (listOfMyFolders[i].endsWith("[@name='My Folders']"))
{
int y = 0;
for (y = 0; y < listOfCamIds[0].length - 1; y++)
{
String test = listOfCamIds[0][y];
if (listOfMyFolders[i].indexOf(test) >= 0)
{
found = true;
}
}
if (!found)
{
// String userName = getUserNameFromCamid(listOfMyFolders[i]);
System.out.println(listOfMyFolders[i] + " does not have an associated user");
orphanedMyFolders.add(listOfMyFolders[i]);
}
found = false;
}
}
}
// Now we need to take the list of orphaned My Folders and move them to the
// public folders so that the content can be examined.
for (int x = 0; x < orphanedMyFolders.size(); x++)
{
mainClass.moveMF2PF(orphanedMyFolders.elementAt(x).toString(), targetLocation);
}
System.out.println("Done ....");
}
}
source to share
The sample GetOrphanMyFolders.java
uses classes defined in external libraries (like jars), which should be available in Cognos 8 SDK
(usually under C8_INSTALLATION_DIR/sdk/lib
), I believe you should search cognosClient.jar
oraxisCognosClient.jar
Since you are new to java it will be tricky to compile this with javac
and add external jars to the classpath. I would recommend that you use eclipse
After downloading / installing (just unzip any directory you like) create New Java Project
, add GetOrphanMyFolders.java
to package src
(copy / paste or drag / drop). Then see this question to see how you can add libraries to your project path.
It will be much easier than figuring out how to do it with javac -cp
source to share
The problem is that the cognos banner is currently invisible. Hence, the compiler cannot resolve references to classes that are packaged in this jar.
You can find axisCognosClient.jar in the cognos installation directory
%COGNOS_INSTALL_DIR%/c8/webapps/p2pd/WEB-INF/lib
Include this directory in your classpath when compiling. This jar includes all the classes that you reference in the import statements.
source to share
As a rule, the first reported errors are significant. By fixing them, everything will be fixed. If the first errors look something like this: GetOrphanMyFolders.java:19: error: com.cognos.developer package does not exist import com.cognos.developer. *; ^
Then you need to follow some IBM instructions to download these packages and add them to your classpath.
If you already downloaded try http://www-01.ibm.com/support/docview.wss?uid=swg21343429
source to share
You are initializing an array of properties of type PropEnum. Maybe PropEnum does not have canBurst and capabilities defined as an attribute.
Just try removing the spaces between {PropEnum.canBurst, PropEnum.capabilities,} in {PropEnum.canBurst, PropEnum.capabilities,}. Whitespace shouldn't be a problem.
source to share