Search code examples
javanetbeansdeploymenttomee-8

netbeans unable to copy context xml file from temp folder to tomee's localhost when deploy. FileNotFoundException(access denied)


netbeans unable to copy context xml file from AppData\Local\Temp\ folder to tomee's conf\Catalina\localhost when deploy.

already tried:

deploy to tomee 7.0.X is fine but tomee 8.0.0 fail.

fatal error in stderr.log

03-Oct-2019 16:31:22.358 fatal [http-nio-9200-exec-6] org.apache.catalina.startup.ExpandWar.copy Error copying [C:\Users\xxx\AppData\Local\Temp\context2716699461818377726.xml] to [D:\Tomee\apache-tomee-plus-8.0.0\conf\Catalina\localhost\myApp.xml] java.io.FileNotFoundException: C:\Users\xxx\AppData\Local\Temp\context2716699461818377726.xml (Access is denied.) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at org.apache.catalina.startup.ExpandWar.copy(ExpandWar.java:276)


Solution

  • This problem only occurs when Tomee is running as a Windows service.
    I tested version 7.0.4~8.0.0 to get the following conclusions.

    The Tomee runs the service with the LocalSystem account before version 7.0.6.
    Starting with version 7.0.6, the service is run with the LocalService account, so that the permissions are insufficient.

    The following two ways can solve the issue:
    - Give the LocalService account access to the directory AppData\Local\Temp\.
    - Specifying the Tomee runs the service with the LocalSystem account when installing the service.
       service install %serviceName% --service-user LocalSystem