[1.3.0] Startup exception when using await(promise) in controller

73 views
Skip to first unread message

Robert Lincoln

unread,
Feb 26, 2015, 10:18:02 PM2/26/15
to play-fr...@googlegroups.com
I have a controller method which receives a promise from a static utility method and then calls await(promise).  Whenever I add the line to await the promise I get the exception below.  The method returning the promise is a static utility method returning a Promise<HttpResponse> from a play web service request getAsync() call. Not sure if I'm doing anything wrong here or if there is some dependency that needs to be overridden causing the problem.  Tried this one java 6 and 7 and got the same results.


play.exceptions.UnexpectedException: Unexpected Error

at play.Invoker$Invocation.onException(Invoker.java:244)

at play.Invoker$Invocation.run(Invoker.java:306)

at Invocation.HTTP Request(Play!)

Caused by: java.lang.IncompatibleClassChangeError: org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter

at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:74)

at org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer.transform(AsmClassTransformer.java:41)

at play.classloading.enhancers.ContinuationEnhancer.enhanceThisClass(ContinuationEnhancer.java:76)

at play.CorePlugin.enhance(CorePlugin.java:297)

at play.plugins.PluginCollection.enhance(PluginCollection.java:551)

at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:239)

at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)

at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:82)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Scott Rippee

unread,
Mar 3, 2015, 1:00:17 AM3/3/15
to play-fr...@googlegroups.com
await is called from the promise?  You are doing something like HttpResponse resp = await(WS.url(...).get().now) but with the WS.url(...).get() part done in the util?

Robert Lincoln

unread,
Mar 3, 2015, 7:53:30 AM3/3/15
to play-fr...@googlegroups.com
So I discovered my issue with a conflicting library.  I had an older version of apache-tika as a dependency which required asm-3.1.  Even the newer tika versions seem to use 4.1 while play 1.3.0 uses 5.0.3 (the latest).  I was able to get the app to startup by specifically excluding the asm dependencies from tika in my dependencies.yml but still had some odd behavior.  Removing them entirely seems to have helped, but now I have a new question.

(fyi I've posted this below on the play-framework-dev group but wanted to also update this post incase anyone else runs into these issues)

So I realize calling await(promise) makes a second request where request.isNew = false.  However, should that second request also be triggering controller methods annotated with @Before again?  It seems like if it is just pausing the method that logic wouldn't need to be repeated.  Also for some reason when the @Before method is called the declared parameters for it are duplicated and cause it (in my case) to fail.  It seems that at least the parameters should stay the same?  I can get around this by checking for request.isNew in each annotated method but that seems unnecessary?



for example calling someTestMethod() below would render the following log output if clientId=test.  thoughts?

clientId is test
clientId is test, test


public class Application extends Controller {

      @Before(priority=1)
      public static void checkClientId(String clientId) {
             Logger.info("clientId is %s", clientId);
       }


       public static void someTestMethod() {
                 Promise<HttpResponse> promise = WS.url("http://www.google.com").getAsync();
                 await(promise):
                 // do something

Scott Rippee

unread,
Mar 3, 2015, 12:46:01 PM3/3/15
to play-fr...@googlegroups.com
I've always found that behavior strange as well.  I've assumed it was a quirk of the framework or there incase the action needs to re-establish state that may have been lost when executing the await (I can't think of anything though).

Thanks for the heads up on the isNew.  I've added it to my Before annotations.



--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/t6FO09UvcMg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott Rippee

unread,
Mar 3, 2015, 12:57:12 PM3/3/15
to play-fr...@googlegroups.com
I just encountered a case where I need the default @Before behavior.

I have a @Before that adds a JPA session filter (Session...enableFilter) to automatically constrain some requests.  If this doesn't execute when returning from a promise the DB queries are not properly constrained.
Reply all
Reply to author
Forward
0 new messages