Java grails应用程序中的上下文为只读错误
我试图使用grails应用程序中的示例使用de GROBID JAVA API。 以下JAVA代码(Netbeans)运行良好:Java grails应用程序中的上下文为只读错误,java,grails,Java,Grails,我试图使用grails应用程序中的示例使用de GROBID JAVA API。 以下JAVA代码(Netbeans)运行良好: public static void main(String[] args) { // TODO code application logic here String pdfPath = "/home/jose/plantilla_Informatica_2015 (ok).pdf"; String pathGHome = "/home/jo
public static void main(String[] args) {
// TODO code application logic here
String pdfPath = "/home/jose/plantilla_Informatica_2015 (ok).pdf";
String pathGHome = "/home/jose/GROBID_COMPILED/grobid-home";
String pathGProp = "/home/jose/GROBID_COMPILED/grobid-home/config/grobid.properties";
try {
MockContext.setInitialContext(pathGHome, pathGProp);
GrobidProperties.getInstance();
Engine engine = GrobidFactory.getInstance().createEngine();
BiblioItem bi = new BiblioItem();
String doc = engine.processHeader(pdfPath, false, bi);
System.out.println(doc);
} catch (Exception ex) {
Logger.getLogger(GROBID.class.getName()).log(Level.SEVERE, null, ex);
}
finally{
try{
MockContext.destroyInitialContext();
}
catch(Exception ex){
Logger.getLogger(GROBID.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
当我向grails复制具有相同依赖项集的相同代码时,
然后将grobid-core.jar放在文件夹lib中,它会告诉我错误:
| Error 2016-03-11 16:50:22,195 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - OperationNotSupportedException occurred when processing request: [GET] /GROB/grobid
Context is read only. Stacktrace follows:
Message: Context is read only
Line | Method
->> 961 | checkWritable in org.apache.naming.NamingContext
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 548 | createSubcontext in ''
| 574 | createSubcontext in ''
| 487 | createSubcontext in org.apache.naming.SelectorContext
| 483 | createSubcontext in javax.naming.InitialContext
| 37 | setInitialContext in org.grobid.core.mock.MockContext
| 76 | setInitialContext in ''
| 17 | index in grob.GrobidController
| 198 | doFilter . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . in java.lang.Thread
Process finished with exit code 137
我的Grobid管理员:
import org.grobid.core.data.BiblioItem
import org.grobid.core.engines.Engine
import org.grobid.core.factory.GrobidFactory
import org.grobid.core.mock.MockContext
import org.grobid.core.utilities.GrobidProperties
class GrobidController {
def index() {
String pdfPath = "/home/jose/plantilla_Informatica_2015 (ok).pdf"
String pathGHome = "/home/jose/GROBID_COMPILED/grobid-home"
String pathGProp = "/home/jose/GROBID_COMPILED/grobid-home/config/grobid.properties"
MockContext.setInitialContext(pathGHome, pathGProp)
GrobidProperties.getInstance()
Engine engine = GrobidFactory.getInstance().createEngine()
BiblioItem bi = new BiblioItem()
String doc = engine.processHeader(pdfPath, false, bi)
println(doc)
MockContext.destroyInitialContext()
}
}
我的BuildConfig依赖项:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
compile "directory-naming:naming-java:0.8"
compile "org.slf4j:slf4j-api:1.7.7"
compile "org.apache.commons:commons-lang3:3.1"
compile "com.cybozu.labs:langdetect:1.1-20120112"
compile "com.google.collections:google-collections:1.0"
compile "net.arnx:jsonic:1.3.5"
compile "fr.limsi.wapiti:wapiti:1.5.0"
compile "commons-io:commons-io:2.0.1"
compile "com.google.guava:guava:16.0.1"
compile "xom:xom:1.2.5"
compile "org.slf4j:slf4j-log4j12:1.7.7"
compile "log4j:log4j:1.2.17"
}
###编辑#####
如果我构建同一个应用程序的war并使用
grails run-war target/GROB-0.1.war
它工作得很好
会发生什么?
有什么帮助吗?
感谢您的建议。作为第一步,您是否添加了grobid作为依赖项<代码>编译'org.grobid:grobid核心:0.3.4'该异常来自Tomcat。您可以在这里看到:代码运行时是否使用Tomcat?我在lib文件夹中复制了grobid的最新版本(称为grobid-core-0.4.0-SNAPSHOT.jar),在BuildConfig.groovy中添加了compile“org.grobid:grobid-core:0.4.0”,控制台打印:解决获取依赖项的错误:读取org的工件描述符失败。grobid:grobid core:jar:0.4.0(使用--stacktrace查看完整跟踪)@EmmanuelRosa是的,我正在使用tomcat,如何修复此错误?谢谢你的时间!作为第一步,您是否添加了grobid作为依赖项<代码>编译'org.grobid:grobid核心:0.3.4'该异常来自Tomcat。您可以在这里看到:代码运行时是否使用Tomcat?我在lib文件夹中复制了grobid的最新版本(称为grobid-core-0.4.0-SNAPSHOT.jar),在BuildConfig.groovy中添加了compile“org.grobid:grobid-core:0.4.0”,控制台打印:解决获取依赖项的错误:读取org的工件描述符失败。grobid:grobid core:jar:0.4.0(使用--stacktrace查看完整跟踪)@EmmanuelRosa是的,我正在使用tomcat,如何修复此错误?谢谢你的时间!