cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch iview_List from PCD.

Former Member
0 Kudos

Hi Folks

kindly help me on below issue.

i am trying to use the below piece of code to fetch the list of iviews from PCD.

the problem is i dont understand the error.

Code in APC:

===========

public class APC_Comp extends AbstractPortalComponent
{
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
    {
 
	  try{
	  Hashtable env = new Hashtable();
	  env.put(IPcdContext.SECURITY_PRINCIPAL, request.getUser());
	  env.put(Context.INITIAL_CONTEXT_FACTORY,IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
//
//	  env.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);
//		
// 		/******** Since i couldnt find 	PcmConstants.ASPECT_SEMANTICS jar i used the below code.
// 
	  env.put(Constants.REQUESTED_ASPECT,"com.sap.portal.pcd.gl.PersistencyAspect");
	  InitialContext ctx = null;
	  DirContext dirCtx;
	  List roleList = null;
	  ctx = new InitialContext(env);
	  dirCtx = (DirContext) ctx.lookup("pcd:portal_content/");
	  PcdSearchControls pcdSearchControls = new PcdSearchControls();
	  pcdSearchControls.setReturningObjFlag(false);
	  pcdSearchControls.setSearchScope(
	  PcdSearchControls.SUBTREE_WITH_UNIT_ROOTS_SCOPE);
	  dirCtx.addToEnvironment(
	  Constants.APPLY_ASPECT_TO_CONTEXTS,
	  Constants.APPLY_ASPECT_TO_CONTEXTS);
	  NamingEnumeration ne = dirCtx.search("","(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.*iview*)",
	  												pcdSearchControls);
 
	  while (ne.hasMoreElements()) {
	  IPcdSearchResult searchResult =
	  (IPcdSearchResult) ne.nextElement();
	  String location = "pcd:portal_content/" + searchResult.getName();
	  roleList.add(location);
	  response.write("Object is "+location);
	  }
 
		
	  }catch(Exception e )
	  {
	  	 response.write("Exception Occured due to :" +e.toString());
	  }
	
	}
 
}

Error Log :
==========
<< item 1 : >>#1.5 #001125A585A0005F000003BD0002514800045CAD115E54F3#1227798297334#com.sap.portal.prt.runtime#sap.com/irj#com.sap.portal.prt.runtime#ramesht#150270##n/a##e592fa70bc8511dd9fdd001125a585a0#SAPEngine_Application_Thread[impl:3]_19##0#0#Error##Java###07:04_27/11/08_0078_79979950 
[EXCEPTION]
{0}#1#java.lang.NoClassDefFoundError: com.sapportals.portal.pcd.gl.PcdSearchControls
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:66)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:127)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Simon , Nikhil

Thanks for your response.

Regarding the suggestion , you provided did'nt help me out.

i did the referening of the PCDsearchResult

and i too import the jar file , still i am facing the same problem.

Nikhil: i didnt get wat you mean by

__Please add the references of gl_api.jar file to project as PcdSearchControls class is defined there._

how to do?

the thing i did was , i add the gl_api.jar as external jar file to the project. is that wat you mean?

but still the presist....:-(

Appreciate your help in advance.

Portalapp.xml
================
<?xml version="1.0" encoding="utf-8"?>
<application>
  <application-config/>
    <application-config>
    <property name="SharingReference" value="com.sapportals.portal.pcd.gl.PcdSearchControls"/>
     </application-config>
  <components>
    <component name="Test_APC">
      <component-config>     
        <property name="ClassName" value="com.sap.test_apc.Test_APC"/>
        <property name="SafetyLevel" value="no_safety"/>
        </component-config>
      <component-profile/>
    </component>
  </components>
  <services/>
</application>

Import
=======
package com.sap.test_apc;
 
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.directory.DirContext;

import com.sap.portal.directory.Constants;
import com.sapportals.portal.pcd.gl.IPcdContext;
import com.sapportals.portal.pcd.gl.IPcdSearchResult;  <<<<<<<<<
import com.sapportals.portal.pcd.gl.PcdSearchControls;  <<<<<<<<<<<
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;

Former Member
0 Kudos

Hi Kumar,

In Portalapp.xml file change the value of SharingReference property to com.sap.portal.pcd.glservice. You have provided the value as com.sapportals.portal.pcd.gl.PcdSearchControls which is the <package Name>.<Class Name> and not the SharingReference for the class PcdSearchControls.

Hope this will resolve your problem.

Regards,

Nikhil

Former Member
0 Kudos

hi nikhil

<?xml version="1.0" encoding="utf-8"?>
<application>
  <application-config/>
   <application-config>
	<property name="SharingReference" value="com.sap.portal.pcd.glservice"/>
	</application-config>
  <components>
    <component name="Test_APC">
      <component-config>     
        <property name="ClassName" value="com.sap.test_apc.Test_APC"/>
       </component-config>
      <component-profile/>
    </component>
  </components>
  <services/>
</application>

I modified as you suggested, but still the same errorr comes up

inorde to find the exact point of failure, i tried printmsg in each line,

thus doing so, i found the crash happened at

PcdSearchControls pcdSearchControls = new PcdSearchControls();
              response.write("<br>check ==> "+ i++);

during the point of object creation, the code break out.

dont know the reason and solution..

Former Member
0 Kudos

Hi Kumar,

Going through your code I can see that you have not allocate the memory to roleList variable. It has only been

initialized with null and you started adding location to it. Allocate memory to roleList before while loop by using this

statement:

roleList = new ArrayList();

This will surely resolve your problem.

Regards,

Nikhil

PS: Don't forget to award points and close the thread.

Former Member
0 Kudos

Hi Nikhil

Thanks for you help and Support.

Full points awarded....:-)

BTW, as you pointed , its one of the mistake i did, even on correcting it , still i faced the problem.

Thus as i changed the code bit, instead of using pcdsearchcontrol api , i used normal java searchControl api.

which completely resolved my issue.

Honestly , i still dont know, wats the problem with PCDsearchControl API.

Since, i got resolved , i am closing this thread as Answered...

Thanks for your support..

Thanks

Kumar T

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Runtime references may not be defined in your portalapps.xml to use PcdSearchControls which is giving rise to this error. Below are the dependencies for using the classes and interfaces for accessing PCD:

Add Sharing References in portalapps.xml:

com.sap.portal.pcd.glservice

JAR files:

com.sap.portal.pcd.glservice_api.jar

gl_api.jar

Please add the references of gl_api.jar file to project as PcdSearchControls class is defined there.

Regards,

Nikhil Farkya

Former Member
0 Kudos

Hi,

In your portalapp.xml file make sure you have a reference to the service required to use the pcdSearchControls object. The error is telling you it can't find that class file probably because you haven't told the portal runtime the you intend to use it (via the portalapp.xml file config) - therefore it hasn't got it in the class loader for your component.

Hope this helps,

Simon