On 01/03/16 14:15, Miguel Valencia wrote:
> Thorsten Scherler <thorsten <at> apache.org> writes:
> 
>>
>> On 01/03/16 10:57, Miguel Valencia wrote:
>>> Hi
>>>
>>>  I have detected an error in my project with Apache Cocoon using dispatcher
>>> plugin.
>>>
>>> ERROR cocoon.access - Internal Cocoon Problem
>>> Caused by: org.apache.forrest.dispatcher.exception.ContractException:
>>> Could not invoke the transformation for the contract "meta". Error java:
>>> javax.xml.transform.TransformerException: Premature end of file.
>>>
>>> Error sequence is:
>>> a) Ask some page of my project
>>> b) Wait until expire jx cache
>>> c) Ask again the same page
>>>
>>> The web page of my project using forrest, so using structurer that are
>>> composite with contracts and caching with jx tag. 
>>>
>>> Example jx caching:
>>>
>>> jx:cache-key=
>>> "${Packages.org.apache.forrest.dispatcher.impl.helper.Key
>>> (cocoon.request).toString()}"
>>> jx:cache-validity=
>>> "${Packages.org.apache.excalibur.source.impl.validity.
>>> ExpiresValidity(300000)}">
>>>
>>> Example call to contract:
>>>
>>> <forrest:contract name="comun/meta"
>>> dataURI="servlet:conector:/estatico/drupal/metadatos.xml">
>>>   <forrest:property name="url">/${getRequest}/</forrest:property>
>>> </forrest:contract>
>>>
>>>
>>> Sometimes to resolve some contracts, dispatcher can not get XSLT of contract
>>> and then appear this error.
>>>
>>> Two things I have seen:
>>> 1) If not used jx cache this error not appear.
>>> 2) I have debug this problema until class:
>>> org.apache.forrest.dispatcher.impl.CocoonResolver and if put synchronized
>>> block here:
>>>
>>> source = resolver.resolveURI(uri);      
>>> stream = new BufferedInputStream(source.getInputStream());
>>>
>>> then, it seems that error not show.
>>>
>>> has anyone seen this error before?
>>>
>>> Thanks
>>>
>>
>> Hola Miguel, como estamos? ;)
>>
>> It looks like that either the data url of the contract or the
>> ${getRequest} is not resolved.
>>
>> ${getRequest} is a xml, coming from where?
>>
>> salu2
>>
> 
> Hi Thor
> 
> we are as always, same people same problems :-P
> 
> About this problema, the contract read a file on disk. At beginner whe
> though it was a problem with NFS system, but we changed the file to disk and
> the problem go on.
> 
> We deleted the contract and then, error appear in the next contract that it
> used dataURI parameter. 
> I think is a race condition because not happen always, and then any variable
> is lost or override. It's strange because dispatcher is configured like
> prototype bean.
> 
> Logs including messages in code seems that sometimes, when you try to
> terminate the contract for the XSLT to be used to get the HTML of the
> contract, an XML type is obtained:
> 
> 1 <? Xml version = "1.0" encoding = "utf-8"?>
> 2 <foo />
> 
> What causes the error when performing the processing SAX. Debug the
> application has reached the class:
> org.apache.forrest.dispatcher.impl.CocoonResolver that is where the
> information is obtained when a contract is terminated. Thinking it might be
> a bug type: race condition, which for some concurrency issue the value of
> the variable that obtains the data stream contract miss a synchronized block
> was applied to the following judgments of code
> 
> 1 synchronized (this) {
> 2   source = resolver.resolveURI (uri);
> 3   stream = new BufferedInputStream (source.getInputStream ());
> 4 }
> 
> and with this modification to the code, error not appear, but I think this
> change could affect to performance of application.
> 
> What do you think?
> 

Yeah, it will influence the performance a bit but it makes sense what
you are describing.

Can you provide a patch and we will apply it.

salu2


-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/

Attachment: signature.asc
Description: OpenPGP digital signature