Reaching a static folder in a web app with maven & tomcat

Viewed 20

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!

0 Answers
Related