Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » REST Client: fetching data and populating a table(fetching data from a public API and using the results to populate a table)
REST Client: fetching data and populating a table [message #1839291] Thu, 18 March 2021 20:14 Go to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Hello everyone,

I want to fetch data from a public API and use it to first populate a table and then fill a form when a row in the table is clicked. My problem is I cannot put all the pieces together in order.

The full path to the public data source on the Open Data Paris website is
https://opendata.paris.fr/api/records/1.0/search/?dataset=liste_des_prenoms
and it fetches 10 records (in JSON format) with the following fields: nombre, annee, nombre_total_cumule, sexe, prenoms

Here is what I've done so far:

a) My EntityDo
public class FirstNameEntityDo extends DoEntity {

  @AttributeName("nombre")
  public DoValue<String> number() {
    return doValue("nombre");
  }

  @AttributeName("annee")
  public DoValue<String> year() {
    return doValue("annee");
  }

  @AttributeName("nombre_total_cumule")
  public DoValue<String> cumulativeTotal() {
    return doValue("nombre_total_cumule");
  }

  @AttributeName("sexe")
  public DoValue<String> sex() {
    return doValue("sexe");
  }

  @AttributeName("prenoms")
  public DoValue<String> firstName() {
    return doValue("prenoms");
  }

  public FirstNameEntityDo withName(String string) {
    // TODO Auto-generated method stub
    return null;
  }
}


b) The RestClientHelper
public class FirstNameRestClientHelper extends AbstractRestClientHelper {

  @Override
  protected String getBaseUri() {
    return "https://opendata.paris.fr/api/";
  }

  @Override
  protected RuntimeException transformException(RuntimeException e, Response response) {
    if (response != null && response.hasEntity()) {
      ErrorDo error = response.readEntity(ErrorResponse.class).getError();
      throw new VetoException(error.getMessage()).withTitle(error.getTitle());
    }
    return e;
  }
}


c) The ResourceClient
public class FirstNameResourceClient implements IRestResourceClient {
  // example full path
  // "https://opendata.paris.fr/api/records/1.0/search/?dataset=liste_des_prenoms&refine.prenoms=Anne-Sophie"
  protected static final String RESOURCE_PATH = "/records/1.0/search/";

  protected FirstNameRestClientHelper helper() {
    return BEANS.get(FirstNameRestClientHelper.class);
  }

  // Get a list of firstnames
  public FirstNameEntityDo getFirstNameEntity() {
    WebTarget target = helper().target(RESOURCE_PATH).queryParam("dataset", "liste_des_prenoms");
    return target.request().accept(MediaType.APPLICATION_JSON).get(FirstNameEntityDo.class);
  }

  // Get a particular firstname e.g "Anne-Sophie" from a list of firstnames
  public FirstNameEntityDo getFirstNameEntity(String firstname) {
    WebTarget target = helper().target(RESOURCE_PATH).queryParam("dataset", "liste_des_prenoms")
        .queryParam("refine.prenoms", firstname);
    return target.request().accept(MediaType.APPLICATION_JSON).get(FirstNameEntityDo.class);
  }

  public FirstNameEntityDo getFirstNameEntityCustomExceptionHandling() {
    WebTarget target = helper().target(RESOURCE_PATH, this::transformCustomException)
        .queryParam("dataset", "liste_des_prenoms");
    return target.request().accept(MediaType.APPLICATION_JSON).get(FirstNameEntityDo.class);
  }

  protected RuntimeException transformCustomException(RuntimeException e, Response r) {
    if (r != null && r.hasEntity() && MediaType.TEXT_PLAIN_TYPE.equals(r.getMediaType())) {
      String message = r.readEntity(String.class);
      throw new VetoException(message);
    }
    return e;
  }
}


d) Finally in the FirstNamePage.java class, I have the following
  @Override
  protected void execLoadData(SearchFilter filter) {
    importPageData(BEANS.get(IFirstNameService.class).getFirstNameTableData(filter));     <--- THIS IS NOT RELEVANT FOR REST CALLS
  }


I know that the execLoadData is incorrect but I do not know how to correct it.

I want to fill the FirstNameTable immediately after I click on the tile. However I need some help with tying all the loose ends I posted above together.

Thanks a lot for your kind assistance.

Cheers,

JD

[Updated on: Fri, 19 March 2021 09:39]

Report message to a moderator

Re: REST Client: fetching data and populating a table [message #1839307 is a reply to message #1839291] Fri, 19 March 2021 07:58 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hi JD

You say you want to click on a tile, so I assume you have a form which has a tile-grid with tiles. Is that correct?

The AbstractTileGrid has a method #execTileClick(T tile, MouseButton mouseButton) which handles a click on a tile. This is where you would call your REST service.

When you work with REST services you don't necessarily need to work with the generated FormDatas or TableDatas. These classes are intended for the classic Scout approach, where the Scout UI sends form-data to the Scout backend. In cases where your UI directly makes a REST call you don't need them.

Btw: I don't know the REST service you call, but to me it looks like the call should return a _list_ of first names, and not only a single first-name entity.

@Override
protected void execTileClick(JdTile tile, MouseButton mouseButton) {
  // Optional: maybe you need some data from the clicked tile to make a specific REST call?
  // Object lookupId = tile.getLookupId();
	List<FirstNamesEntityDo> firstNames = BEANS.get(IFirstNameService.class).getFirstNames(lookupId);
	FirstNameTable firstNameTable = getFirstNameTable();
	firstNameTable.deleteAllRows();
	firstNames.stream().forEach(
	    firstName -> addFirstNameTableRow(firstNameTable, firstName));
}

protected List<ITableRow> addFirstNameTableRow(FirstNameTable firstNameTable, FirstNameEntityDo firstName) {
	ITableRow row = firstNameTable.addRow();
	firstNameTable.getNombreColumn().setValue(row, firstName.getNombre());
	firstNameTable.getSexeColumn().setValue(row, firstName.getSexe());
	//...
}


Most likely this will not compile, as I hacked everything into the forum editor here, but it should give you an idea of how to proceed.

Cheers,
André


Eclipse Scout Homepage | Documentation | GitHub
Re: REST Client: fetching data and populating a table [message #1839698 is a reply to message #1839307] Thu, 25 March 2021 23:28 Go to previous messageGo to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Hello there Andre,

Thanks a lot for your suggestions. Unfortunately, I'm still having problems with retrieving the data. This is what my code looks like now:

a) FirstNameResourceClient for fetching the data
public class FirstNameResourceClient implements IRestResourceClient {
  // example full path
  // "https://opendata.paris.fr/api/records/1.0/search/?dataset=liste_des_prenoms&refine.prenoms=Anne-Sophie"
  protected static final String RESOURCE_PATH = "/records/1.0/search/";

  protected FirstNameRestClientHelper helper() {
    return BEANS.get(FirstNameRestClientHelper.class);
  }

  // Get a list of firstnames
  public List<FirstNameEntityDo> getFirstNameEntity() {
    WebTarget target = helper().target(RESOURCE_PATH).queryParam("dataset", "liste_des_prenoms");
    return (List<FirstNameEntityDo>) target.request().accept(MediaType.APPLICATION_JSON)
        .get(FirstNameEntityDo.class);
  }

  // Get a particular firstname from a list of firstnames
  public List<FirstNameEntityDo> getFirstNameEntity(String firstname) {
    WebTarget target = helper().target(RESOURCE_PATH).queryParam("dataset", "liste_des_prenoms")
        .queryParam("refine.prenoms", firstname);
    return (List<FirstNameEntityDo>) target.request().accept(MediaType.APPLICATION_JSON)
        .get(FirstNameEntityDo.class);
  }

  public FirstNameEntityDo getFirstNameEntityCustomExceptionHandling() {
    WebTarget target = helper().target(RESOURCE_PATH, this::transformCustomException)
        .queryParam("dataset", "liste_des_prenoms");
    return target.request().accept(MediaType.APPLICATION_JSON).get(FirstNameEntityDo.class);
  }

  protected RuntimeException transformCustomException(RuntimeException e, Response r) {
    if (r != null && r.hasEntity() && MediaType.TEXT_PLAIN_TYPE.equals(r.getMediaType())) {
      String message = r.readEntity(String.class);
      throw new VetoException(message);
    }
    return e;
  }
}


b) FirstNamePage - the execLoadData() method fetches the data from the server
@Data(FirstNameTablePageData.class)
public class FirstNamePage extends AbstractPageWithTable<Table> {

 // Fetch the list of names from the REST server
  @Override
  protected void execLoadData(SearchFilter filter) {
    List<FirstNameEntityDo> firstNames =
        BEANS.get(FirstNameResourceClient.class).getFirstNameEntity();
    // FirstNameTable firstNameTable = FirstNameTable.getFirstNameTable();
    // firstNameTable.deleteAllRows();
    // firstNames.stream().forEach(firstName -> addFirstNameTableRow(firstNameTable, firstName));
  }

  @Override
  protected String getConfiguredTitle() {
    // TODO [jide] verify translation
    return TEXTS.get("FirstName");
  }

  @Override
  protected boolean getConfiguredLeaf() {
    return true;
  }

  public class FirstNameTable extends AbstractTable {
    // container class to hold columns and other elements for this table page

    public FirstNameTable getFirstNameTable() {
      return new FirstNameTable();
    }

    // // This action gets executed when the user presses Enter on a table row or double clicks on a
    // // table row
    @Override
    protected Class<? extends IMenu> getConfiguredDefaultMenu() {
      return EditMenu.class;
    }

    public SexColumn getSexColumn() {
      return getColumnSet().getColumnByClass(SexColumn.class);
    }

    public YearColumn getYearColumn() {
      return getColumnSet().getColumnByClass(YearColumn.class);
    }

    public FirstNameColumn getFirstNameColumn() {
      return getColumnSet().getColumnByClass(FirstNameColumn.class);
    }

    public CumulativeTotalPerYearColumn getCumulativeTotalPerYearColumn() {
      return getColumnSet().getColumnByClass(CumulativeTotalPerYearColumn.class);
    }

    public NumberOfDeclaredFirstNamesColumn getNumberOfDeclaredFirstNamesColumn() {
      return getColumnSet().getColumnByClass(NumberOfDeclaredFirstNamesColumn.class);
    }

    // Test fetching JSON data
    @Order(500)
    public class SearchMenu extends AbstractSimpleSearchMenu {
      @Override
      protected void execAction() {
         List<FirstNameEntityDo> firstNames =
            BEANS.get(FirstNameResourceClient.class).getFirstNameEntity();
        System.out.println(firstNames);                         //  <---- CRUDE DEBUGGING 
      }
    }

    // Three menu items: New, Edit & Delete will be displayed for rows in the table
    @Order(1000)
    public class NewMenu extends AbstractNewMenu {
      @Override
      protected String getConfiguredText() {
        return TEXTS.get("New");
      }

      // Including TableMenuType.EmptySpace in the return value activates the "New" menu even when
      // no row is selected.
      @Override
      protected Set<? extends IMenuType> getConfiguredMenuTypes() {
        return CollectionUtility.<IMenuType>hashSet(TableMenuType.EmptySpace,
            TableMenuType.SingleSelection);
      }

      @Override
      protected void execAction() {
        FirstNameForm form = new FirstNameForm();
        form.addFormListener(new FirstNameFormListener());
        // start the form using its new handler
        form.startNew();
      }
    }

    @Order(2000)
    public class EditMenu extends AbstractEditMenu {
      @Override
      protected void execAction() {
        FirstNameForm form = new FirstNameForm();
        // form.setPartnerContactId(getContactIdColumn().getSelectedValue());
        form.addFormListener(new FirstNameFormListener());
        // start the form using its modify handler
        form.startModify();
      }
    }

    @Order(3000)
    public class DeleteMenu extends AbstractDeleteMenu {
    }

    private class FirstNameFormListener implements FormListener {
      @Override
      public void formChanged(FormEvent e) {
        // reload page to reflect new/changed data after saving any changes
        if (FormEvent.TYPE_CLOSED == e.getType() && e.getForm().isFormStored()) {
          reloadPage();
        }
      }
    }

    @Order(1000)
    public class NumberOfDeclaredFirstNamesColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("NumberOfDeclaredFirstNames");
      }

      @Override
      protected int getConfiguredWidth() {
        return 200;
      }
    }

    @Order(2000)
    public class YearColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("Year");
      }

      @Override
      protected int getConfiguredWidth() {
        return 100;
      }
    }

    @Order(3000)
    public class CumulativeTotalPerYearColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("CumulativeTotalPerYear");
      }

      @Override
      protected int getConfiguredWidth() {
        return 250;
      }
    }

    @Order(4000)
    public class SexColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("Sex");
      }

      @Override
      protected int getConfiguredWidth() {
        return 100;
      }
    }

    @Order(5000)
    public class FirstNameColumn extends AbstractStringColumn {
      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("FirstName");
      }

      @Override
      protected int getConfiguredWidth() {
        return 100;
      }
    }

  }
}


The problem is whenever I open the FirstNamePage, I get an error message shown below:

2021-03-25 23:42:57,773 ERROR [scout-model-thread-25 Processing JSON request] org.eclipse.scout.rt.platform.exception.ExceptionHandler.handlePlatformException(ExceptionHandler.java:124) -  - MDC[principal=jd, uiSession=1:1t1heup7o5n28vf4cprlg866chbusorsn438ucnch3effuf2ub0h, scoutSession=1b4g3igm04no1cogohs62v02isa3kkme1h7ou3b8clbk0j1ff7i7, jobName=Processing JSON request, cid=ZW2vM5rE6QJ/4]
org.eclipse.scout.rt.platform.util.Assertions$AssertionException: [b]Assertion error: no instance found for query: class [/b]org.eclipse.scout.apps.yougenie.client.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper [user=jd, ui.event=action, ui.adapter=Menu[id=28, modelClass=org.eclipse.scout.apps.yougenie.client.mocksamples.opendataparis.firstname.FirstNamePage$Table$SearchMenu, parentId=19]]
	at org.eclipse.scout.rt.platform.util.Assertions.fail(Assertions.java:621)
	at org.eclipse.scout.rt.platform.util.Assertions.assertNotNull(Assertions.java:87)
	at org.eclipse.scout.rt.platform.BEANS.get(BEANS.java:42)
	at org.eclipse.scout.apps.yougenie.client.rest.mocksamples.opendataparis.firstname.FirstNameResourceClient.helper(FirstNameResourceClient.java:18)
	at org.eclipse.scout.apps.yougenie.client.rest.mocksamples.opendataparis.firstname.FirstNameResourceClient.getFirstNameEntity(FirstNameResourceClient.java:37)
	at org.eclipse.scout.apps.yougenie.client.mocksamples.opendataparis.firstname.FirstNamePage$Table$SearchMenu.execAction(FirstNamePage.java:97)
	at org.eclipse.scout.rt.client.ui.action.AbstractAction$LocalActionExtension.execAction(AbstractAction.java:656)
	at org.eclipse.scout.rt.client.extension.ui.action.ActionChains$ActionActionChain$1.callMethod(ActionChains.java:57)
	at org.eclipse.scout.rt.client.extension.ui.action.ActionChains$ActionActionChain$1.callMethod(ActionChains.java:1)
	at org.eclipse.scout.rt.shared.extension.AbstractExtensionChain.callChain(AbstractExtensionChain.java:113)
	at org.eclipse.scout.rt.client.extension.ui.action.ActionChains$ActionActionChain.execAction(ActionChains.java:60)
	at org.eclipse.scout.rt.client.ui.action.AbstractAction.interceptAction(AbstractAction.java:680)
	at org.eclipse.scout.rt.client.ui.action.AbstractAction.doActionInternal(AbstractAction.java:352)
	at org.eclipse.scout.rt.client.ui.action.AbstractAction.doAction(AbstractAction.java:343)
	at org.eclipse.scout.rt.client.ui.action.AbstractAction$P_UIFacade.fireActionFromUI(AbstractAction.java:629)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.scout.rt.client.ModelContextProxy.lambda$1(ModelContextProxy.java:49)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxMandatory(TransactionProcessor.java:156)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:139)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:78)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:158)
	at org.eclipse.scout.rt.client.ModelContextProxy.lambda$0(ModelContextProxy.java:49)
	at com.sun.proxy.$Proxy31.fireActionFromUI(Unknown Source)
	at org.eclipse.scout.rt.ui.html.json.action.JsonAction.handleUiAction(JsonAction.java:159)
	at org.eclipse.scout.rt.ui.html.json.action.JsonAction.handleUiEvent(JsonAction.java:151)
	at org.eclipse.scout.rt.ui.html.json.JsonEventProcessor.processEvent(JsonEventProcessor.java:52)
	at org.eclipse.scout.rt.ui.html.json.JsonEventProcessor.processEvents(JsonEventProcessor.java:37)
	at org.eclipse.scout.rt.ui.html.UiSession.processJsonRequestInternal(UiSession.java:817)
	at org.eclipse.scout.rt.platform.util.concurrent.Callables.lambda$0(Callables.java:31)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.job.internal.ExceptionProcessor.intercept(ExceptionProcessor.java:41)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxMandatory(TransactionProcessor.java:156)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:139)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:78)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:158)
	at org.eclipse.scout.rt.platform.context.RunContextRunner.intercept(RunContextRunner.java:38)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.job.internal.CallableChainExceptionHandler.intercept(CallableChainExceptionHandler.java:33)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.lambda$0(JobFutureTask.java:106)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.run(JobFutureTask.java:175)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.eclipse.scout.rt.platform.job.internal.NamedThreadFactory$1.run(NamedThreadFactory.java:63)


It looks like the most important thing to retain is the statement

Assertion error: no instance found for query: class


Can you help me get around this problem?

Thanks a lot,

JD
Re: REST Client: fetching data and populating a table [message #1839704 is a reply to message #1839698] Fri, 26 March 2021 06:53 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hi J D

When you want to access classes through Scout's BeanManager with BEANS.get(FirstNameRestClientHelper.class), you need to register the class with the @ApplicationScoped annotation.

See the doc for more details: https://eclipsescout.github.io/11.0/technical-guide.html#sec-bean.manager

Cheers
André


Eclipse Scout Homepage | Documentation | GitHub
Re: REST Client: fetching data and populating a table [message #1839799 is a reply to message #1839704] Mon, 29 March 2021 09:58 Go to previous messageGo to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Hello there André,

Thanks for your suggestions. I tried it but I was unsuccessful. These are the errors/exceptions I got when I added the annotations @ApplicationScoped and/or @Bean to the class FirstNameRestClientHelper:

a) As is without annotations
Assertion error:
no instance found for query: class org.eclipse.scout.apps.ygclient.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper

b) With @ApplicationScoped
BeanCreationException:
Could not create bean [class org.eclipse.scout.apps.ygclient.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper]

c) With @ApplicationScoped & @Bean
BeanCreationException:
Could not create bean [class org.eclipse.scout.apps.ygclient.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper]

d) With @Bean alone
BeanCreationException:
Could not create bean [class org.eclipse.scout.apps.ygclient.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper]

What do I do now?

JD

[Updated on: Mon, 29 March 2021 10:07]

Report message to a moderator

Re: REST Client: fetching data and populating a table [message #1839805 is a reply to message #1839799] Mon, 29 March 2021 10:37 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hi JD.

Maybe your class has no public constructor? or an exception is thrown while the constructor is called?
Anyway: please post the full stracktrace here.

André


Eclipse Scout Homepage | Documentation | GitHub
Re: REST Client: fetching data and populating a table [message #1839807 is a reply to message #1839805] Mon, 29 March 2021 10:52 Go to previous messageGo to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Andre Wegmueller wrote on Mon, 29 March 2021 10:37
Hi JD.

Maybe your class has no public constructor? or an exception is thrown while the constructor is called?
Anyway: please post the full stracktrace here.

André



Here it is:

2021-03-29 12:48:41,781 ERROR [scout-model-thread-22 Processing JSON request] org.eclipse.scout.rt.platform.exception.ExceptionHandler.handlePlatformException(ExceptionHandler.java:124) -  - MDC[principal=jd, uiSession=1:u3vho41kq17lgj6lr8a3fqcjbrkedrqrc4b5k5ab4nca5ces0k6, scoutSession=mg17a7s28m54cf2mj35d91hhsah0kjbu637armhgfh9d7jvg4v0, jobName=Processing JSON request, cid=Rd2NK8ZQ7TW/5]
org.eclipse.scout.rt.platform.exception.BeanCreationException: Could not create bean [class org.eclipse.scout.apps.ygclient.client.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper]
	at org.eclipse.scout.rt.platform.internal.BeanInstanceUtil.translateException(BeanInstanceUtil.java:171)
	at org.eclipse.scout.rt.platform.internal.BeanInstanceUtil.createBean(BeanInstanceUtil.java:67)
	at org.eclipse.scout.rt.platform.internal.BeanInstanceUtil.lambda$1(BeanInstanceUtil.java:124)
	at org.eclipse.scout.rt.platform.internal.BeanInstanceUtil.createAndAssertNoCircularDependency(BeanInstanceUtil.java:149)
	at org.eclipse.scout.rt.platform.internal.NonSingeltonBeanInstanceProducer.produce(NonSingeltonBeanInstanceProducer.java:56)
	at org.eclipse.scout.rt.platform.internal.BeanImplementor.getInstance(BeanImplementor.java:98)
	at org.eclipse.scout.rt.platform.BEANS.opt(BEANS.java:58)
	at org.eclipse.scout.rt.platform.BEANS.get(BEANS.java:42)
	at org.eclipse.scout.apps.ygclient.client.rest.mocksamples.opendataparis.firstname.FirstNameResourceClient.helper(FirstNameResourceClient.java:18)
	at org.eclipse.scout.apps.ygclient.client.rest.mocksamples.opendataparis.firstname.FirstNameResourceClient.getFirstNameEntity(FirstNameResourceClient.java:23)
	at org.eclipse.scout.apps.ygclient.client.mocksamples.opendataparis.firstname.FirstNameTablePage.execLoadData(FirstNameTablePage.java:39)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable$LocalPageWithTableExtension.execLoadData(AbstractPageWithTable.java:1068)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain$1.callMethod(PageWithTableChains.java:47)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain$1.callMethod(PageWithTableChains.java:1)
	at org.eclipse.scout.rt.shared.extension.AbstractExtensionChain.callChain(AbstractExtensionChain.java:113)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain.execLoadData(PageWithTableChains.java:50)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.AbstractPageWithTableExtension.execLoadData(AbstractPageWithTableExtension.java:35)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain$1.callMethod(PageWithTableChains.java:47)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain$1.callMethod(PageWithTableChains.java:1)
	at org.eclipse.scout.rt.shared.extension.AbstractExtensionChain.callChain(AbstractExtensionChain.java:113)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTableLoadDataChain.execLoadData(PageWithTableChains.java:50)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable.interceptLoadData(AbstractPageWithTable.java:1033)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable.execPopulateTable(AbstractPageWithTable.java:265)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable$LocalPageWithTableExtension.execPopulateTable(AbstractPageWithTable.java:1078)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain$1.callMethod(PageWithTableChains.java:82)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain$1.callMethod(PageWithTableChains.java:1)
	at org.eclipse.scout.rt.shared.extension.AbstractExtensionChain.callChain(AbstractExtensionChain.java:113)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain.execPopulateTable(PageWithTableChains.java:85)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.AbstractPageWithTableExtension.execPopulateTable(AbstractPageWithTableExtension.java:45)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain$1.callMethod(PageWithTableChains.java:82)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain$1.callMethod(PageWithTableChains.java:1)
	at org.eclipse.scout.rt.shared.extension.AbstractExtensionChain.callChain(AbstractExtensionChain.java:113)
	at org.eclipse.scout.rt.client.extension.ui.desktop.outline.pages.PageWithTableChains$PageWithTablePopulateTableChain.execPopulateTable(PageWithTableChains.java:85)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable.interceptPopulateTable(AbstractPageWithTable.java:1045)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable.loadTableDataImpl(AbstractPageWithTable.java:772)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable.loadChildrenImpl(AbstractPageWithTable.java:831)
	at org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPage.loadChildren(AbstractPage.java:1021)
	at org.eclipse.scout.rt.client.ui.basic.tree.AbstractTreeNode.ensureChildrenLoaded(AbstractTreeNode.java:1049)
	at org.eclipse.scout.rt.client.ui.desktop.outline.DefaultPageChangeStrategy.pageChanged(DefaultPageChangeStrategy.java:43)
	at org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutline.handleActivePageChanged(AbstractOutline.java:744)
	at org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutline.nodesSelectedInternal(AbstractOutline.java:734)
	at org.eclipse.scout.rt.client.ui.basic.tree.AbstractTree.fireNodesSelected(AbstractTree.java:2303)
	at org.eclipse.scout.rt.client.ui.basic.tree.AbstractTree.selectNodes(AbstractTree.java:1938)
	at org.eclipse.scout.rt.client.ui.basic.tree.AbstractTree$P_UIFacade.setNodesSelectedFromUI(AbstractTree.java:2860)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.scout.rt.client.ModelContextProxy.lambda$1(ModelContextProxy.java:49)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxMandatory(TransactionProcessor.java:156)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:139)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:78)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:158)
	at org.eclipse.scout.rt.client.ModelContextProxy.lambda$0(ModelContextProxy.java:49)
	at com.sun.proxy.$Proxy30.setNodesSelectedFromUI(Unknown Source)
	at org.eclipse.scout.rt.ui.html.json.tree.JsonTree.handleUiNodesSelected(JsonTree.java:1065)
	at org.eclipse.scout.rt.ui.html.json.tree.JsonTree.handleUiEvent(JsonTree.java:1011)
	at org.eclipse.scout.rt.ui.html.json.JsonEventProcessor.processEvent(JsonEventProcessor.java:52)
	at org.eclipse.scout.rt.ui.html.json.JsonEventProcessor.processEvents(JsonEventProcessor.java:37)
	at org.eclipse.scout.rt.ui.html.UiSession.processJsonRequestInternal(UiSession.java:817)
	at org.eclipse.scout.rt.platform.util.concurrent.Callables.lambda$0(Callables.java:31)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.job.internal.ExceptionProcessor.intercept(ExceptionProcessor.java:41)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxMandatory(TransactionProcessor.java:156)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:139)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:78)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:158)
	at org.eclipse.scout.rt.platform.context.RunContextRunner.intercept(RunContextRunner.java:38)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.job.internal.CallableChainExceptionHandler.intercept(CallableChainExceptionHandler.java:33)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.lambda$0(JobFutureTask.java:106)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.run(JobFutureTask.java:175)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.eclipse.scout.rt.platform.job.internal.NamedThreadFactory$1.run(NamedThreadFactory.java:63)
Caused by: java.lang.SecurityException: class "org.glassfish.jersey.apache.connector.ApacheConnectorProvider"'s signer information does not match signer information of other classes in the same package
	at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1151)
	at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:906)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1015)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at org.eclipse.scout.rt.rest.jersey.client.JerseyClientConfigFactory.initConnectionProvider(JerseyClientConfigFactory.java:167)
	at org.eclipse.scout.rt.rest.jersey.client.JerseyClientConfigFactory.postProcessClientBuilder(JerseyClientConfigFactory.java:141)
	at org.eclipse.scout.rt.rest.jersey.client.JerseyClientConfigFactory.buildClient(JerseyClientConfigFactory.java:131)
	at org.eclipse.scout.rt.rest.client.AbstractRestClientHelper.buildClient(AbstractRestClientHelper.java:99)
	at org.eclipse.scout.rt.rest.client.AbstractRestClientHelper.createClient(AbstractRestClientHelper.java:81)
	at org.eclipse.scout.rt.rest.client.AbstractRestClientHelper.createClientSupplier(AbstractRestClientHelper.java:57)
	at org.eclipse.scout.rt.rest.client.AbstractRestClientHelper.<init>(AbstractRestClientHelper.java:50)
	at org.eclipse.scout.apps.ygclient.client.rest.mocksamples.opendataparis.firstname.FirstNameRestClientHelper.<init>(FirstNameRestClientHelper.java:12)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.eclipse.scout.rt.platform.internal.BeanInstanceUtil.createBean(BeanInstanceUtil.java:64)
	... 84 common frames omitted


Thanks a lot for your assistance.

JD
Re: REST Client: fetching data and populating a table [message #1839812 is a reply to message #1839807] Mon, 29 March 2021 11:18 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hi JD

The root cause is here:

Quote:
Caused by: java.lang.SecurityException: class "org.glassfish.jersey.apache.connector.ApacheConnectorProvider"'s signer information does not match signer information of other classes in the same package


I've seen this error before in an internal Scout project. I've opened bugzilla ticket 572405 and contact my colleague who worked on that issue. I come back to you as soon we have news.

Cheers
André


Eclipse Scout Homepage | Documentation | GitHub

[Updated on: Mon, 29 March 2021 11:24]

Report message to a moderator

Re: REST Client: fetching data and populating a table [message #1839820 is a reply to message #1839812] Mon, 29 March 2021 12:51 Go to previous messageGo to next message
Stephan Merkli is currently offline Stephan MerkliFriend
Messages: 48
Registered: April 2012
Member
The issue is caused somehow due to signed packages and the Java classes in modul "org.eclipse.scout.rt.rest.jersey.client", package "org.glassfish.jersey.apache.connector".

My workaround was to build Scout RT manually and install the artefacts into my local Maven repository so that my newly built .jar files are used instead of the signed ones from Maven Central.

git clone git://git.eclipse.org/gitroot/scout/org.eclipse.scout.rt.git .
git checkout tags/10.0.42 -b tags/10.0.42
mvn clean install -DskipTests


Re: REST Client: fetching data and populating a table [message #1839828 is a reply to message #1839820] Mon, 29 March 2021 16:21 Go to previous messageGo to next message
Paolo Bazzi is currently offline Paolo BazziFriend
Messages: 33
Registered: January 2017
Location: Switzerland
Member
Thanks Stephan for your workaround!

This is unfortunately an bug in Eclipse Scout. You can solve this like Stephan mentioned by building your own, unsigned module "org.eclipse.scout.rt.rest.jersey.client" (if you're able to use a local maven repository while building) or as an alternative like this:

- Remove dependency to module "org.eclipse.scout.rt.rest.jersey.client" from your Scout project and just add a dependency to "org.eclipse.scout.rt.rest".
- Add the following temporary class to your project

public class WorkaroundJerseyClientConfigFactory implements IRestClientConfigFactory {
  @Override
  public ClientConfig createClientConfig() {
    return new ClientConfig();
  }
}


This removes a few fetures of the Apache HTTP client but should work in most cases. If you need full Apache HTTP client support, you need to use Stephan's workaround or to copy the following Scout Classes to your Workspace:

JerseyClientConfigFactory (full implementation of the above class using the following helper classes)
ClosingApacheConnector
ClosingApacheConnectorProvider
RestEnsureHttpHeaderConnectionCloseProperty

Cheers,
Paolo


Eclipse Scout Homepage | Documentation | GitHub
Re: REST Client: fetching data and populating a table [message #1839975 is a reply to message #1839828] Fri, 02 April 2021 12:59 Go to previous messageGo to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
@Paolo, @Stephan & @Andre

Thanks a lot for your explanations and suggestions. I'll try them.

JD
Re: REST Client: fetching data and populating a table [message #1840002 is a reply to message #1839975] Sat, 03 April 2021 19:56 Go to previous messageGo to next message
J D is currently offline J DFriend
Messages: 110
Registered: February 2021
Senior Member
Hi there everyone,

I applied Paolo's tips and I was finally able to fetch the data from the public REST api.

I also used the opportunity to migrate to Eclipse Scout 11 and everything is working fine.

Thanks a lot to everyone that offered me assistance.

JD
Re: REST Client: fetching data and populating a table [message #1840041 is a reply to message #1840002] Tue, 06 April 2021 05:47 Go to previous message
Paolo Bazzi is currently offline Paolo BazziFriend
Messages: 33
Registered: January 2017
Location: Switzerland
Member
Great to hear, thanks for your feedback!

Cheers, Paolo


Eclipse Scout Homepage | Documentation | GitHub
Previous Topic:Error java.sql.SQLException: No suitable driver found for jdbc:mysql:XXXXXXXXXXXX
Next Topic:LDAPAuthenticator - example
Goto Forum:
  


Current Time: Thu Dec 26 18:41:50 GMT 2024

Powered by FUDForum. Page generated in 0.35715 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top