0

When building the JSGFDemo using ant, everything works fine. Running the JSGFDemo.jar build artifact works without any errors. However, when using source folder imported in eclipse, and adding the jars in the lib/ directory to the build path, the program errors with the following message:

Problem configuring recognizerProperty exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:/edu/cmu/sphinx/demo/jsapi/jsgf/
edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:/edu/cmu/sphinx/demo/jsapi/jsgf/

For some reason the call to ConfigurationManagerUtils.class.getResource(resourceName); in ConfigurationManagerUtils.resourceToURL(String location) seemingly returns different results for location = "resource:/edu/cmu/sphinx/demo/jsapi/jsgf/". (null, or a valid URL-object)

As a sidenote, I thought getResource("/path/to/a/dir/not/file/"); was invalid when it would resolve to a path inside a jar.

I've been banging my head against this for a while now and can't see what I'm doing wrong.

remuladgryta
  • 101
  • 1
  • 1
  • 10
  • The only reason for missing resource is missing resource. This error means you do not have the corresponding path in your classpath. Probably you named the package differently and didn't change the path in config.xml file. You need to provide more information about your project layout, what is the file structure of your project and so on in order to receive more meaningful answer. – Nikolay Shmyrev Mar 31 '13 at 13:14
  • @NikolayShmyrev From what I can tell, the jars have identical file structure. Have a look at them if you want: https://docs.google.com/file/d/0B4ayCXFZPsx8aU5DeGRXb1VpNm8/edit I don't get the error if i append the filename of some specific file however, like resource:/edu/cmu/sphinx/demo/jsapi/jsgf/commands.gram, but obviously this doesn't work later when sphinx tries to refer to resource:/edu/cmu/sphinx/demo/jsapi/jsgf/command.gram/command.gram – remuladgryta Mar 31 '13 at 21:42

1 Answers1

1

I believe to have found the issue. By default, Eclipse seems to construct the jar differently, leaving out entries for directories.

Investigating the archives with unzip -v reveals some interesting details.

File from building with Ant:

Archive:  JSGFDemo.jar
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2013-03-31 03:13 00000000  META-INF/
     284  Defl:N      210  26% 2013-03-31 03:13 ddd976ff  META-INF/MANIFEST.MF
       0  Stored        0   0% 2013-03-31 03:08 00000000  edu/
       0  Stored        0   0% 2013-03-31 03:08 00000000  edu/cmu/
       0  Stored        0   0% 2013-03-31 03:13 00000000  edu/cmu/sphinx/
       0  Stored        0   0% 2013-03-31 03:12 00000000  edu/cmu/sphinx/demo/
       0  Stored        0   0% 2013-03-31 03:13 00000000  edu/cmu/sphinx/demo/jsapi/
       0  Stored        0   0% 2013-03-31 03:13 00000000  edu/cmu/sphinx/demo/jsapi/jsgf/
    7391  Defl:N     3501  53% 2013-03-31 03:13 938438dd  edu/cmu/sphinx/demo/jsapi/jsgf/JSGFDemo.class
     798  Defl:N      326  59% 2013-03-31 03:13 647722fc  edu/cmu/sphinx/demo/jsapi/jsgf/books.gram
     204  Defl:N      140  31% 2013-03-31 03:13 789bb514  edu/cmu/sphinx/demo/jsapi/jsgf/commands.gram
    9295  Defl:N     1500  84% 2013-03-31 03:13 3b519044  edu/cmu/sphinx/demo/jsapi/jsgf/jsgf.config.xml
    1589  Defl:N      473  70% 2013-03-31 03:13 60075af0  edu/cmu/sphinx/demo/jsapi/jsgf/movies.gram
     299  Defl:N      195  35% 2013-03-31 03:13 42e94d32  edu/cmu/sphinx/demo/jsapi/jsgf/music.gram
     666  Defl:N      288  57% 2013-03-31 03:13 ca4b72f9  edu/cmu/sphinx/demo/jsapi/jsgf/news.gram
--------          -------  ---                            -------
   20526             6633  68%                            15 files

Jar exported using eclipse:

Archive:  JSGFDemo-eclipse.jar
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     180  Defl:N      134  26% 2013-03-31 23:35 1e681d3b  META-INF/MANIFEST.MF
    7338  Defl:N     3537  52% 2013-03-31 23:29 ed8c4c3f  edu/cmu/sphinx/demo/jsapi/jsgf/JSGFDemo.class
     798  Defl:N      326  59% 2013-03-31 13:21 647722fc  edu/cmu/sphinx/demo/jsapi/jsgf/books.gram
     204  Defl:N      140  31% 2013-03-31 13:21 789bb514  edu/cmu/sphinx/demo/jsapi/jsgf/commands.gram
    9295  Defl:N     1500  84% 2013-03-31 13:21 3b519044  edu/cmu/sphinx/demo/jsapi/jsgf/jsgf.config.xml
    1589  Defl:N      473  70% 2013-03-31 13:21 60075af0  edu/cmu/sphinx/demo/jsapi/jsgf/movies.gram
     299  Defl:N      195  35% 2013-03-31 13:21 42e94d32  edu/cmu/sphinx/demo/jsapi/jsgf/music.gram
     666  Defl:N      288  57% 2013-03-31 13:21 ca4b72f9  edu/cmu/sphinx/demo/jsapi/jsgf/news.gram
--------          -------  ---                            -------
   20369             6593  68%                            8 files

After a quick google, I found the "Add directory entries" option in Eclipse's jar export wizard.

remuladgryta
  • 101
  • 1
  • 1
  • 10