#1039 confirmed
Ricki Sickenger

'InvocationTargetException occured : null' - Wierd behaviour

Reported by Ricki Sickenger | August 16th, 2011 @ 01:49 PM | in 1.4.x

Framework version: 1.2.2
Platform you're using: Windows XP SP3

Reproduction steps: Open index page of provided controller class to provoke the error.

Details: Continuations implementation causes InvocationTargetException. The submitted class reliably provokes the InvocationTargetException. If I remove the variable "removeMeAndItWorks" then the index() method will render "works?" correctly. Also other bits of the index() method can be removed and it will work.

The offending class looks like this. The exception is thrown in index():

package controllers;

import play.jobs.Job;
import play.libs.F;
import play.mvc.Controller;
import java.util.*;

public class BugTester extends Controller

    public static <V> V execJob(Job<V> job) {
        F.Promise<V> promise = job.now();

        try {
            return promise.get();
        } catch (Exception ex) {
            throw new RuntimeException(ex);

    public static void index() {

        List<String> ListOfStrings = new ArrayList<String>();
        for (String s : ListOfStrings)
        int removeMeAndItWorks = 1;
        ListOfStrings = execJob(new MyJob());
        for (String s : ListOfStrings)
        execJob(new MyJob());


    public static class MyJob extends Job<List<String>> {
        public List<String> doJobWithResult() throws Exception {

            List<String> docs = new ArrayList<String>();
            return docs;

This is the exception from the play-log:

Execution exception
InvocationTargetException occured : null

    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:230)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.reflect.InvocationTargetException
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:475)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)
    ... 1 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Iterator
    at controllers.BugTester.index(BugTester.java)
    ... 6 more

Speculation: Seems like something gets out of synch, so play retreives the wrong class from storage when continuing the continuation?

Note: This is also confirmed on the latest (per 16th of August / commit: 2d05bf8471807de8c7c6) master on GitHub


Comments and changes to this ticket

  • Morten Kjetland

    Morten Kjetland August 23rd, 2011 @ 11:15 AM

    • State changed from “new” to “confirmed”
    • Assigned user set to “Morten Kjetland”
    • Milestone set to 1.3
    • Milestone order changed from “731” to “0”
  • Richard Wise

    Richard Wise November 11th, 2011 @ 10:44 AM

    • Milestone order changed from “23” to “0”

    If it helps, I have isolated another (similar) reproduction class. It seems to share the commonality of futures, collections and 2 foreach loops.

    package controllers;

    import play.mvc.Controller;

    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.concurrent.Callable;
    import java.util.concurrent.Executors;
    import java.util.concurrent.Future;

    public class TestController extends Controller {

    private static <T> Future<T> test1_callback(final Callable<T> ctr) {
        return Executors.newSingleThreadExecutor().submit(new Callable<T>() {
            public T call() throws Exception {
                return ctr.call();
    public static void test1() {
        String[] test = new String[1]; // Does not reproduce with List<String>
        test[0] = "A";
        List<Future<List<String>>> futures = new LinkedList<Future<List<String>>>();
        for (String s1 : test) // Does not reproduce with for loop or loop unravelling
            futures.add(TestController.<List<String>>test1_callback(new Callable<List<String>>() { // Reproduces with Map<String> as well
                public List<String> call() throws Exception {
                    return new ArrayList<String>();
        List<List<String>> data = new LinkedList<List<String>>();
        for (Future<List<String>> future : futures) {
            List<String> laneData = await(future); // Does not reproduce without local variable


    This throws:

    Internal Server Error (500) for request GET /TestController/test1

    Execution exception
    InvocationTargetException occured : null


    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
    at Invocation.HTTP Request(Play!)

    Caused by: java.lang.reflect.InvocationTargetException

    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
    ... 1 more

    Caused by: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.util.List

    at controllers.TestController.test1(TestController.java)
    ... 6 more
  • Morten Kjetland

    Morten Kjetland December 13th, 2011 @ 10:48 PM

    • Milestone changed from 1.3 to 1.2.5
    • Milestone order changed from “3” to “0”

    This still not works in 1.2.x or master

  • Morten Kjetland
  • Nicolas Leroux

    Nicolas Leroux May 29th, 2012 @ 10:39 AM

    • Milestone set to 1.3
    • Milestone order changed from “1” to “0”
  • notalifeform (at gmail)

    notalifeform (at gmail) April 21st, 2014 @ 08:02 PM

    • Milestone changed from 1.3 to 1.4.x
  • Gad Krumholz

    Gad Krumholz September 18th, 2014 @ 04:18 PM

    This still happens with 1.3.x branch.

    Execution exception
    InvocationTargetException occured : null

    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:238) at Invocation.HTTP Request(Play!) Caused by: java.lang.reflect.InvocationTargetException
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:556) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:507) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:483) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:160) ... 1 more Caused by: java.lang.ClassCastException: org.tdl.vireo.model.jpa.JpaNamedSearchFilterImpl cannot be cast to org.tdl.vireo.search.ActiveSearchFilter
    at controllers.FilterTab.batchExport(FilterTab.java) ... 6 more

    Any chance there will be a patch to fix this soon?

  • Hard Work

    Hard Work November 26th, 2018 @ 09:42 AM

    If you are in the search for methods to How do i clear cache in windows 10 so you need not to go anywhere as here we are having one of the best portal where you will able to find out all beneficial information by which you can smoothly get over it. For having beneficial information have a visit for once.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2>Play framework</h2>

Play makes it easier to build Web applications with Java. It is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Learn more on the <a href="http://www.playframework.org">http://www.playframework.org</a> website.<br><br>

<h2>Source code is hosted on github</h2>Check out our repository at <a href="http://github.com/playframework/play">http://github.com/playframework/play</a><br><br>

<h2>Contributing, creating a patch</h2> Please read the <a href="http://play.lighthouseapp.com/projects/57987/contributor-guide">contributor guide</a><br><br>

<h2>Reporting Security Vulnerabilities</h2> Since all bug reports are public, please report any security vulnerability directly to <em>guillaume dot bort at gmail dot com</em>.<br><br>

<h2>Creating a bug report</h2> Bug reports are incredibly helpful, so take time to report bugs and request features in our ticket tracker. We’re always grateful for patches to Play’s code. Indeed, bug reports with attached patches will get fixed far quickly than those without any.<br><br>

Please include as much relevant information as possible including the exact framework version you're using and a code snippet that reproduces the problem.<br><br>

Don't have too much expectations. Unless the bug is really a serious "everything is broken" thing, you're creating a ticket to start a discussion. Having a patch (or a branch on Github we can pull from) is better, but then again we'll only pull high quality branches that make sense to be in the core of Play.