7

I get the following error when installing Tomcat7:

Setting up tomcat7 (7.0.26-1ubuntu1.1) ...  
chmod: cannot access `/etc/tomcat7/tomcat-users.xml': No such file or directory  
dpkg: error processing tomcat7 (--configure):  
 subprocess installed post-installation script returned error exit status 1  
No apport report written because MaxReports is reached already  

 >Errors were encountered while processing:  
 tomcat7  
E: Sub-process /usr/bin/dpkg returned an error code (1)

And I get this error when I try to apt-get remove Tomcat7:

Removing tomcat7 ...  
 * tomcat7 is not installed  
invoke-rc.d: initscript tomcat7, action "stop" failed.

How do I fix this to install Tomcat 7 correctly?

Braiam
  • 67,791
  • 32
  • 179
  • 269
Hendré
  • 759
  • 4
    Try to run a apt-get purge tomcat7 and reinstall it. See if it helps. I just wonder why you would like to use the deb package from official repository, for Tomcat, I'd rather download the binary and extract it (chown) and run as a normal user. If you want it to start during boot, there are plenty of options out there. – Terry Wang Dec 14 '12 at 05:47
  • Running apt-get purge tomcat7 did not work. Whoever when I removed all the tomcat7 optional tomcat7 packages like tomcat7-admin, it finally worked. – Hendré Dec 14 '12 at 10:17
  • Terry, I like the way the packaged version is installed on the file system. My tomcat configurations files are under /etc and my log files under /var/log etc. What I do not like about the package is it's dependency on OpenJDK, I prefer using the Oracle JDK. – Hendré Dec 14 '12 at 10:19
  • 1
    I understand your concern. To install Oracle JDK, there is an easy script on github, please check this out: http://askubuntu.com/questions/213583/not-recognize-jdk-after-installation-in-ubuntu-12-10/213590#213590 – Terry Wang Dec 14 '12 at 10:54
  • i am smiling :) – Hendré Dec 14 '12 at 13:34
  • The packaged tomcat7 does not depend on OpenJDK. It depends on a Java. The exact specification is default-jre-headless | java6-runtime-headless | java6-runtime | java-6-runtime. You can use the packaged tomcat7 with the Oracle JDK. – Robie Basak Nov 22 '13 at 18:51
  • is this still reproducible, I couldn't. – Braiam Mar 14 '14 at 18:49

3 Answers3

4

I had the exact the same problem.

I had to run this command (see below) to see what all tomcat related libraries are there and remove ALL the tomcat related libraries:

To see what all tomcat related libraries are there:

dpkg -l | grep -i tomcat

To remove a tomcat library:

dpkg -P <library-name>

Then, I reinstalled tomcat7 using the command:

sudo apt-get install tomcat7

[ During installation, it spit out messages saying it is going to install some of the other libraries related to tomcat7 - I chose - yes ].

It installed tomcat7 and started it.

Then, I stopped and restarted tomcat7 using these commands:

/etc/init.d/tomcat7 stop
/etc/init.d/tomcat7 start
Braiam
  • 67,791
  • 32
  • 179
  • 269
1

I had error stated that tomcat7 is aready newer version. Steps :

  1. Uninstall tomcat7 using command sudo apt-get autoremove tomcat7.
  2. This uninstalls tomcat7 completely.
  3. Now install it using sudo apt-get install tomcat7.

It worked well with me, give it a try.

Pranav Karnik
  • 127
  • 1
  • 4
  • I don't see how this has anything to do with the question at hand. Could you maybe clarify? – Seth Mar 11 '14 at 22:28
  • @Seth : The question is tomcat7 installation fails using apt-get method, so I suggested the possible solution that I have tried and got desired result. If I have miss-understood this question, kindly let me know :) – Pranav Karnik Mar 22 '14 at 15:03
-1

Run the following commands:

sudo apt-get purge libtomcat7-java tomcat6 tomcat6-admin tomcat6-docs tomcat6-examples tomcat7 tomcat7-admin tomcat7-common tomcat7-docs tomcat7-examples tomcat7-user

sudo apt-get install tomcat7