Windows Server 2019部署Talend作业调用Selenium时创建扩展解压临时目录失败的问题求助
I’ve dealt with this exact frustrating error on Windows Server environments before, so let’s dig into what might be missing from the fixes you’ve already tried.
First, let’s recap your scenario to align:
- You’re running a Java-based Talend job with Selenium ChromeDriver
- Works perfectly locally, but fails on Windows Server 2019 with this error:
Could not start a new session. Response code 500. Message: unknown error: cannot create temp dir for unpacking extensions
Your current ChromeOptions code:
Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("download.default_directory", "C:\\data\\"); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", prefs); options.addArguments("--no-sandbox"); options.addArguments("--headless"); options.addArguments("--disable-gpu"); options.addArguments("--disable-dev-shm-usage"); options.addArguments("--profile-directory=Default"); options.addArguments("--user-data-dir=C:\\Temp"); WebDriver driver = new ChromeDriver(options); // Rest of your execution code...
You’ve already gone through a solid list of troubleshooting steps: setting TMP/TEMP environment variables, running chromedriver as admin, adjusting --user-data-dir, cleaning temp folders, verifying disk space, rebooting, downgrading chromedriver versions, and tweaking group policies.
Here are targeted additional fixes that often resolve this on Windows Server:
1. Double-Check Folder Permissions for the Job User
Even if you set --user-data-dir to C:\Temp, Chrome may still attempt to use the system temp directory (controlled by TMP/TEMP) for extension unpacking. Ensure the user running the Talend job has:
- Full read/write/modify permissions on
C:\Temp - Full permissions on the default user temp path (usually
C:\Users\<JobRunningUser>\AppData\Local\Temp) - If the job runs as a Windows Service, verify the service account has unrestricted access to these folders—service accounts often have limited permissions even with global TMP var changes.
2. Explicitly Override Chrome’s Temp Directory
Chrome has a hidden command-line argument to force its temp folder location. Add this to your ChromeOptions:
options.addArguments("--temp-dir=C:\\Temp\\ChromeExclusiveTemp");
Create the ChromeExclusiveTemp folder first, and confirm the job user has full access to it. This bypasses system temp var inconsistencies that are common on server setups.
3. Adjust Chrome Installation Permissions
If Chrome is installed system-wide (in C:\Program Files), the job user might lack write access to Chrome’s internal extension folders. Try:
- Installing Chrome for the specific user running the Talend job (instead of system-wide)
- Granting the job user read/write permissions to
C:\Program Files\Google\Chrome\Applicationand its subdirectories
4. Disable All Extension Loading
Since the error directly references extension unpacking, try disabling all extensions (including built-in ones) to rule out conflicts:
options.addArguments("--disable-extensions"); options.addArguments("--disable-plugins");
This is a temporary test, but it will confirm if the issue stems from extension-related temp folder access.
5. Check for Antivirus/Endpoint Protection Blocks
Windows Server often has strict antivirus or endpoint protection (like Windows Defender) that blocks writes to temp directories. Try:
- Adding
C:\Tempand Chrome’s installation folder to your antivirus exclusion list - Temporarily disabling antivirus (for testing only) to see if the error clears up
6. Run the Talend Job as a Local Admin (Temporarily)
Even if you set chromedriver to run as admin, the Talend job itself might be running with limited permissions. Test running the job under a local admin account—if this works, you can adjust permissions for the original job user instead of relying on admin access long-term.
7. Revert to Matching Latest Stable Chrome/ChromeDriver Versions
You tried downgrading, but sometimes newer versions patch server-specific bugs. Ensure both Chrome and ChromeDriver are on the exact same latest stable version (version mismatch is a common hidden culprit).
Let me know if any of these steps resolve your issue—this error is almost always tied to permission restrictions on Windows Server, so focusing on the job user’s folder access is key.
内容的提问来源于stack exchange,提问作者Nick Heidke

