<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to get the URL of a process start within a JAX-RS class</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class</link><description>&lt;p&gt;Hello IvyTeam,&lt;/p&gt;
&lt;p&gt;My Ivy Version : 7.0.3
I would like to get the url from a process in a JAX-RS Rest Resource but I get an Exception with this code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Ivy.html().startref("Functional Processes/dis/videoIdentification/start.ivp")
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The JAX-RS Resource is located in the same project as the process. It works without problem in a Process (IvyScript Step).&lt;/p&gt;
&lt;p&gt;I can imagine that the fact the code is in a JAX-RS Resource does not allow accessing some Ivy resources like the ProjectModelVersion Provider. Is there a workaround for that? Or do I have to compute the url more manually with the InetAddress and so on ? By the way this code works in this resource: Ivy.html().applicationHomeRef()&lt;/p&gt;
&lt;p&gt;Thanks in advance &lt;/p&gt;
&lt;p&gt;Here the StackTrace I get:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, java.lang.NullPointerException
  while locating ch.ivyteam.ivy.workflow.internal.di.CaseProjectProcessModelVersionProvider
  while locating ch.ivyteam.ivy.application.IProcessModelVersion annotated with interface ch.ivyteam.ivy.scope.restricted.FromCaseScope
Caused by: java.lang.NullPointerException
    at ch.ivyteam.ivy.workflow.internal.di.CaseProjectProcessModelVersionProvider.get(CaseProjectProcessModelVersionProvider.java:18)
    at ch.ivyteam.ivy.workflow.internal.di.CaseProjectProcessModelVersionProvider.get(CaseProjectProcessModelVersionProvider.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 com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1050)
    at ch.ivyteam.di.restricted.DiInjector.getInstance(DiInjector.java:77)
    at 
&lt;/code&gt;&lt;/pre&gt;</description><atom:link href="https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 19 Apr 2018 09:51:29 -0400</lastBuildDate><item><title>Comment by Alex Suter on Emmanuel Comba's answer</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3229</link><description>&lt;p&gt;Hello everybody.&lt;/p&gt;
&lt;p&gt;Thanks for the additional info. We think that this is a bug and we will fix that. But some api like ivy.repo.get(), will still fail, because they relates to a case. And in the rest context, there is no case set. There you must use ivy.repo.find(): XIVY-2504&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex Suter</dc:creator><pubDate>Thu, 19 Apr 2018 09:51:29 -0400</pubDate><guid>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3229</guid></item><item><title>Comment by Emmanuel Comba on Emmanuel Comba's answer</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3228</link><description>&lt;p&gt;Hi &lt;a href="https://answers.axonivy.com/users/118/trungdv"&gt;&lt;a href="https://answers.axonivy.com/users/118/trungdv"&gt;@trungdv&lt;/a&gt;&lt;/a&gt; and &lt;a href="https://answers.axonivy.com/users/710/alex-suter"&gt;&lt;a href="https://answers.axonivy.com/users/710/alex-suter"&gt;@Alex Suter&lt;/a&gt;&lt;/a&gt; Thanks for your help.
Calling a subcallable that compute, the given processName url, from the rest Resource is working fine. It is a little bit more complex but it is acceptable ;) It would be great to have access to the Ivy Context within a jax rs resource.
Thanks and cheers
Emmanuel&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emmanuel Comba</dc:creator><pubDate>Thu, 19 Apr 2018 08:37:03 -0400</pubDate><guid>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3228</guid></item><item><title>Comment by trungdv on Emmanuel Comba's answer</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3225</link><description>&lt;p&gt;hi &lt;a href="https://answers.axonivy.com/users/932/emmanuel-comba"&gt;&lt;a href="https://answers.axonivy.com/users/932/emmanuel-comba"&gt;@Emmanuel Comba&lt;/a&gt;&lt;/a&gt; 
I think you're right about in RestAPI we're outside of 'real' ivy context. I also can't use some api like &lt;code&gt;ivy.repo&lt;/code&gt; or &lt;code&gt;ivy.rule&lt;/code&gt; but i can use &lt;code&gt;ivy.log&lt;/code&gt; or &lt;code&gt;ivy.cms&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Normally i need to create callablesub just to execute &lt;code&gt;Ivy.html().startref()&lt;/code&gt; then trigger it from RestApi.&lt;/p&gt;
&lt;p&gt;I'm looking forward for another solution. :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Thu, 19 Apr 2018 07:12:12 -0400</pubDate><guid>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class#3225</guid></item><item><title>Answer by Emmanuel Comba</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class/3222</link><description>&lt;p&gt;Hi Alex,&lt;/p&gt;
&lt;p&gt;Thanks for your answer. 
This is unfortunately not exactly my use-case. 
What I want to achieve is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A Rest Client calls the Rest Resource located in Ivy Process Model A. This Process Model has a bunch of process Starts (not SubCallable),&lt;/li&gt;
&lt;li&gt;The Rest Resource provides a response Object (JSON) with several properties, among them the url of one of the process Start.&lt;/li&gt;
&lt;li&gt;So I just want there to compute the Process Call url dynamically and "easily" ;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Normally&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ivy.html().startref("Functional
Processes/dis/videoIdentification/start.ivp")&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;is the easiest way to perform that.
But in the case of a jax-rs Rest Resource, I suppose that the we are outside any "real" Ivy context. 
That could explain why I get the Error I have posted in my first post.&lt;/p&gt;
&lt;p&gt;Do you know another way to perform that? &lt;/p&gt;
&lt;p&gt;Thanks in advance
Emmanuel&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emmanuel Comba</dc:creator><pubDate>Thu, 19 Apr 2018 01:55:56 -0400</pubDate><guid>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class/3222</guid></item><item><title>Answer by Alex Suter</title><link>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class/3221</link><description>&lt;p&gt;Hi &lt;a href="https://answers.axonivy.com/users/932/emmanuel-comba"&gt;&lt;a href="https://answers.axonivy.com/users/932/emmanuel-comba"&gt;@Emmanuel Comba&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This bug has been fixed with Ivy 7.0.5 and Ivy 7.2. For other versions consider the workaround via a sub process call.&lt;/p&gt;
&lt;p&gt;Have a look at ConnectivityDemos:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;com.axonivy.connectivity.rest.provider.ApprovalService
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Does this code snippet fit you rneeds?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ITask task = SubProcessCall.withPath("rest/createApproval")
                .withParam("title", title)
                .withParam("description", description)
                .call()
                .get("approvalTask", ITask.class);
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex Suter</dc:creator><pubDate>Thu, 19 Apr 2018 01:39:11 -0400</pubDate><guid>https://answers.axonivy.com/questions/3218/how-to-get-the-url-of-a-process-start-within-a-jax-rs-class/3221</guid></item></channel></rss>