I am trying to use GROBID ( link ) in an application in grails. I tried the basic example that comes in the Java documentation from the Netbeans and it works fine, but in grails I get the error:
| Error 2016-03-13 16:37:59,899 [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 ''
| 24 | getText in Grob.test
| 9 | 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
The best thing is that if I create the .war of the application and deploy it (either from the mimso grails or from a local tomcat server) everything works as I hope
This is the test.java class:
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;
import java.io.File;
public class test {
public String getText() throws Exception {
String root = "/media/jose/Datos/DOCUMENTS/Datos/Gobid/GROBID_COMPILED";
String pdfPath = root + File.separator + "doc" + File.separator + "GROBID.pdf";
String pathGHome = root + File.separator + "grobid-home";
String pathGProp = root + File.separator + "grobid-home" + File.separator + "config" + File.separator + "grobid.properties";
String resp = "";
MockContext.setInitialContext(pathGHome, pathGProp);
GrobidProperties.getInstance();
Engine engine = GrobidFactory.getInstance().createEngine();
BiblioItem bi = new BiblioItem();
resp = engine.processHeader(pdfPath, false, bi);
MockContext.destroyInitialContext();
return resp;
}
}
and this is the controller where I call it GrobidController.groovy:
package grob
import Grob.test
class GrobidController {
def index() {
def g = new test()
def resp = g.getText()
[resp: resp]
}
}
Someone can tell me what is wrong. Thanks in advance.