cancel
Showing results for 
Search instead for 
Did you mean: 

Using ICacheService in Web Dynpro DC

Sigiswald
Contributor
0 Kudos

Dear,

My Web Dynpro DC application allows users to upload several files. Since I don't want to keep all these files continuously in memory, during the complete user session, I want to temporarily save them to disk. Therefore I'm trying to use the ICacheService interface, <a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/km/com/sapportals/wcm/service/cache/package-frame.html">com.sapportals.wcm.service.cache.ICacheService</a>, part of the Knowledge Management and Collaboration (KMC) API.

To be able to compile (the code below), I created a separate DC of type "External Library" that contains these 3 jar files: bc.sf.framework_api.jar, bc.sf.service.cache_api.jar and bc.util.public_api.jar. These 3 jar files where obtained from these 3 par files: com.sap.netweaver.bc.sf.par.bak, com.sap.netweaver.bc.sf.service.par.bak and com.sap.netweaver.bc.util.par.bak. It took a little bit of searching to find the required jar files, but anyway, everything compiles fine... The External Library only has a public part of type API.

As you may have guessed, my problem is to get this working at runtime... I can't deploy the External Library DC (using a public part of type assembly) together with my Web Dynpro, because that causes class loader issues. After all, these jar files are already deployed on the server. But if I don't define any runtime dependency or reference, I get a java.lang.ClassNotFoundException.

<b>The question is: how to define the runtime reference(s)?</b>

Should I define a Web Dynpro Sharing Reference like "PORTAL:sap.com/com.sap.km.bs.sf.service"? Then how can I obtain a reference to CacheServiceFactory?

FYI, we're using SAP NetWeaver 2004 SPS 15.

FYI, the relevant code I (think I) need looks like

ICache cache = CacheServiceFactory.getInstance().getCache("CACHE_ID");

Any help is greatly appreciated!

Kind regards,

/Sigiswald

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

1.Create a public part for those jar files for Assembly purpose.

2.Create an Application project and refer this public part in this Application DC and deploy on the server.

3.Make a sharing reference to this Application DC in your webdypro.

Hope this helps.

Answers (1)

Answers (1)

Sigiswald
Contributor
0 Kudos

Hi Sasi,

Thanks for your reply!

I don't think your suggestion of creating a public part of type assembly will work. Eventually, this will deploy the jar files on the server, which is not required since they're already deployed and it won't work either because of the same reason (class loader collissions).

But this is how I actually solved it, to my great surprise it's working perfect. <u>All</u> I had to do was create this sharing reference: "PORTAL:sap.com/com.sap.km.application".

Note that the referenced par file, com.sap.km.application.par.bak, does not include the CacheServiceFactory class. Neither was it necessary to obtain a reference via WDPortalUtils.getServiceReference.

Anyway, I'm glad it's working

Kind regards,

/Sigiswald