[groovy-user] Using groovy shell in multi-threaded environment

380 views
Skip to first unread message

Lee Morris

unread,
May 8, 2014, 10:39:13 AM5/8/14
to us...@groovy.codehaus.org
Hi all

I'm trying to use callbacks in some embedded groovy code but I'm running into issues whereby either the bindings or returned objects seem to be overwritten by other threads doing the same thing with other values.  I've tried using groovy via JSR-223 interface and using GroovyShell directly, both doing the same thing.  I know bindings are not thread safe, but wondering if anyone has achieved this somehow?

Cheers
Lee

Jochen Theodorou

unread,
May 9, 2014, 2:21:09 PM5/9/14
to us...@groovy.codehaus.org
well, you give not really much information, but maybe using thread local
bindings would work.

bye blackdrag

--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Cédric Champeau

unread,
May 9, 2014, 2:51:16 PM5/9/14
to us...@groovy.codehaus.org

Hi!

Take a look at http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/#_groovy_integration_mechanisms

There is a section that explains how to work around the thread safety issue.

Nelson, Erick [HDS]

unread,
May 9, 2014, 3:59:31 PM5/9/14
to us...@groovy.codehaus.org

Groovy 2.3.0 Java 6

 

Since I’ve upgraded my dev environment to 2.3.0 I’ve noticed that the groovy classloader via @Grab is much more restrictive

Here is an example for a problem I’m having with smtp

 

When I get mailapi.jar and smtp.jar from a  Grab I now get these errors.

 

15:45:53,132 ERROR SMTPMailer - javax.mail.MessagingException: IOException while sending message;

  nested exception is:

        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

        boundary="----=_Part_0_2145764153.1399664752712"

 

Before 2.3.0 the classes resolved correctly and I did not get these errors

 

I can fix this by …

1.       adding @GrabConfig(systemClassLoader=true)

2.       throwing mailapi.jar and smtp.jar into ~/.groovy/lib  .

 

This is not just restricted to smtp. I’m also getting the problem using the wink rest client

 

What has changed with the @Grab classloader?

Nelson, Erick [HDS]

unread,
May 9, 2014, 5:05:41 PM5/9/14
to us...@groovy.codehaus.org

Edits…

 

From: Nelson, Erick [HDS]
Sent: Friday, May 09, 2014 1:00 PM
To: us...@groovy.codehaus.org
Subject: @Grab classloader seems different in 2.3.0

 

Groovy 2.3.0 Java 6

 

Since I’ve upgraded my dev environment to 2.3.0 I’ve noticed that the groovy classloader via @Grab is much more restrictive

Here is an example for a problem I’m having with smtp

 

When I get mailapi.jar and smtp.jar from a  Grab I now get these errors.

 

15:45:53,132 ERROR SMTPMailer - javax.mail.MessagingException: IOException while sending message;

  nested exception is:

        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

        boundary="----=_Part_0_2145764153.1399664752712"

 

Before 2.3.0 the classes resolved correctly and I did not get these errors

 

I can fix this by …

1.       adding @GrabConfig(systemClassLoader=true)

 

or

Guillaume Laforge

unread,
May 9, 2014, 5:15:16 PM5/9/14
to Groovy User
Hello Erick,

A ticket along the same lines has been open here:

Might be related.

We're going to investigate that.

Guillaume
--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

Lee Morris

unread,
May 12, 2014, 3:28:29 AM5/12/14
to us...@groovy.codehaus.org
Great thanks! Class Loader looks to be the way to go for me.
Reply all
Reply to author
Forward
0 new messages