java - Play Framework update from 2.1 to 2.2: SimpleResult not working - compile error -


we upgrading our project play framework 2.1 2.2. new results structure not working, however. have changed return type result simpleresult in 'call' function in global.java file:

public class global extends globalsettings {  @override   public void onstart(application app) {     logger.info("global on start event called");     logger.info("admin application has started");     // schedule duration application.conf     long scheduleduration = play.application().configuration().getlong("schedule-duration");     logger.debug("scheduler duration :"+ scheduleduration) ;     logger.debug("calling schedule service");     cancellable response1 = scheduleservice.scheduleit(scheduleduration);      // schedule duration worker task expiration scheduler application.conf     long workertaskexpirationduration = play.application().configuration().getlong("worker-task-scheduler-interval");     cancellable response2 = taskexpirationscheduleservice.schedule(workertaskexpirationduration);     /******************fix cea-3440*************************************/     long workeremailduration = play.application().configuration().getlong("worker-email-scheduler-interval");     cancellable response3 = workeremailscheduleservice.schedule(workeremailduration);      /******************fix cea-3440*************************************/   }      @override   public void onstop(application app) {     logger.info("global on stop event called");     logger.info("application shutdown started..stopping sync service actor.");     actorref syncactor = akka.system().actorfor("/user/syncserviceactor");     akka.system().stop(syncactor);     logger.info("application shutdown started..stopping worker task expiration actor.");     actorref taskexpirationactor = akka.system().actorfor("/user/workertaskexpireactor");     akka.system().stop(taskexpirationactor);      /******************fix cea-3440*************************************/     logger.info("application shutdown started..stopping worker email actor.");     actorref workertaskexpirationduration = akka.system().actorfor("/user/workertaskexpirationduration");     akka.system().stop(workertaskexpirationduration);      /******************fix cea-3440*************************************/     // shut down system     akka.system().shutdown();     logger.info("actor stopped , akka system shutdown successfully..");   }       // cors   private class actionwrapper extends action.simple {   public actionwrapper(action<?> action) {   this.delegate = action;   }    @override   public promise<simpleresult> call(http.context ctx) throws java.lang.throwable {        http.response response = ctx.response();        response.setheader("access-control-allow-origin", "*");        response.setheader("access-control-allow-methods", "post, get, options, put, delete");         response.setheader("allow", "*");         response.setheader("access-control-max-age", "3600");         response.setheader("access-control-allow-headers", "origin, x-requested-with, content-type, accept, referer, user-agent");         response.setheader("access-control-allow-credentials", "true");         promise<simpleresult> result = (promise<simpleresult>) this.delegate.call(ctx);        return result;   }   }    @override   public action<?> onrequest(http.request request, java.lang.reflect.method actionmethod) {    return new actionwrapper(super.onrequest(request, actionmethod));   }  } 

this gives following error when compiled on browser:

compiled play project

i have tried resolve looking @ similar stackoverflow questions not resolve issue. relatively new play please elaborate in solution.

also, using eclipse ide following error:

the return type incompatible action.call(http.context)

thanks.

just replace simpleresult result ?

here example of action

public f.promise<result> call( http.context context ) throws throwable {      if ( !authorized ) {         return f.promise.promise(() -> unauthorized());     }      // execute action     return delegate.call( context ); } 

here global.java

@override public f.promise<result> onerror(http.requestheader requestheader, throwable throwable) {     if(play.isdev()){         return super.onerror(requestheader, throwable);     }     logger.error("error : ", throwable);     return f.promise.pure(controller.ok(views.html.error.render(requestheader.uri()))); } 

you should read https://www.playframework.com/documentation/2.2.0/migration22#new-results-structure-in-java


Comments