2013-03-31 20 views
0

使用ant构建JSGFDemo时,一切正常。运行JSGFDemo.jar构建工件没有任何错误。然而,使用在eclipse导入的源文件夹时,并添加在lib /目录的罐子到构建路径,使用以下信息的程序中的错误:狮身人面像语法位置无法找到资源

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/ 

出于某种原因,在ConfigurationManagerUtils.resourceToURL(String location)看似返回调用ConfigurationManagerUtils.class.getResource(resourceName); location =“resource:/ edu/cmu/sphinx/demo/jsapi/jsgf /”的不同结果。 (null,或者一个有效的URL对象)

作为旁注,我认为getResource(“/ path/to/a/dir/not/file /”);在它解析为jar内的路径时无效。

我一直对我的头撞了一会儿,看不到我做错了什么。

+0

缺少资源的唯一原因是缺少资源。这个错误意味着你的类路径中没有相应的路径。可能您以不同的方式命名了该软件包,并且未更改config.xml文件中的路径。您需要提供更多关于您的项目布局的信息,您的项目的文件结构是什么等,才能获得更有意义的答案。 –

+0

@NikolayShmyrev从我可以告诉,罐子有相同的文件结构。看看他们,如果你想要的话:https://docs.google.com/file/d/0B4ayCXFZPsx8aU5DeGRXb1VpNm8/edit 我不明白如果我附加一些特定文件的文件名,但是,如资源:/ edu/cmu/sphinx/demo/jsapi/jsgf/commands.gram,但显然这在sphinx尝试引用资源时不起作用:/edu/cmu/sphinx/demo/jsapi/jsgf/command.gram/command 。公克 – remuladgryta

回答

1

我相信找到了问题。默认情况下,Eclipse似乎以不同的方式构造该jar,从而为目录留下条目。

使用unzip -v调查存档可以发现一些有趣的细节。从使用Ant构建

文件:使用eclipse

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 

罐出口:

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 

快速谷歌后,我发现在Eclipse的JAR导出向导 “添加目录条目” 选项。