Permission external jar create file tomcat

657 views Asked by At

I am with a problem in my application.

It obtains data from websites through Crawler4j and it needs to create some directories and files to manipulate data, but tomcat doesn't give permissions. The answer is like that:

Couldn't create this folder: /data/crawl/root

How to configure tomcat to give permission for external jars to create directories and files in my application?

Source code can be found in: https://github.com/MarcelorjOliveira/CrawlerSpring

Full stacktrace here

Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

root cause

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.Exception: Couldn't create this folder: /data/crawl/root org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:738) org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:708) org.apache.jsp.index_jsp._jspService(index_jsp.java:65) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

root cause

java.lang.Exception: Couldn't create this folder: /data/crawl/root edu.uci.ics.crawler4j.crawler.CrawlController.(CrawlController.java:83) br.com.crawlerspring.controller.MainController.initCrawler(MainController.java:52) br.com.crawlerspring.controller.MainController.main(MainController.java:66) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:738) org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:708) org.apache.jsp.index_jsp._jspService(index_jsp.java:65) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

Thanks for all.

1

There are 1 answers

0
Marcelo On

I've found an answer.

It was because a dash in the beginning and it tries to create a directory in the beginning of the system and the user doesn't have permission to that.

I've already changed the folder and all is working.