cancel
Showing results for 
Search instead for 
Did you mean: 

Java backed webscript just shut down...

documentalover
Champ in-the-making
Champ in-the-making
Hi to all of the members of this forum, this is my first post here. Smiley Happy
I'm developing a java backed webscript, on an Alfresco 3.3.4, which has to read some numerical properties from nodes, aggregate them using a certain set of rules, then outputs the results in a csv file.
When I run the first tests of this webscript on a few tens of nodes I had no problems whatsoever, leaving aside bugs related to the inner logic of the webscript itself, which I had long fixed anyway.
The problems started getting quite serious when I ran the tests on a realistical scenario, with thousands of nodes to be computed, tens of thousands in the future most likely.
The program just shuts down with no errors and exits, NOT DOING ANY ROLLBACK on the modifications it does on the nodes it visits (it puts a timestamp in them to understand when and if it visited a specific node).
In the logs there are no errors, no exceptions, just the execution stops at a certain point of a class, always the same point, which does nothing in particular: it simply prints a log message.
The only particular things this webscript does is it prints tens of thousands of log messages in a very short amount of time: I used them to check if it makes the right aggregations. They're not essential and I will disable them in the future, most likely. Can this be related to the problem I'm having?
I encoutered the 1000 nodes limit "feature" of lucene too, but I had already handled that, this problem verifies long after I've already loaded all of the nodes I need in memory in fact.

Thanks for any help.
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
By default the WebScript framework works in a transactional process, this means that for each execution of your Web Scripts the container will rollback all the nodes data if there will be returned any exception (RuntimeException).

So probably you will have in your log file an OutOfMemory error returned by the Java Virtual Machine.

If you need to process many nodes probably you should disable the default transaction support of the Web Scripts engine and you could use the RetryingTransactionCallBack feature of Alfresco that allows you to use the transactionService in an explicit way.
In this way you can control the transactionService and you can decide when and what will be rollbacked by your WebScript without using all the memory available for the Java Virtual Machine.

I suggest to try to disable the default transaction container of the WebScript setting to none the transaction element in the WebScript descriptor. Then I suggest to use the explicit transactionService as you can see in the FirstFoundationClient example that you can find in the Alfresco SDK.

WebScripts Transactions:
http://wiki.alfresco.com/wiki/Web_Scripts#Advanced_Description_Options

Java API - RetryingTransactionHelper:
http://wiki.alfresco.com/wiki/Java_Foundation_API#Using_RetryingTransactionHelper

Hope this helps.