Tomcat

2017-03-31  本文已影响131人  月寒兮夜凉
收纳目录
  1. 文件下载失败(POI)
  2. 项目启动失败(MAVEN)

1.文件下载失败(POI)

异常信息:

Caused by: java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at java.io.File.createTempFile(Unknown Source)
    at org.apache.poi.util.TempFile$DefaultTempFileCreationStrategy.createTempFile(TempFile.java:105)
    at org.apache.poi.util.TempFile.createTempFile(TempFile.java:60)
    at org.apache.poi.xssf.streaming.SheetDataWriter.createTempFile(SheetDataWriter.java:80)
    at org.apache.poi.xssf.streaming.SheetDataWriter.<init>(SheetDataWriter.java:63)
    at org.apache.poi.xssf.streaming.SheetDataWriter.<init>(SheetDataWriter.java:68)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheetDataWriter(SXSSFWorkbook.java:295)
    at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:75)
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:636)
    ... 115 more

出错原因:使用POI导出文件时会在服务器的临时文件夹中生成临时文件,当前若无该文件夹或没有操作该文件的权限,则下载失败。
解决方案:查看tomcat的临时文件夹(TOMCAT_HOME\bin\catalina.bat文件中的-Djava.io.tmpdir参数,或打开tomcat启动窗口,“Java”页中有Java Options属性的-Djava.io.tmpdir参数),修改此参数值为一个存在并且有操作权限的文件夹路径;
致谢:
CSDN > shiyonghm > POI导出文件报错 java.lang.RuntimeException: java.io.IOException: 系统找不到指定的路径。


2.项目启动失败(MAVEN)

异常信息:

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/assm]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 7 more
Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
    at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1670)
    at org.apache.catalina.startup.ContextConfig.getServletContainerInitializers(ContextConfig.java:1652)
    at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1562)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more

出错原因:当程序运行时,javax.servlet的依赖jar与tomcat中已经存在的jar产生冲突,致使tomcat启动失败。
解决方案:修改MAVEN依赖jar的作用范围(在依赖节点添加<scope>provided</scope>属性),避开tomcat的使用时段;
致谢:
CSDN > white1black0 > Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer c

最后
上一篇下一篇

猜你喜欢

热点阅读