[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17719860#comment-17719860 ] ASF subversion and git services commented on OFBIZ-12801: - Commit d31b69efc70ecf31d8a8720a6eea238e0f3170a4 in ofbiz-framework's branch refs/heads/trunk from Gil Portenseigne [ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=d31b69efc7 ] Fixed: Fix cast error at CommunicationEventServices.groovy (OFBIZ-12801) Service implementation should return a Map, since `return success()` was misplaced within `.each`, it is ignored, and the `communicationEvents` List was returned instead. Thanks, Jacques for spotting and Daniel for the analysis > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17719845#comment-17719845 ] Jacques Le Roux commented on OFBIZ-12801: - +1 for me, thanks Gil > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17719844#comment-17719844 ] Gil Portenseigne commented on OFBIZ-12801: -- Hello Jacques, Daniel, While the discussion continue about GroovyBaseScript in dev mailing list, i think we can agree for this case to move the return success() out of the each block ? Thanks, Gil > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714089#comment-17714089 ] Jacques Le Roux commented on OFBIZ-12801: - bq. I think we can reasonably state that any particular groovy script or method can only be the implementation for an event or a service, but not both. I agree with this assumption, especially for methods. If it's not the case for a scripts (both types mixed, I doubt), a separation would need to be used. Since we are unsure of the solution to adopt, I agree a discussion on dev ML should be created (before a Jira is created). I'll do that... > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713934#comment-17713934 ] Gil Portenseigne commented on OFBIZ-12801: -- For this case I agree that the fix should be returning success at the end of the service implementation. I personally wondered about success method that can return two different types depending of the context (request vs service), and I agree that any groovy script implementation using this method are only of one type. But I think that this particular implementation was intentional to avoid the dev to think about being in service or event, and using success() in any situation. (same with error method). Quote of the commit message from Jacopo : {quote}these helper methods have been enhanced in order to be used by groovy method executed as services or events in a transparent way. {quote} With that intent in mind, codenarc-disable was set, i'm yet not sure that we should remove that intent, that technically do not cause any issue apart from having NoDef best practice not respected. I guess that should be discussed in another Jira / mailing list :) > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713728#comment-17713728 ] Daniel Watford commented on OFBIZ-12801: Another approach, but less favourable in my opinion, is to recognise that an groovy event handler is permitted to return a Map. GroovyEventHandler#invoke (lines 118-128) will then extract a message and response code from the map and set them as attributes on the caller's HttpServletRequest. However any other values in the map are ignored, whereas the implementation in GroovyBaseScript#success (lines 127-130) will set additional map values as attributes on the request. This potential loss of information is why I think we should take the event-handler implementation from GroovyBaseScript#success (lines 123-132) and reimplement in GroovyBaseScript#eventSuccess where a String is returned and attributes set on the HttpServletRequest. > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713725#comment-17713725 ] Daniel Watford commented on OFBIZ-12801: In the case of sendEmailDated, I believe it is only being used as a service implementation, not an event handler. We could therefore use a new GroovyBaseScript#serviceSuccess method to construct a response map. > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713721#comment-17713721 ] Daniel Watford commented on OFBIZ-12801: Regarding GroovyBaseScript#success, we cannot use explicit typing here as the success() implementation (lines 121-139 in GroovyBaseScript.groovy) seems to be trying to solve two entry points into groovy scripts: GroovyEventHandler#invoke for events and GroovyEngine#runSync for services. I think we can reasonably state that any particular groovy script or method can only be the implementation for an event or a service, but not both. We should therefore avoid calling GroovyBaseScript#success and instead introduce two new 'success' type methods named something like GroovyBaseScript#serviceSuccess and GroovyBaseScript#eventSuccess which can craft appropriate responses according to whether they support service or events. These two new services can then be explicitly typed meaning they can be called from the groovy code without the need to disable codenarc rules. Similar methods will also need to be created for failure/error responses from events and service invocations. If we find cases where a groovy script or method is providing the implementation/invocation for both a service and event, then we should explicitly set the implementation to satisfy one type of entry point (e.g. service) and then build a new 'adapter' method which can be invoked by the other entry point (e.g. event). Over time the GroovyBaseScript#success methods can be retired in favour of the new methods. > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712406#comment-17712406 ] Jacques Le Roux commented on OFBIZ-12801: - Thanks for the effort Daniel, I'll have a look too... > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167
[ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712362#comment-17712362 ] Daniel Watford commented on OFBIZ-12801: Line 489 of CommunicationEventServices.groovy - i.e. the last expression to be evaluated in the function - is communicationEvents.each \{ } In this case communciationEvents.each() will return a List. Since this is the last expression in the function it will be returned, meaning this function's signature is really: {code:java} List sendEmailDated(){code} I imagine this was not the original intent of the function since there is a call to `return success` inside the closure passed to communicationEvents.each. The service definition does not define any outputs... {code:java} Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email {code} ... but since it is a service I imagine it should return a map containing responseMessage entry with a value of success, fail or error. (See ModelService#returnSuccess, etc). The function should probably be modified to return a 'success' map unless any non-success results were found when executing the closure by communicationEvents.each(). Side note: We should probably take a look at GroovyBaseScript#success and ensure it really does return a Map. The current implementation can return either a Map or a String. > Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167 > -- > > Key: OFBIZ-12801 > URL: https://issues.apache.org/jira/browse/OFBIZ-12801 > Project: OFBiz > Issue Type: Bug > Components: projectmgr >Affects Versions: Upcoming Branch > Environment: >Reporter: Jacques Le Roux >Assignee: Jacques Le Roux >Priority: Major > Fix For: Upcoming Branch > > > I get this error locally: > The Following Errors Occurred: > Service dispatcher threw an exception:Error running Groovy method > [sendEmailDated] in Groovy file > [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: > (Cannot cast object '[]' with class 'java.util.ArrayList' to class > 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find > matching constructor for: java.util.Map()) > When I replace > Map sendEmailDated() { > by > def sendEmailDated() { > The error disappears > I guess something better can be done, but I have not yet found what :) -- This message was sent by Atlassian Jira (v8.20.10#820010)