32

I have a freshly installed Tomcat 7 server, and I'm trying to make IntelliJ deploy a HelloWorld Spring MVC app to Tomcat.

My Tomcat home is /usr/share/tomcat7 and Tomcat base is /var/lib/tomcat7

However, when I try to run the project, IntelliJ throws an error saying:

Error running Tomcat : Error copying configuration files from /var/lib/tomcat7/conf to /home/adonis/.IntelliJIdea12/system/tomcat/Tomcat__SpringMVCApp/conf : /var/lib/tomcat7/conf/tomcat-users.xml (Permission denied)

Here is a screenshot - https://i.stack.imgur.com/Jm7xJ.png

Any permissions I need to set up?

Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74

7 Answers7

41

Try chmod -R 777 /var/lib/tomcat7/conf/, it works to me.

Wanna Coffee
  • 2,742
  • 7
  • 40
  • 66
Rodrigo Hime
  • 511
  • 4
  • 4
  • 2
    This only helped me. Thank you – Yauhen Nov 20 '14 at 22:23
  • Since this is the highest voted answer I'd just like to add that this makes the directory writable for any user on your system. This may be an unwanted side effect for some. – Maritim Feb 08 '23 at 11:12
34

Make sure that files under /var/lib/tomcat7/conf/ directory have read permission for the user IntelliJ IDEA is running from.

chmod -R 644 /var/lib/tomcat7/conf/

should help.

Also check that /home/adonis/.IntelliJIdea12/system/tomcat/ has correct permissions and owner. Could be that it was created from a different user and your current user doesn't have the rights to write into it.


If it doesn't help, download and unpack a new Tomcat installation from .tar.gz file, configure IDEA to use this installation instead.

Note that Tomcat installed using the package manager on some Linux systems has non-standard layout and permissions, and therefore will not work with IDEA.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 1
    I contacted JetBrains support about this, and they too replied exactly like you did. However, after `chmod`ing the `conf` folder, the tomcat instance running at localhost:8080 stopped.. and the original IntelliJ error remains as it is.. I'll try out the newer installation as you said.. – Hrishikesh Choudhari May 07 '13 at 21:28
  • 27
    I'm JetBrains support who replied you. – CrazyCoder May 07 '13 at 21:29
  • 1
    Note that if you already have Tomcat running, IDEA will not be able to start a second copy as the ports are already taken. You will have to either shut down this Tomcat copy before starting it from IDEA or modify the ports in `conf/server.xml`, not just the HTTP connector port, but SHUTDOWN port as well so that there are no conflicts. – CrazyCoder May 07 '13 at 21:31
  • Thanks for helping me out. I did as you said - Downloaded a new installation and pointed it to IDEA, and `chmod`ed the `conf` folder to 644, yet the error remains in IDEA. I have no other tomcat instance running. – Hrishikesh Choudhari May 07 '13 at 21:46
  • And I've changed the startup and shutdown ports of the older tomcat's server.xml too.. – Hrishikesh Choudhari May 07 '13 at 21:47
  • Attach [idea.log](http://intellij-support.jetbrains.com/entries/23352446). Note that you don't have to `chmod` the new installation. – CrazyCoder May 07 '13 at 21:47
  • Here is the idea.log - https://gist.github.com/hrishikeshchoudhari/5536476#file-gistfile1-txt – Hrishikesh Choudhari May 07 '13 at 21:55
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/29564/discussion-between-crazycoder-and-hrishikesh-choudhari) – CrazyCoder May 07 '13 at 21:57
  • I also had to give the execute permission on the directory as some distribution make link of `conf` to `/etc/tomcat7`, I did it with : `sudo chmod -R +X /etc/tomcat7`. – bric3 Oct 09 '15 at 17:58
  • my directory was located at /usr/share/tomcat7/conf/ – Smile4ever Dec 24 '15 at 11:54
  • @CrazyCoder I'm currently facing a similar problem. You say that ~/IntelliJIdea/system/tomcat/ should have "correct" permissions? what are the correct permission setting exactly? is there such a thing as too liberal? (mine is configured to 777) permission denied would be kind of wierd error to get if that's the case, but I've chased all the other rabits down their holes now so.... – Anders Martini Sep 20 '16 at 09:30
  • nvm, turns out my /var/lib/tomcat8/conf/ was actually a symlink, so changing permissions on it didn't help me because the folder it linked to continued to have restrictive permissions...if you have permission problems, watch out for symlinks people! – Anders Martini Sep 20 '16 at 09:50
  • @CrazyCoder my /home/pranav/.IntelliJIdea12/system/tomcat/ look like this: https://pastebin.com/CRriQVfB Is it ok? Or, should I need to run "chmod -R 644" to this folder too? –  Aug 06 '19 at 16:12
12

I had the same problem and these steps helped me to Start my tomcat7 from Intellij :

I have Linux Mint 17,and Tomcat 7 which is installed using apt-get

CATALINA_HOME in /usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7

1- First I created a soft link which references /etc/tomcat7

cd /usr/share/tomcat7
ln -s /etc/tomcat7 conf

2- Then you have to change the access permissions of /etc/tomcat7

sudo chmod -R 655 /etc/tomcat7/

That's it.

Kayvan Tehrani
  • 3,070
  • 2
  • 32
  • 46
6

For me, this worked for Tomcat 8 on Manjaro Linux:

sudo chmod -R 755 /usr/share/tomcat8/
Smile4ever
  • 3,491
  • 2
  • 26
  • 34
1

I added my own user account to the tomcat7 group.

And chmod g+r /var/lib/tomcat7/conf/tomcat-users.xml

  • Same as you on Fedora but need to set write permission for the group : `sudo chmod g+w /usr/share/tomcat/conf/tomcat-users.xml`. – Doc Davluz Aug 26 '20 at 07:08
1

Had the same error with usr/share, dont just blindly run a command to act as magic-wand as many just tell you you run this and that on a mother-directory.

this is Linux, always some stupid thing with the permissions.

all you garra do is using chmod 666 or chmod 777 on files that are causing the error, but you need to look at those files first using ll and ls to make sure you are not decreasing some access, you may have a directory with 77x and when you do 666 you mess things up.

just gradually and one by one increase the chmod level and check whether problem goes away or not.

Sorry I didn't give you some code to fix all the problems.

Aramis NSR
  • 1,602
  • 16
  • 26
0

This also happens to me, and I managed to solve it for Tomcat version 9, this problem is related to the configuration of Tomcat and you just need to give it permissions to be deployed.

You can use this link for more instructions.

Moritz
  • 1,954
  • 2
  • 18
  • 28