Error in joget V5 code; it was working fine in V4

Confluence User - 14 Jun, 2016

 

Hi,
Following Code is not working in V5.

FormDefinitionDao formDefinitionDao = (FormDefinitionDao) AppUtil.getApplicationContext().getBean("formDefinitionDao");
FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService");

AppDefinition appDef = appService.getAppDefinition(appId, appVersion.toString());
FormDefinition formDef = formDefinitionDao.loadById(formId, appDef);
if (formDef != null) {
    //create the form
    Form form = (Form) formService.createElementFromJson(formDef.getJson(), true);
}
With Following Exception. Do we have any change in the class.
    
ERROR 14 Jun 2016 12:37:20 org.joget.apps.app.web.JsonResponseFilter  - java.lang.IncompatibleClassChangeError: Found interface org.joget.apps.form.service.FormService, but class was expected
java.lang.IncompatibleClassChangeError: Found interface org.joget.apps.form.service.FormService, but class was expected
        at webservice.JsonApiPlugin.getFormImageFields(JsonApiPlugin.java:395)
Try to do it this way but still failing
    FormService formService = (FormServiceImpl) AppUtil.getApplicationContext().getBean("formService");
forms;plugins

2


14 Jun, 2016
confluenceUser
confluenceUser

Hi,

In v5, FormService had been changed to an interface with FormServiceImpl as its implementation. 

I can't replicate your issue. From the error you posted, it could be you are building your plugin with v4 source code?

The following still the correct way to retrieve FormService.

FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService");
14 Jun, 2016
confluenceUser
confluenceUser

I am able to resolve the issue by compiling the Code with V5 dependency

 

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print