cancel
Showing results for 
Search instead for 
Did you mean: 

getPublicCachedWebResource method is unstable after adding 2nd server node

Former Member
0 Kudos

Hello,

I am using WDWebResource.getPublicCachedWebResource in order to put some excel file on the server and I use WDScopeType.CLIENTSESSION_SCOPE as the session type parameter.

Everything was working OK when we worked with just one server node but since we added another server node it is very unstable.

I have created a sample program that uses this method, generates the file and prints it's location on the server using IWDCachedWebResource.getAbsoluteURL() method.

I've noticed that at many times, if I open up a browser and browse to the getAbsoluteURL(0 location I receive a resource does not exist message.

I couldn't find any pattern in here, sometimes the resource is there and sometimes it doesn't.

Any idea why this strange thing is happening?

Roy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Roy,

Have you found a solution for this? I'm having the same problem..

Thanks.

Former Member
0 Kudos

OK, I developed my own solution..

The problem is: If you have only one Webdynpro server, the file is generated right away, and you can download immediately. But, if you have multiple servers, it takes a few seconds for the file to be generated. So, I developed a simple wait mechanism:


	IWDCachedWebResource resource;
	resource = WDWebResource.getPublicCachedWebResource(
		excel.getBytes(), WDWebResourceType.XLS, 
		WDScopeType.APPLICATION_SCOPE,
		wdThis.wdGetAPI().getComponent().getDeployableObjectPart(), 
		"UserRoles");
	resource.setAttachment(true);

	String filePath = WDURLGenerator.getResourcePath(
		wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),
		resource.getResourceName()); 
	File file = new File(filePath);
	long timeStart = System.currentTimeMillis();
	long time = timeStart;
	while (!file.exists() && (time-timeStart < 10000)) 
		{time = System.currentTimeMillis();};

	if (file.exists()) 
		wdComponentAPI.getWindowManager().createNonModalExternalWindow(
			resource.getAbsoluteURL(), "").show();
	else
		throw new Exception("An error occured while creating Excel file");