You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ctakes.apache.org by Jakob Rogstadius <Ja...@who-umc.org> on 2015/08/28 10:26:57 UTC

Bug in resource import in LvgAnnotator?

Hi,

On line 579 in org.apache.ctakes.lvg.ae.LvgAnnotator there is the following resource import:
          ExternalResourceFactory.createExternalResourceDescription(
              LvgCmdApiResourceImpl.class,
              new File(LvgCmdApiResourceImpl.class.getResource(
                  "/org/apache/ctakes/lvg/data/config/lvg.properties").toURI()))
          );

The .getResource() call breaks when the package is imported as a jar (from Maven central), with an error stating that the "URI is not hierarchical". According to:
http://stackoverflow.com/questions/18055189/why-my-uri-is-not-hierarchical
the call should instead use .getResourceAsStream().

Is this a bug, or am I doing something wrong? I'm not very familiar with how Java handles resources in general.

Jakob

Re: Bug in resource import in LvgAnnotator?

Posted by Pei Chen <ch...@apache.org>.
Hi Jakob,
Yes, there is currently a limitation in the LVG component to have
their jar unpacked and added to the classpath.
I think there is an outstanding Jira to enable it read it from a jar
like the rest of the jars.  (There are some limitations such as
hsql/lucene not being able to read directly from a jar hence it's been
outstanding.)
--Pei

On Fri, Aug 28, 2015 at 4:26 AM, Jakob Rogstadius
<Ja...@who-umc.org> wrote:
> Hi,
>
> On line 579 in org.apache.ctakes.lvg.ae.LvgAnnotator there is the following resource import:
>           ExternalResourceFactory.createExternalResourceDescription(
>               LvgCmdApiResourceImpl.class,
>               new File(LvgCmdApiResourceImpl.class.getResource(
>                   "/org/apache/ctakes/lvg/data/config/lvg.properties").toURI()))
>           );
>
> The .getResource() call breaks when the package is imported as a jar (from Maven central), with an error stating that the "URI is not hierarchical". According to:
> http://stackoverflow.com/questions/18055189/why-my-uri-is-not-hierarchical
> the call should instead use .getResourceAsStream().
>
> Is this a bug, or am I doing something wrong? I'm not very familiar with how Java handles resources in general.
>
> Jakob