9

I installed Tomcat 7 following the Ubuntu guide. The server is working and gives me the "It works!" page on http://localhost:8080/.

Now I want to setup my own webapp using Netbeans. I generated a new Web Project with Java EE 6 and Tomcat 7. The user is on the /var/lib/tomcat7/conf/tomcat-users.xml file properly configured.

When I run the project everything seems ok, but when I open the browser it displays a 500 error.

  • The Tomcat output mentions permission errors trying to access tomcat7/logs and
  • The IDE logs trying to access tomcat7/conf.

Files permissions:

lucio@lucio-pc:/$ ll /var/lib/tomcat7/logs
lrwxrwxrwx 1 root root 17 jul 24 18:07 /var/lib/tomcat7/logs -> ../../log/tomcat7/
lucio@lucio-pc:/$ ll /var/log/tomcat7/
total 136
drwxr-x---  2 tomcat7 adm      4096 ago 28 10:50 ./
drwxrwxr-x 15 root    syslog   4096 ago 28 09:29 ../
-rw-r--r--  1 tomcat7 tomcat7   800 ago 26 17:23 catalina.2014-08-26.log.gz
-rw-r--r--  1 tomcat7 tomcat7  5173 ago 27 21:59 catalina.2014-08-27.log
-rw-r--r--  1 tomcat7 tomcat7 31285 ago 28 10:36 catalina.2014-08-28.log
-rw-r--r--  1 tomcat7 root    44192 ago 28 10:36 catalina.out
-rw-r--r--  1 tomcat7 tomcat7    45 ago 26 16:19 localhost.2014-08-26.log.gz
-rw-r--r--  1 tomcat7 tomcat7     0 ago 27 11:15 localhost.2014-08-27.log
-rw-r--r--  1 tomcat7 tomcat7   433 ago 28 09:49 localhost.2014-08-28.log
-rw-r--r--  1 tomcat7 tomcat7  7435 ago 26 17:23 localhost_access_log.2014-08-26.txt
-rw-r--r--  1 tomcat7 tomcat7     0 ago 27 11:15 localhost_access_log.2014-08-27.txt
-rw-r--r--  1 tomcat7 tomcat7 15186 ago 28 09:58 localhost_access_log.2014-08-28.txt

I don't understand why can't access the files, you can see that the user and group tomcat7 has permissions to the files. Is there a user for the JVM that needs privileges over the files?

I also tried changing files ownerships as mentioned here but it doesn't change at all.


The /etc/default/tomcat7 file has:

TOMCAT7_USER=tomcat7
TOMCAT7_GROUP=tomcat7

So I guess it is running as tomcat7 user.


I added my user into the tomcat7 group:

sudo usermod -aG tomcat7 $USER

And then restarted the machine, but the problem persist.

4
  • Is tomcat running as the tomcat7 user?
    – muru
    Aug 26, 2014 at 22:26
  • It's been too long since I used tomcat, but 2 things occur to me: Don't you need to be in the tomcat7 group to allow the program to access the log? And also, it seems like it really wants to access a temp file in /var/lib/tomcat7/temp; does that exist? It may be the same permission problem. Maybe you just need to add yourself to the tomcat7 group. Aug 26, 2014 at 22:29
  • Also, you would need to make the files group writable to use my idea. And there is more information here that might help. Aug 26, 2014 at 22:40
  • It seems the user (human or application) that run tomcat7 don't have the permission to access /var/lib/tomcat7/ and especially the logs folder. Aug 27, 2014 at 7:30

1 Answer 1

10
+50

I noticed two problems here.

Two lines in the error log stood out to me:

SEVERE: Cannot find specified temporary folder at /var/lib/tomcat7/temp  

and:

java.io.FileNotFoundException: /var/lib/tomcat7/conf/tomcat-users.xml (Permission denied)

Doing a bit of diagnosis with Lucio, I figured out that the tomcat-users.xml file was not owned by Tomcat, but instead root. Change the permissions to the proper ones by running the command:

sudo chown tomcat7:tomcat7 /var/lib/tomcat7/conf/tomcat-users.xml

Also, create the folder /var/lib/tomcat7/temp with tomcat permissions, like so:

sudo mkdir /var/lib/tomcat7/temp && sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/temp

Finally, fixing the logs should be done by making /var/lib/tomcat7/logs owned by the tomcat7 user/group. The /var/log/tomcat7/ should also be owned by the tomcat7 user AND group.

1
  • For me, changing the permissions on the tomcat-user.xml file was enough. Doing the same for the logs didn't worked but the application is running anyway :-)
    – Lucio
    Aug 31, 2014 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .