Questions Tagged With ivyhttps://answers.axonivy.com/tags/ivy/?type=rss&user=Genzer%20Hawkerquestions tagged <span class="tag">ivy</span>enMon, 03 Oct 2016 14:50:20 -0400JAX-RS method returns StreamingOutput fails with "Access to ivy environment outside a process request thread is not possible"https://answers.axonivy.com/questions/2072/jax-rs-method-returns-streamingoutput-fails-with-access-to-ivy-environment-outside-a-process-request-thread-is-not-possible<p>Hi Ivy team</p> <p>I want to build a JAX-RS API returning response in a streaming manner (chunked transfer encoding). The code looks like below:</p> <pre><code>@Path("{applicationName}/streams") public class StreamingResponseRestSResource { @GET public Response getStreamingResponse() { // This works by keeping a reference then pass it to the anonymous class. // It may NOT work in all situations. final Logger logger = Ivy.log(); StreamingOutput streamingOutput = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { PrintWriter out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(output)), true); Ivy.log().error("HHH - BREAK HERE"); logger.error("HHH - It works with passed reference of Logger"); IntStream.range(0, 100_000) .forEach(c -&gt; out.println("HHH - Count up to " + c)); } }; return Response.ok(streamingOutput).build(); } } </code></pre> <p>Full code here: <a href="http://pastebin.com/tEAMGFB3">http://pastebin.com/tEAMGFB3</a></p> <p>If I do</p> <p><code>curl -i -u Developer:Developer <a href="http://localhost:8081/ivy/api/designer/streams">http://localhost:8081/ivy/api/designer/streams</a></code></p> <p>the response would be:</p> <p><code>{ "errorId": "1578A42A15718503", "errorMessage": "Access to ivy environment outside a process request thread is not possible.\nCurrent thread: Thread[http-nio-8081-exec-14,5,main]", "statusCode": 500 }</code></p> <p>If I comment out the line ...</p> <p><code>Ivy.log().error("HHH - BREAK HERE");</code></p> <p>...the error disappears.</p> <p>Is there anyway to fix the access to <code>Ivy</code> with <code>StreamingOutput</code> implementation?</p>Genzer HawkerMon, 03 Oct 2016 14:50:20 -0400https://answers.axonivy.com/questions/2072/jax-rs-method-returns-streamingoutput-fails-with-access-to-ivy-environment-outside-a-process-request-thread-is-not-possibleivyrestLucene versions conflict when migrating from Xpert.ivy v4 to Axon.ivy v5https://answers.axonivy.com/questions/1256/lucene-versions-conflict-when-migrating-from-xpert-ivy-v4-to-axon-ivy-v5<p>Our project have encountered an urgent situation in which we have to migrate all modules into Axon.ivy v5.1.4. The migration have some serious trouble with Lucene.</p> <p>Our project uses Lucene v3.6.0 and we have the <code>lucene-core-v3.6.0.jar</code> in our <code>buildpath</code>. After migrating into Axon.ivy 5.1.4, the project cannot built anymore since we get strange complilation error:</p> <pre><code>Errors occurred during the build. Errors running builder 'Ivy Web Service Process Class Builder' on project 'test'. Bad return type Exception Details: Location: ch/test/lucene/LuceneManager.analyzer()Lorg/apache/lucene/analysis/Analyzer; @10: areturn Reason: Type 'org/apache/lucene/analysis/standard/StandardAnalyzer' (current frame, stack[0]) is not assignable to 'org/apache/lucene/analysis/Analyzer' (from method signature) Current Frame: bci: @10 flags: { } locals: { } stack: { 'org/apache/lucene/analysis/standard/StandardAnalyzer' } Bytecode: 0000000: bb00 f459 b200 28b7 00f6 b0 </code></pre> <p>We found out that the Axon.ivy has upgraded Lucene to v4.5.1 which contains a lots of incompatible changes compared to Lucene v3.6.0. <strong>The problem is we could not find a way to force the Axon.ivy build the project with <code>lucene-core-v3.6.0.jar</code> instead of the built-in <code>lucene-core-v4.5.1.jar</code></strong></p> <h1>UPDATE</h1> <p>We later tried to upgrade our implementation into Lucene 4.5.1 but got several other problems:</p> <p>(1) Axon.ivy issues warnings about we are trying to access Lucene API.</p> <p>(2) Start the project in Axon.ivy Designer will encounter <code>ClassNotFoundException</code>: </p> <pre><code>Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer at ch.soreco.alag.ria.service.taskindex.LucenceHandler.startLuceneInstance(LucenceHandler.java:6) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at ch.ivyteam.ivy.scripting.internal.types.IvyJavaMethod.invokeImpl(IvyJavaMethod.java:73) ... 35 more Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer at ch.ivyteam.ivy.java.internal.IvyProjectClassLoader.loadClass(IvyProjectClassLoader.java:243) at java.lang.ClassLoader.loadClass(Unknown Source) ... 41 more </code></pre> <p>.. even if all the jars are shipped with Axon.ivy.</p> <p>(3) If we try to include the jars file into our projects (in the classpath), the build will halt with the <code>Bad Return Type</code> error above.</p> <h1>QUESTIONS</h1> <ul> <li>How could we force the Axon.ivy to build our projects using the <code>lucene-core-v3.6.0</code> instead of the <code>lucene-core-v4.5.1</code> shipped with Axon.ivy?</li> <li>Why do we get strange problems when building the projects with built-in Lucene library of Axon.ivy v5.1.4?</li> </ul> <h1>SAMPLE PROJECTS</h1> <p>I attach in this email the two sample projects which illustrate the problems we are facing. We tested the two with AxonIvyDesigner5.1.4.48243_Windows_x64:</p> <ul> <li><a href="https://app.box.com/s/ggaz5cuiip9g6wb1bdq2l1js7xxi2emx"><code>use_built_in_lucene.iar</code></a>: This project illustrates the problem which we cannot built the project if it uses Lucene's classes.</li> <li><a href="https://app.box.com/s/j8gkpnxnmr9oydyelxy446ej7urqb6d9"><code>use_external_lucene.iar</code></a>: This project illustrates the problem which we purposely include the Lucene's jar files but the project still fails.</li> </ul> <h1>UPDATE 2 (extend the answer)</h1> <p>The solution from Reguel Wermelinger which suggest to repack all the classes in <code>lucene-core-v3.6.0.jar</code> in different package name works.</p> <p>1- Download <a href="https://code.google.com/p/jarjar/downloads/list">JarJar</a> (hosted on Google Code, if you read this after 25.01.2016, please search it on GitHub).</p> <p>2 - Put the file <code>lucene-core-v3.6.0.jar</code> at the same directory at JarJar.</p> <p>3 - Create a text file, namely <code>rules.txt</code>, contains one line</p> <pre><code>rule org.apache.lucene.** org.apache.lucene.v3_6_0.@1 </code></pre> <p>4 - Execute the command</p> <pre><code>$ java -jar jarjar.jar rules.txt lucene-core-v3.6.0.jar lucene-core-v3.6.0-repacked.jar </code></pre> <p>5 - Done!</p> <p>You can download the already-repackged <a href="https://app.box.com/s/9efw6bxhm8gkws25gd34d44qwu30662r"><code>lucene-core-v3.6.0-repacked.jar</code></a></p> <p>Please note that this is only a work-around. The Axon.ivy still has problem if you use the Lucene v4.5.1 shipped with it.</p>Genzer HawkerMon, 13 Apr 2015 08:07:15 -0400https://answers.axonivy.com/questions/1256/lucene-versions-conflict-when-migrating-from-xpert-ivy-v4-to-axon-ivy-v5luceneivy4x-migrationivymigrationHow to start the Ivy Server in plain Java?https://answers.axonivy.com/questions/1187/how-to-start-the-ivy-server-in-plain-java<p>There are several questions regarding how to access to Ivy environment JUnit tests but there is no elegant solution so far.</p> <p>In Ivy Designer, if I start the Ivy Server and then start run JUnit tests, the Ivy Server will be automatically stopped. I'm trying to find a way to avoid this (and not sure if there is).</p> <p>I'm trying to implement a JUnit <code>TestRunner</code> which could start the Ivy Server programmatically but as of now, I don't know the way. What I could found is:</p> <p><code>IServer server = ServerFactory.createEclipseEmbeddedTestServer(); server.start(null); &lt;-- stuck here since I don't know how to instantiate IProgressMonitor</code></p> <p>My questions are:</p> <ul> <li>Is it possible to configure and run JUnit tests in designer along with the engine?</li> <li>How can we programmatically start a server?</li> </ul> <p>Thanks &amp; Best Regards</p>Genzer HawkerMon, 02 Mar 2015 11:11:00 -0500https://answers.axonivy.com/questions/1187/how-to-start-the-ivy-server-in-plain-javaenginetestjunitivy