0

As a newbie to developing web applications, I am developing an app (java 8, maven, tomcat, windows 10) using grobid.

enter image description here

To be able to use the grobid resources, I need to reach grobid-home folder (see the capture that it is under resources folder) as mentioned here grobid

The code to find home folder is:

String pGrobidHome = "src/main/resources/grobid-home";
GrobidHomeFinder grobidHomeFinder = new GrobidHomeFinder(Arrays.asList(pGrobidHome));
GrobidProperties.getInstance(grobidHomeFinder);

and this works fine when I run my code locally (w/o tomcat). PS. I run my code using WSL to be able to run it on linux system.

However, when I use the same code part in my app changing the path with,

ServletContext ctx=getServletContext();
String path = ctx.getRealPath("/WEB-INF/classess");

I got the following error:

Unsupported protocol for Grobid home at location: file:/C:/Users/u0156666/TOMCAT/apache-tomcat-9.0.65/webapps/webapp_war/WEB-INF/classes/grobid-home/lexicon/names/firstname.5k

org.grobid.core.main.GrobidHomeFinder.fail(GrobidHomeFinder.java:92)
    org.grobid.core.main.GrobidHomeFinder.getGrobidHomePathOrLoadFromClasspath(GrobidHomeFinder.java:141)
    org.grobid.core.main.GrobidHomeFinder.findGrobidHomeOrFail(GrobidHomeFinder.java:53)
    org.grobid.core.utilities.GrobidProperties.getInstance(GrobidProperties.java:97)
    main.java.mainProcess.<init>(mainProcess.java:48)
    main.java.FileUploadServlet.doPost(FileUploadServlet.java:55)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Apparently the way I get the path to the home-folder is not correct. So how should I reach a folder when I run my application on a server?

Thanks in advance!

mlee_jordan
  • 772
  • 4
  • 18
  • 50
  • 1
    My response, with the link to the discussion leading to the correct answer was deleted. The discussion can be found here: https://github.com/kermitt2/grobid/issues/949. TLDR: it was an issue in the configuration of the servlet context https://github.com/kermitt2/grobid/issues/949#issuecomment-1254968830 – Luca Foppiano Jun 02 '23 at 08:56

0 Answers0