You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Kranti Agrawal <kr...@gmail.com> on 2010/04/14 08:32:29 UTC

Groovy file as a service

Hi,

Can I call a groovy file as a service?

Regards,
Kranti Agrawal
Student, IIIT Bangalore
krantiagrawal.blogspot.com

Re: Groovy file as a service

Posted by Joe Eckard <jo...@redrocketcorp.com>.
Take a look at /framework/service/src/org/ofbiz/service/engine/ 
GroovyEngine.java... all you need to do to is create a map called  
"result" in your groovy script and put your OUT parameters there.

The error below is just a type mismatch... groovy strings in with  
variables in them (${ex}) are GStrings, not Strings. You can fix this  
by calling .toString() on the groovy string before putting it into the  
result map.


On Apr 14, 2010, at 10:24 AM, Kranti Agrawal wrote:

> Can you please give some examples of groovy services which return a  
> List?
>
> Regards,
> Kranti Agrawal
> Student, IIIT Bangalore
> krantiagrawal.blogspot.com
>
>
> On Wed, Apr 14, 2010 at 7:53 PM, Robert Morley  
> <rm...@emforium.com> wrote:
>
>> We had a period of time where people wrote some services in groovy.
>> However, in our Obiz code we report the same error as what is  
>> listed here
>> (with testGroovy).  The groovy services we currently have in play  
>> (for the
>> most part) have no OUT parameters and the ones that do return a
>> GenericEntity, a List, and an Integer (all of those I would suspect  
>> are
>> working).  Appears we have a bug here dealing with String OUT  
>> parameters
>> (granted it must have worked at one point in time).
>>
>>
>> On Apr 14, 2010, at 9:42 AM, Kranti Agrawal wrote:
>>
>> Hi,
>>> I tried running the service 'testGroovy' in the Service Engine under
>>> webtools, I got the following error
>>>
>>> <li>Service dispatcher threw an exceptionType check failed for field
>>> [testGroovy.successMessage]; expected type is [String]; actual  
>>> type is
>>> [org.codehaus.groovy.runtime.GStringImpl]
>>>
>>>
>>


Re: Groovy file as a service

Posted by Kranti Agrawal <kr...@gmail.com>.
Can you please give some examples of groovy services which return a List?

Regards,
Kranti Agrawal
Student, IIIT Bangalore
krantiagrawal.blogspot.com


On Wed, Apr 14, 2010 at 7:53 PM, Robert Morley <rm...@emforium.com> wrote:

> We had a period of time where people wrote some services in groovy.
>  However, in our Obiz code we report the same error as what is listed here
> (with testGroovy).  The groovy services we currently have in play (for the
> most part) have no OUT parameters and the ones that do return a
> GenericEntity, a List, and an Integer (all of those I would suspect are
> working).  Appears we have a bug here dealing with String OUT parameters
> (granted it must have worked at one point in time).
>
>
> On Apr 14, 2010, at 9:42 AM, Kranti Agrawal wrote:
>
>  Hi,
>> I tried running the service 'testGroovy' in the Service Engine under
>> webtools, I got the following error
>>
>> <li>Service dispatcher threw an exceptionType check failed for field
>> [testGroovy.successMessage]; expected type is [String]; actual type is
>> [org.codehaus.groovy.runtime.GStringImpl]
>>
>>
>

Re: Groovy file as a service

Posted by Robert Morley <rm...@emforium.com>.
We had a period of time where people wrote some services in groovy.   
However, in our Obiz code we report the same error as what is listed  
here (with testGroovy).  The groovy services we currently have in play  
(for the most part) have no OUT parameters and the ones that do return  
a GenericEntity, a List, and an Integer (all of those I would suspect  
are working).  Appears we have a bug here dealing with String OUT  
parameters (granted it must have worked at one point in time).

On Apr 14, 2010, at 9:42 AM, Kranti Agrawal wrote:

> Hi,
> I tried running the service 'testGroovy' in the Service Engine under
> webtools, I got the following error
>
> <li>Service dispatcher threw an exceptionType check failed for field
> [testGroovy.successMessage]; expected type is [String]; actual type is
> [org.codehaus.groovy.runtime.GStringImpl]
>


Re: Groovy file as a service

Posted by Kranti Agrawal <kr...@gmail.com>.
Hi,
I tried running the service 'testGroovy' in the Service Engine under
webtools, I got the following error

<li>Service dispatcher threw an exceptionType check failed for field
[testGroovy.successMessage]; expected type is [String]; actual type is
[org.codehaus.groovy.runtime.GStringImpl]

*The log section is as follows*:

     [java] 2010-04-14 19:09:06,248 (http-0.0.0.0-8443-6) [
 ContextFilter.java:201:INFO ] [Request]: /webtools/control/scheduleService
     [java] 2010-04-14 19:09:06,249 (http-0.0.0.0-8443-6) [
ControlServlet.java:144:INFO ] [[[scheduleService] Request Begun,
encoding=[UTF-8]- total:0.0,since last(Begin):0.0]]
     [java] 2010-04-14 19:09:06,307 (http-0.0.0.0-8443-6) [
 CallSiteArray.java:40 :INFO ] -=-=-=- TEST GROOVY SERVICE -=-=-=-
     [java] 2010-04-14 19:09:06,308 (http-0.0.0.0-8443-6) [
      ?:?  :INFO ] ----- Message is: hello -----
     [java] 2010-04-14 19:09:06,308 (http-0.0.0.0-8443-6) [
ModelService.java:564:ERROR] [ModelService.validate] : {testGroovy} : (OUT)
Required test error: org.ofbiz.service.ServiceValidationException: Type
check failed for field [testGroovy.successMessage]; expected type is
[String]; actual type is [org.codehaus.groovy.runtime.GStringImpl]
     [java] 2010-04-14 19:09:06,309 (http-0.0.0.0-8443-6) [
 ServiceDispatcher.java:495:ERROR]
     [java] ---- exception report
----------------------------------------------------------
     [java] Outgoing result (in runSync : testGroovy) does not match
expected requirements
     [java] Exception: org.ofbiz.service.ServiceValidationException
     [java] Message: Type check failed for field
[testGroovy.successMessage]; expected type is [String]; actual type is
[org.codehaus.groovy.runtime.GStringImpl]
     [java] ---- stack trace
---------------------------------------------------------------
     [java] org.ofbiz.service.ServiceValidationException: Type check failed
for field [testGroovy.successMessage]; expected type is [String]; actual
type is [org.codehaus.groovy.runtime.GStringImpl]
     [java] org.ofbiz.service.ModelService.validate(ModelService.java:698)
     [java] org.ofbiz.service.ModelService.validate(ModelService.java:562)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:493)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226)
     [java]
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165)
     [java]
org.ofbiz.webapp.event.CoreEvents.scheduleService(CoreEvents.java:412)
     [java] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] java.lang.reflect.Method.invoke(Method.java:597)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:92)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:78)
     [java]
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:637)
     [java]
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:383)
     [java]
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:227)
     [java]
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:90)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:267)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     [java]
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     [java]
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
     [java]
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     [java]
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     [java]
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
     [java]
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
     [java]
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
     [java]
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
     [java]
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
     [java] java.lang.Thread.run(Thread.java:619)
     [java]
--------------------------------------------------------------------------------

     [java] 2010-04-14 19:09:06,309 (http-0.0.0.0-8443-6) [
 ServiceDispatcher.java:516:INFO ] [[Sync service failed...- total:0.0,since
last(Begin):0.0]] - 'webtools / testGroovy'
     [java] 2010-04-14 19:09:06,310 (http-0.0.0.0-8443-6) [
 ServiceDispatcher.java:519:ERROR]
     [java] ---- exception report
----------------------------------------------------------
     [java] Service [testGroovy] threw an unexpected exception/error
     [java] Exception: org.ofbiz.service.ServiceValidationException
     [java] Message: Type check failed for field
[testGroovy.successMessage]; expected type is [String]; actual type is
[org.codehaus.groovy.runtime.GStringImpl]
     [java] ---- stack trace
---------------------------------------------------------------
     [java] org.ofbiz.service.ServiceValidationException: Type check failed
for field [testGroovy.successMessage]; expected type is [String]; actual
type is [org.codehaus.groovy.runtime.GStringImpl]
     [java] org.ofbiz.service.ModelService.validate(ModelService.java:698)
     [java] org.ofbiz.service.ModelService.validate(ModelService.java:562)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:493)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226)
     [java]
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165)
     [java]
org.ofbiz.webapp.event.CoreEvents.scheduleService(CoreEvents.java:412)
     [java] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] java.lang.reflect.Method.invoke(Method.java:597)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:92)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:78)
     [java]
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:637)
     [java]
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:383)
     [java]
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:227)
     [java]
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:90)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:267)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     [java]
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     [java]
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
     [java]
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     [java]
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     [java]
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
     [java]
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
     [java]
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
     [java]
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
     [java]
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
     [java] java.lang.Thread.run(Thread.java:619)
     [java]
--------------------------------------------------------------------------------

     [java] 2010-04-14 19:09:06,310 (http-0.0.0.0-8443-6) [
 TransactionUtil.java:329:ERROR]
     [java] ---- exception report
----------------------------------------------------------
     [java] [TransactionUtil.rollback]
     [java] Exception: java.lang.Exception
     [java] Message: Stack Trace
     [java] ---- stack trace
---------------------------------------------------------------
     [java] java.lang.Exception: Stack Trace
     [java]
org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:328)
     [java]
org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:310)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:526)
     [java]
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226)
     [java]
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165)
     [java]
org.ofbiz.webapp.event.CoreEvents.scheduleService(CoreEvents.java:412)
     [java] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] java.lang.reflect.Method.invoke(Method.java:597)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:92)
     [java]
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:78)
     [java]
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:637)
     [java]
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:383)
     [java]
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:227)
     [java]
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:90)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
     [java] javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:267)
     [java]
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     [java]
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     [java]
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     [java]
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     [java]
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
     [java]
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     [java]
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     [java]
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
     [java]
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
     [java]
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
     [java]
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
     [java]
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
     [java] java.lang.Thread.run(Thread.java:619)
     [java]
--------------------------------------------------------------------------------

     [java] 2010-04-14 19:09:06,310 (http-0.0.0.0-8443-6) [
 TransactionUtil.java:339:INFO ] [TransactionUtil.rollback] transaction
rolled back
     [java] 2010-04-14 19:09:06,311 (http-0.0.0.0-8443-6) [
 TransactionUtil.java:269:WARN ] [TransactionUtil.commit] Not committing
transaction, status is No Transaction (6)
     [java] 2010-04-14 19:09:06,311 (http-0.0.0.0-8443-6) [
RequestHandler.java:638:INFO ] Ran Event
[java:org.ofbiz.webapp.event.CoreEvents#scheduleService] from [request],
result is [error]
     [java] 2010-04-14 19:09:06,311 (http-0.0.0.0-8443-6) [
RequestHandler.java:421:ERROR] Request scheduleService caused an error with
the following message: <li>Service dispatcher threw an exceptionType check
failed for field [testGroovy.successMessage]; expected type is [String];
actual type is [org.codehaus.groovy.runtime.GStringImpl]
     [java] 2010-04-14 19:09:06,311 (http-0.0.0.0-8443-6) [
RequestHandler.java:742:INFO ] Rendering View [scheduleJob],
sessionId=C77BBDE748AB5463B16542786890B057.jvm1
     [java] 2010-04-14 19:09:06,664 (http-0.0.0.0-8443-6) [
ServerHitBin.java:627:INFO ] Visit delegatorName=default, ServerHitBin
delegatorName=default
     [java] 2010-04-14 19:09:06,679 (http-0.0.0.0-8443-6) [
ControlServlet.java:327:INFO ] [[[scheduleService] Request Done-
total:0.43,since last([scheduleService]...):0.43]]


Regards,
Kranti Agrawal
Student, IIIT Bangalore
krantiagrawal.blogspot.com


On Wed, Apr 14, 2010 at 5:59 PM, Kranti Agrawal <kr...@gmail.com>wrote:

> Hi Jacques,
> I was looking for a service. I found one in
> /framework/common/servicedef/services_test.xml.
> I am using a similar service and not able to get back the OUT parameter
> from it.
> Could you please throw some light on it?
>
> Regards,
> Kranti Agrawal
> Student, IIIT Bangalore
> krantiagrawal.blogspot.com
>
>
> On Wed, Apr 14, 2010 at 5:16 PM, Jacques Le Roux <
> jacques.le.roux@les7arts.com> wrote:
>
>> Note that an event is not a service though...
>>
>> Jacques
>>
>>
>> Brajesh Patel wrote:
>>
>>> Hi Kranti,
>>> hope following code will help you.
>>>
>>> <event type="groovy" path="component://
>>> manufacturing/webapp/manufacturing/jobshopmgt/"
>>> invoke="ShowProductionRun.groovy"/>
>>>
>>> Thanks and Regards
>>> Brajesh Patel
>>>
>>> Kranti Agrawal wrote:
>>>
>>>> Hi,
>>>>
>>>> Can I call a groovy file as a service?
>>>>
>>>> Regards,
>>>> Kranti Agrawal
>>>> Student, IIIT Bangalore
>>>> krantiagrawal.blogspot.com
>>>>
>>>
>>
>

Re: Groovy file as a service

Posted by Kranti Agrawal <kr...@gmail.com>.
Hi Jacques,
I was looking for a service. I found one in
/framework/common/servicedef/services_test.xml.
I am using a similar service and not able to get back the OUT parameter from
it.
Could you please throw some light on it?

Regards,
Kranti Agrawal
Student, IIIT Bangalore
krantiagrawal.blogspot.com


On Wed, Apr 14, 2010 at 5:16 PM, Jacques Le Roux <
jacques.le.roux@les7arts.com> wrote:

> Note that an event is not a service though...
>
> Jacques
>
>
> Brajesh Patel wrote:
>
>> Hi Kranti,
>> hope following code will help you.
>>
>> <event type="groovy" path="component://
>> manufacturing/webapp/manufacturing/jobshopmgt/"
>> invoke="ShowProductionRun.groovy"/>
>>
>> Thanks and Regards
>> Brajesh Patel
>>
>> Kranti Agrawal wrote:
>>
>>> Hi,
>>>
>>> Can I call a groovy file as a service?
>>>
>>> Regards,
>>> Kranti Agrawal
>>> Student, IIIT Bangalore
>>> krantiagrawal.blogspot.com
>>>
>>
>

Re: Groovy file as a service

Posted by Jacques Le Roux <ja...@les7arts.com>.
Note that an event is not a service though...

Jacques

Brajesh Patel wrote:
> Hi Kranti,
> hope following code will help you.
> 
> <event type="groovy" path="component://
> manufacturing/webapp/manufacturing/jobshopmgt/"
> invoke="ShowProductionRun.groovy"/>
> 
> Thanks and Regards
> Brajesh Patel
> 
> Kranti Agrawal wrote:
>> Hi,
>> 
>> Can I call a groovy file as a service?
>> 
>> Regards,
>> Kranti Agrawal
>> Student, IIIT Bangalore
>> krantiagrawal.blogspot.com


Re: Groovy file as a service

Posted by Brajesh Patel <br...@hotwaxmedia.com>.
Hi Kranti,
hope following code will help you.

<event type="groovy" path="component://
manufacturing/webapp/manufacturing/jobshopmgt/" 
invoke="ShowProductionRun.groovy"/>

Thanks and Regards
Brajesh Patel

Kranti Agrawal wrote:
> Hi,
>
> Can I call a groovy file as a service?
>
> Regards,
> Kranti Agrawal
> Student, IIIT Bangalore
> krantiagrawal.blogspot.com
>
>