• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error starting Tomcat in Ubuntu

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

I'm unable to start Tomcat in my Ubuntu partition. The reason is as below:


 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After changing the permissions to 777, it seemed to work fine.
 
JavaMonitor Support
Posts: 251
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
777 means: own my box. Anyone can now write that file and make your filesystem flow full.

Use the right permissions.

Kees Jan
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which one should I use? 666???
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem was, when I try to start Tomcat it says that it cannot touch the catalina.out because it does not have enough permissions. I now used 764, but still it gives me the headache.
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ideally you have to create user and group for running Tomcat, after that configure the operation system to use created account to launch Tomcat.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that you started tomcat previously using some other account (possibly root) and so the permissions were set for that user, not you. Run the following command and post the output:
  • The first thing you should see is a set of permissions. If you used permission bit map 764 then it probably reads -rwxrw-r--
  • The next thing you will see is the number of hard links to the file: it should be 1
  • The next column is the owner name (or number if tomcat was started with an account that no longer exists)
  • The next column is the group name (or number if tomcat was started with a group that no longer exists)

  • I wont bother with the other columns for now.

    As I mentioned earlier, if you specified 764 as the permission bit map, then you have specified that the owner gets "7" or "rwx" or "read + write + execute"; the group gets "6" or "rw-" or "read and write"; and the world gets "4" or "r--" or "read only"

    See how that worked? Each digit in the bit map corresponded to owner-group-world in that order, and the bits themselves are just a binary representation for the read bit, the write bit, and the execute bit. So if all 3 bits are turned on, then the equivalent bitmap will be 7.

    Since you specified that the world (anybody who has access to your linux box who is not the owner and not in the group) has read-only permissions, then you must be either the owner or in the group in order to write to that file. I am guessing that you are neither the owner nor in the group, since you got a permission error.

    You should have seen what group the file belongs to when you ran the "ls -l" command earlier. You can see what groups you belong to by issuing the "groups" command.

    Moving forward, from bad ideas to better ideas:

    You could change the file permissions to 666, however this is not a good solution.

    If you are convinced that nobody else is ever going to run tomcat on jothi-laptop, then you could consider changing the user and/or group to your own username or to a group that you belong to. This is normally a bad idea, but it might work for you since this does not appear to be a standard installation of tomcat, and since the box appears dedicated to you.

    Misha has the right idea with setting up a dedicated user (and group) to run tomcat. If you intend to have tomcat running all the time, then that is what I would do (and what I do do). Then add yourself to the same group that tomcat runs under, so that you can easily view the log files. Most of the time you can deploy / undeploy / restart web applications either through the tomcat web interface, or through ant, or through Eclipse or ... - basically all the standard ways that Tomcat provides so that Tomcat does not need to be restarted.

    In some development scenarios, there can be value in having a totally separate development area that you control. So the bulk of Tomcat (the main jars, binary files etc) stay in the default location (in your case /opt/softwares/apache-tomcat-6.0.26/...), but you set up a local area (e.g. /home/jothi/tomcat ) specifically for a particular development process. That way you only need your own personal deploy and work areas in your local directory (and a config directory if you want to play with configuration such as port numbers). This would mean that you (as in user "jothi" on the Linux box) owns everything outright: no special changing permissions.
     
    Joe San
    Ranch Hand
    Posts: 10198
    3
    Mac PPC Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    ls -l on catalina.out gave me the following.


     
    Joe San
    Ranch Hand
    Posts: 10198
    3
    Mac PPC Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok I changed it to my user and gave 666 and it now looks fine. But I could not understand one point is that I gave 666 on the top level folder (Tomcat installation folder), but why did it not change the subfolders permissioning?
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It depends on what you did.

    I suspect that you ran "chmod 666 /opt/softwares/apache-tomcat-6.0.26", which does exactly what you asked it to do - it changes the permission on just that folder.

    If you want the permissions to be changed recursively, you need to specify "-R" for recursive. See the chmod man page for more details.

    Note that this is normally a really bad idea - it is rare that you would want to change all the files and folders in this way. As one example, if you had recursively changed all the files in this manner, you would no longer have execute privileges on startup.sh, which would stop you from starting Tomcat

    [Side note for your way of starting tomcat: since you ran "sh ./startup.sh", the shell (sh) would successfully execute the commands in the file "startup.sh" - in this case startup.sh does not need to be executable (the normal way of running startup.sh is by typing ./startup.sh - no "sh" needed). However startup.sh executes catalina.sh, and that would have failed with a semi-confusing message: it would have told you that it was unable to find catalina.sh, even though you could see it]

    Anyway, if you must change the file access permissions recursively, it is better to do so by specifying what you want to add or delete rather than specifying an exact permission bitmap. For example, you showed that the log file had permissions -rw-r--r--. To change this so that group members can also write to the file, you could specify "chmod g+w ...". This will leave any existing permissions alone, but specifically add the write permissions.

    More advanced stuff: Normally when recursively changing permissions, I want to be explicit on what type of file gets changed. For example, normally I want to leave directory permissions alone, while changing permissions on files. So I might type something like find . -type f -exec chmod g+w "{}" \;. Or I might want to change all the executable files so that anyone in the group can execute the - something like find . -type f -perm -100 -exec chmod g+x "{}" \; - the important thing here is that I am not changing all files to be executable, I am not removing any permissions (so if an individual file was executable by the world it still will be after running the command), and I am not changing directories or symbolic links (or any other type of file) at all.
     
    Joe San
    Ranch Hand
    Posts: 10198
    3
    Mac PPC Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Got a good article to deal with file permissions in Linux http://www.linuxforums.org/articles/file-permissions_94.html
     
    Joe San
    Ranch Hand
    Posts: 10198
    3
    Mac PPC Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    By the way how does others (o) and all (a) differ in user permissions? To my, they both look the same!
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    u: user: The person who owns the file
    g: group: A group of people who may have permissions
    o: other: anyone who is not the user and not in the group
    a: all: everybody, whether they are the user, in the group, or other.
    reply
      Bookmark Topic Watch Topic
    • New Topic