Sergei Biletnikov created OFBIZ-5449:
----------------------------------------

             Summary: Emails with attachments are sent multiple times, problem 
with : field-to-result (simple methods)
                 Key: OFBIZ-5449
                 URL: https://issues.apache.org/jira/browse/OFBIZ-5449
             Project: OFBiz
          Issue Type: Bug
          Components: content
    Affects Versions: Release Branch 12.04
            Reporter: Sergei Biletnikov


The service "createCommContentDataResource" which is used for creating and 
storing the content data resourses throws an error. As result, the email 
sending is not finished (just the data resource was not stored to the DB) and 
the service scheduler reschedule it again. As result, OFBiz sends emails every 
retring period.

The service implementation:
component://content/script/org/ofbiz/content/content/ContentServices.xml#createCommContentDataResource

There is a snippet of code with wrong behaviour: 
          <call-service service-name="persistContentAndAssoc" 
in-map-name="persistIn">
            <results-to-map map-name="persistOut"/>
        </call-service>

        <iterate-map key="key" value="val" map="persistOut">
            <field-to-result field="val" result-name="${key}"/>
        </iterate-map>


Message: Roll back error, could not commit transaction, was rolled back instead 
because of: Service [createCommContentDataResource] threw an unexpected 
exception/errororg.ofbiz.service.GenericServiceException: Outgoing result (in 
runSync : createCommContentDataResource) does not match expected requirements 
(Unknown parameter found: [createCommContentDataResource.success]) (Outgoing 
result (in runSync : createCommContentDataResource) does not match expected 
requirements (Unknown parameter found: [createCommContentDataResource.success]))
---- cause ---------------------------------------------------------------------
Exception: org.ofbiz.service.GenericServiceException
Message: Outgoing result (in runSync : createCommContentDataResource) does not 
match expected requirements (Unknown parameter found: 
[createCommContentDataResource.success])
---- cause ---------------------------------------------------------------------
Exception: org.ofbiz.service.ServiceValidationException
Message: Unknown parameter found: [createCommContentDataResource.success]
---- stack trace ---------------------------------------------------------------
org.ofbiz.service.ServiceValidationException: Unknown parameter found: 
[createCommContentDataResource.success]
org.ofbiz.service.ModelService.validate(ModelService.java:649)
org.ofbiz.service.ModelService.validate(ModelService.java:563)
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:480)
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:225)
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:163)
org.ofbiz.party.communication.CommunicationEventServices.createAttachmentContent(CommunicationEventServices.java:1022)
org.ofbiz.party.communication.CommunicationEventServices.updateCommEventAfterEmail(CommunicationEventServices.java:648)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)

However,the cause of the problem is here:
<field-to-result field="val" result-name="${key}"/>

when the key = "responseMessage" and val = "success"
field-to-result places to the result map unexpected key-value pair : success : 
success  (not  responseMessage : success)
That is wrong, of course.

Quick workaround is ignore the "responseMessage" field:
<iterate-map key="key" value="val" map="persistOut">
            <if-compare field="key" operator="not-equals" 
value="responseMessage">
                <field-to-result field="val" result-name="${key}"/>
            </if-compare>
</iterate-map>

but I would prefer if someone have found the problem in "field-to-result"



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to