Return-Path: X-Original-To: apmail-uima-user-archive@www.apache.org Delivered-To: apmail-uima-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3FB76E1B7 for ; Fri, 23 Nov 2012 09:29:21 +0000 (UTC) Received: (qmail 97249 invoked by uid 500); 23 Nov 2012 09:29:21 -0000 Delivered-To: apmail-uima-user-archive@uima.apache.org Received: (qmail 97059 invoked by uid 500); 23 Nov 2012 09:29:20 -0000 Mailing-List: contact user-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@uima.apache.org Delivered-To: mailing list user@uima.apache.org Received: (qmail 97005 invoked by uid 99); 23 Nov 2012 09:29:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Nov 2012 09:29:19 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ewal@pointpro.nl designates 91.192.36.142 as permitted sender) Received: from [91.192.36.142] (HELO obelix.pointpro.nl) (91.192.36.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Nov 2012 09:29:12 +0000 Received: from localhost (localhost [127.0.0.1]) by obelix.pointpro.nl (Postfix) with ESMTP id 90EA28E91D5 for ; Fri, 23 Nov 2012 10:28:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=pointpro.nl; h= content-transfer-encoding:content-type:content-type:subject :subject:mime-version:user-agent:from:from:date:date:message-id :received:received; s=main; t=1353662930; x=1355477330; bh=23P9L onmZLVFnZPpXY/OdjIRXZuAn7n6nFgVVhoIUFE=; b=CrJsY2bkm71E9XX9AF+3X TQQOFOVShNMcRGUiFbkCZq8wpv4FYu7H5OrqSaWX/pclK8EH7tlD14pvGqoGvyRP WJcCb+2S1K/tPiKDDsDmYn2X67AyqTdwz85+UhMHi8fpKmHGrLYzTbKIKNYYLoTF 7FmVGXnT3xgCHDoUboKjPY= X-Virus-Scanned: Debian amavisd-new at pointpro.nl Received: from obelix.pointpro.nl ([127.0.0.1]) by localhost (obelix.pointpro.nl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 89oO9ghTKhJC for ; Fri, 23 Nov 2012 10:28:50 +0100 (CET) Received: from eggy.assistobot.ai.rug.nl (ai17816.ai.rug.nl [129.125.178.16]) (Authenticated sender: ewal@pointpro.nl) by obelix.pointpro.nl (Postfix) with ESMTPA id AABD38000A7 for ; Fri, 23 Nov 2012 10:28:50 +0100 (CET) Message-ID: <50AF41D8.6090407@pointpro.nl> Date: Fri, 23 Nov 2012 10:28:56 +0100 From: Egbert van der Wal User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: user@uima.apache.org Subject: Loading annotators from resources in JAR-file Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hello, I've been looking all over the internet for this, but I can't find a proper working solution. I'm currently developing a system that needs to run independently on any machine with a JVM. Therefore, I would like to package everything inside a single JAR-file. Preferably including UIMA, but I'm not sure if the license allows this? Anyway, I have created several annotators and one aggregate annotator that links to these annotators using a relative path. The aggregate annotator is in desc/analysis engines/ and the annotators are in desc/annotators. The aggregate annotator links to the annotatiors like so: ../annotators/MyAnnotator.xml Because the files are being packaged in a JAR-file, I am using getClass().getClassLoader().getResourceAsStream("analysis engines/MyAE.xml") to load the engine and pass that to the XMLInputReader. This all seems to work, however, the function parseResourceSpecifier tries to load the linked annotators and complains it cannot find them. So fix the path issues, I replaced 'getResourceAsStream' with 'getResource' which results in a URL. The XMLInputReader also accepts a URL, so that also works, but it gives the same problem. I think the problem more or less lies in the relative path, which messes up the resource in the URL.However, I tried changing the paths to annotators/MyAnnotator.xml or /annotators/MyAnnotator.xml, but this also doesn't work, and in addition, makes the Component Descriptor Editor in Eclipse fail to read the file as it also cannot find the file. So, the big question is: what is the proper procedure to read and reference annotators packaged within a JAR-file? For reference, this is the error I'm getting when running the JAR-file (it all works fine from the development environment): org.apache.uima.resource.ResourceInitializationException: Import failed. Could not read from URL rsrc:../annotators/MyAnnotator.xml. (Descriptor: rsrc:analysis%20engines/MyAE.xml) at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:159) at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94) at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62) at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:269) at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:354) at nl.novay.keywordSpotter.KeywordSpotter.initializeEngine(KeywordSpotter.java:222) at nl.novay.keywordSpotter.KeywordSpotter.main(KeywordSpotter.java:137) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: org.apache.uima.util.InvalidXMLException: Import failed. Could not read from URL rsrc:../annotators/MyAnnotator.xml. (Descriptor: rsrc:analysis%20engines/MyAE.xml) at org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl.resolveDelegateAnalysisEngineImports(AnalysisEngineDescription_impl.java:812) at org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl.resolveDelegateAnalysisEngineImports(AnalysisEngineDescription_impl.java:765) at org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl.getDelegateAnalysisEngineSpecifiers(AnalysisEngineDescription_impl.java:193) at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:147) ... 11 more Caused by: java.net.MalformedURLException: Could not open InputStream for URL 'rsrc:../annotators/MyAnnotator.xml' at org.eclipse.jdt.internal.jarinjarloader.RsrcURLConnection.getInputStream(RsrcURLConnection.java:46) at org.apache.uima.util.XMLInputSource.(XMLInputSource.java:120) at org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl.resolveDelegateAnalysisEngineImports(AnalysisEngineDescription_impl.java:810) ... 14 more Thanks for any suggestions! Bye, Egbert