Hi Axon.ivy team,

I know this questions had been asked long time ago at https://answers.axonivy.com/questions/2777/can-not-use-ivy-repo-in-resfulapi. But the question was for Axon.ivy 6.3.0 and there was never a resolution of the issue.

I am using Axon.ivy 7.0.8 LTS and I still encountered the same issue.

I introduce a JAX-RS resource:

package com.example.lab;

@PermitAll
@Path("awesome")
public class TheAwesomeApi {

    @POST
    @Consume("application/json")
    @Produces("text/plain")
    public String saveAwesomeMessage(AwesomeMessage message) {
        return Ivy.repo().save(message).getId();
    }

    public static class AwesomeMessage {
        private String content;
        // getter, setter
    }
}

When I tried to call this API, the exception was returned.

curl http://localhost:8081/ivy/api/designer/awesome \
  -H 'Content-Type: application/json' \
  -d '{ "content" : "This is an awesome message" }'

full stacktrace can be found here: https://pastebin.com/hXcyQq6h

Unable to provision, see the following errors:

1) Error in custom provider, java.lang.NullPointerException
  while locating ch.ivyteam.ivy.scripting.dataclass.internal.di.IvyCaseProjectClassLoaderProvider
  while locating java.lang.ClassLoader annotated with interface ch.ivyteam.ivy.scope.restricted.FromCaseScope
Caused by: java.lang.NullPointerException
    at ch.ivyteam.ivy.scripting.dataclass.internal.di.IvyCaseProjectClassLoaderProvider.get(IvyCaseProjectClassLoaderProvider.java:20)
    at ch.ivyteam.ivy.scripting.dataclass.internal.di.IvyCaseProjectClassLoaderProvider.get(IvyCaseProjectClassLoaderProvider.java:1)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
    at ch.ivyteam.ivy.business.data.store.restricted.BusinessDataTypeLoader.getContextClassLoader(BusinessDataTypeLoader.java:60)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.serialize(BusinessDataRepositoryImpl.java:369)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.lambda$0(BusinessDataRepositoryImpl.java:196)
    at ch.ivyteam.ivy.business.data.store.internal.ElasticSystemDbPersistence.lambda$14(ElasticSystemDbPersistence.java:439)
    at ch.ivyteam.ivy.persistence.base.AbstractPersistencyService.execute(AbstractPersistencyService.java:177)
    at ch.ivyteam.ivy.persistence.base.ClassPersistencyService.execute(ClassPersistencyService.java:673)
    at ch.ivyteam.ivy.business.data.store.internal.ElasticSystemDbPersistence.executeInTransaction(ElasticSystemDbPersistence.java:435)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.create(BusinessDataRepositoryImpl.java:194)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.save(BusinessDataRepositoryImpl.java:177)
    at com.example.lab.axonivy.api.TheAwesomeApi.saveAwesomeMessage(TheAwesomeApi.java:35)
    ....
    at java.lang.Thread.run(Thread.java:748)

2) Error in custom provider, com.google.inject.OutOfScopeException: No case available in the current scope/context
  while locating ch.ivyteam.ivy.workflow.internal.di.CaseProvider
  while locating ch.ivyteam.ivy.workflow.ICase
    for field at ch.ivyteam.ivy.scripting.dataclass.internal.di.IvyCaseProjectClassLoaderProvider.caze(IvyCaseProjectClassLoaderProvider.java:1)
  while locating ch.ivyteam.ivy.scripting.dataclass.internal.di.IvyCaseProjectClassLoaderProvider
  while locating java.lang.ClassLoader annotated with interface ch.ivyteam.ivy.scope.restricted.FromCaseScope
Caused by: com.google.inject.OutOfScopeException: No case available in the current scope/context
    at ch.ivyteam.ivy.workflow.internal.di.CaseProvider.get(CaseProvider.java:24)
    at ch.ivyteam.ivy.workflow.internal.di.CaseProvider.get(CaseProvider.java:1)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.ProvidedByInternalFactory.provision(ProvidedByInternalFactory.java:82)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.ProvidedByInternalFactory.get(ProvidedByInternalFactory.java:71)
    at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:120)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:61)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
    at ch.ivyteam.ivy.business.data.store.restricted.BusinessDataTypeLoader.getContextClassLoader(BusinessDataTypeLoader.java:60)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.serialize(BusinessDataRepositoryImpl.java:369)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.lambda$0(BusinessDataRepositoryImpl.java:196)
    at ch.ivyteam.ivy.business.data.store.internal.ElasticSystemDbPersistence.lambda$14(ElasticSystemDbPersistence.java:439)
    at ch.ivyteam.ivy.persistence.base.AbstractPersistencyService.execute(AbstractPersistencyService.java:177)
    at ch.ivyteam.ivy.persistence.base.ClassPersistencyService.execute(ClassPersistencyService.java:673)
    at ch.ivyteam.ivy.business.data.store.internal.ElasticSystemDbPersistence.executeInTransaction(ElasticSystemDbPersistence.java:435)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.create(BusinessDataRepositoryImpl.java:194)
    at ch.ivyteam.ivy.business.data.store.internal.BusinessDataRepositoryImpl.save(BusinessDataRepositoryImpl.java:177)
    at com.example.lab.axonivy.api.TheAwesomeApi.saveAwesomeMessage(TheAwesomeApi.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at ch.ivyteam.ivy.webserver.internal.rest.resource.project.RestPmvInvocationHandler$PmvAwareInvocator.lambda$0(RestPmvInvocationHandler.java:38)
    at ch.ivyteam.ivy.webserver.internal.rest.resource.project.RestPmvInvocationHandler.executeWithIvyContext(RestPmvInvocationHandler.java:70)
    at ch.ivyteam.ivy.webserver.internal.rest.resource.project.RestPmvInvocationHandler.access$1(RestPmvInvocationHandler.java:65)
    at ch.ivyteam.ivy.webserver.internal.rest.resource.project.RestPmvInvocationHandler$PmvAwareInvocator.invoke(RestPmvInvocationHandler.java:50)
    ...
    at java.lang.Thread.run(Thread.java:748)

2 errors"

Is this issue still a known limitation even with the 7.0 LTS?

Thanks for your support!

Jack

asked 24.01.2019 at 00:49

vagabond's gravatar image

vagabond
(suspended)
accept rate: 50%

edited 24.01.2019 at 00:52


The BusinessDataRepository is designed and powerful because the data in it is usually attached to a IBusinessCase. So it makes sort of sense to me that the example here does not work with the ivy.repo() API as there is no Task or Case set up when a client uses the REST api.

But the relation (between repo & BusinessData) is not strictly enforced and lives in a separate db table. So it looks like a minor bug to me. I opened an issue for it: https://jira.axonivy.com/jira/browse/XIVY-3074

Workaround up till then: store data that is associated with a IBusinessCase in a process. Within it you have a Task/Case.

link

answered 29.01.2019 at 03:39

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

edited 15.02.2019 at 10:33

SupportIvyTeam's gravatar image

SupportIvyTeam ♦♦
1.4k102118122

Yeah I see. The most common use case is to use the repo in combination with a BusinessCase. But the relation is not strictly enforced and lives in a separate db table. So it looks like a minor bug to me. I opened an issue for it: https://jira.axonivy.com/jira/browse/XIVY-3074

(30.01.2019 at 03:03) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

With today's nightly build this issue has been resolved. You can download the newest 7.3.0-SNAPSHOT here and try it out: https://developer.axonivy.com/download/nightly

(01.02.2019 at 10:02) Andreas Rusch Andreas%20Rusch's gravatar image

Hi Andreas Rusch and Reguel Wermelinger, thanks for the update and quick action to fix the issue! Is there any chance that the fix could be backported to 7.0 LTS? We don't have the option to upgrade to Leading Edge for the time being.

(02.02.2019 at 03:07) vagabond vagabond's gravatar image

Yes, we are planning to add this feature in 7.0.11.

(04.02.2019 at 05:08) Andreas Rusch Andreas%20Rusch's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×17

Asked: 24.01.2019 at 00:49

Seen: 1,492 times

Last updated: 15.02.2019 at 10:33