惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - 星小梦

vue2的devtools开发工具卡死现象的解决方法 echarts图表在浏览器上打印出现裁剪的问题 apache echarts数据点重影或 Cannot read properties of undefined (reading 'type')错误问题 yarn install出现error Error: certificate has expired异常 git多代码仓库合并的方式 docker容器oshi如何获取宿主机的运行状态信息? su命令引起的nohup进程以root身份启动导致的问题 docker-compose启动服务,影响其他服务的原因 xxl-job provider netty_http server caught exception flutter升级导致的旧项目的运行环境问题排查记录 vue3插件库以及对JSX的支持。 JSX、TSX扩展语法学习材料 commitlint Lint 提交消息格式控制 Chromium历史版本下载方式 Window10 关闭Edge浏览器的多选项卡通过Alt+Tab组合键切换的方式 Postgres16数据库集成外部库dblink和postgres_fdw扩展的方式 java 泛型类型如何保留类型的信息的方式 Postgres16 常见问题 docker镜像安装字体支持,解决jdk服务验证码生成找不到字体问题 window和Linux命令行执行多条命令的方法
Linux系统调整java程序启动用户,导出xlsx时抛出Permission denied异常问题。
星小梦 · 2026-05-07 · via 博客园 - 星小梦

jdk1.8环境
出现的原因就是原先的java服务启动是root启动的,之后由于安全原因,由Linux子用户进行启动java服务,导致的导出xlsx时出现错误,错误信息如下:

java.lang.RuntimeException: java.io.IOException: Permission denied
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:688)
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:676)
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:88)
	at com.ruoyi.common.utils.poi.ExcelUtil.createSheet(ExcelUtil.java:605)
	at com.ruoyi.common.utils.poi.ExcelUtil.exportExcel(ExcelUtil.java:248)
	at com.ruoyi.common.utils.poi.ExcelUtil.exportExcel(ExcelUtil.java:221)
	at com.cqcs.effie.admin.JudgeLibraryCtrl.selectExport(JudgeLibraryCtrl.java:767)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

java程序使用的临时目录位置是/tmp
经过分析是org.apache.poi.util.DefaultTempFileCreationStrategy#createPOIFilesDirectory方法默认创建了临时目录导致的,之前的目录是root创建的,所以在使用Linux
子用户启动java服务后,就会导致导出excel失败。

poi基础入口点:
org.apache.poi.xssf.streaming.SXSSFWorkbook#createSheetDataWriter:
image

问题代码处:
org.apache.poi.util.DefaultTempFileCreationStrategy#createPOIFilesDirectory:
image

修复方法:
调整/tmp/poifiles的目录权限即可,执行chown -R <用户>:<用户组> /tmp/poifiles命令即可,<>里的内容替换为自己的java程序使用的用户。

查询Linux系统java环境临时目录的位置: /usr/local/jdk8/bin/java -XshowSettings:properties -version 2>&1 | grep 'java.io.tmpdir'