我的申请中存在问题。
它通过Crawler4j从网站获取数据,它需要创建一些目录和文件来操作数据,但tomcat没有授予权限。答案是这样的:
无法创建此文件夹:/ data / crawl / root
如何配置tomcat以授予外部jar在我的应用程序中创建目录和文件的权限?
源代码可在以下网址找到:https://github.com/MarcelorjOliveira/CrawlerSpring
这里有完整的堆栈跟踪
堆栈跟踪: 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)
根本原因
org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是java.lang.Exception:无法创建此文件夹:/ 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)
根本原因
java.lang.Exception:无法创建此文件夹:/ 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(原生方法) 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)
谢谢大家。
答案 0 :(得分:0)
我找到了答案。
这是因为在开头有一个破折号,它试图在系统的开头创建一个目录,而用户没有权限。
我已经更改了文件夹,一切正常。