Why is Eclipse/WTP having problems with Tomcat 6 on Linux?

I've been staring for a while at something like this:

This is my naive aattempt at defining a server run-time environment in Eclipse Ganymede on my Ubuntu Karmic laptop.

Naive, because I didn't think of at least these issues:

* The /usr/share/tomcat6 is root-writable, which means my "normal" user will be unable to modify the server configuration;

* The Ubuntu Karmic and perhaps others install their standard packages in a way that differs from the default Tomcat packaging. Some of the files, like the conf/ directory in this example is missing;

The Tomcat documentation describes a way to create a user-specific Tomcat server instance, using tomcat6-instance-create utility:

iliyan@thinktop:~$ tomcat6-instance-create server
iliyan@thinktop:~$ ls server server/bin server/conf
server:

bin conf logs temp webapps work

server/bin:
setenv.sh shutdown.sh startup.sh

server/conf:
catalina.properties context.xml logging.properties server.xml tomcat-users.xml web.xml

Great! This should be all I need, right? After all, it runs and stops just fine:
iliyan@thinktop:~$ server/bin/startup.sh iliyan@thinktop:~$ tail -n3 server/logs/catalina.out Jan 7, 2010 4:01:39 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 64 ms
Unfortunately, Eclipse/WTP does not recognize the directory structure. There certain deirectories it is missing, like lib/:
"The Tomcat installation directory is not valid. It is missing expected file or folder lib/jasper-el.jar."

This seems easy to fix:

iliyan@thinktop:~/server$ ln -s /usr/share/tomcat6/lib .

And in the jolly spirit of all GUI applications one is presented with the next problem:

"The Tomcat installation directory is not valid. It is missing expected file or folder bin/bootstrap.jar."

Well, let's try this:

iliyan@thinktop:~/server$ ln -s /usr/share/tomcat6/bin/bootstrap.jar ./bin/

Victory! Looks like we can finally use Eclipse's "Server" view to create a server instance

Alas, it is not over yet. There are more issues, and this time the message one gets is not very helpful:

"Cannot create a server using the selected type"
The Eclipse log points to the culprit:

"Error creating server: org.eclipse.core.runtime.CoreException: Could not load the Tomcat server configuration at /home/iliyan/server/conf. The configuration may be corrupt or incomplete.
...

Caused by: java.io.FileNotFoundException: /home/iliyan/server/conf/catalina.policy (No such file or directory)"
Let's create one (fingers crossed this time):

iliyan@thinktop:~/server$ touch conf/catalina.policy

Yes! And we have a server. Finally!



































    2 comments:

    1. Why not just make a symlink to the conf directory?
      ln -s /etc/tomcat6 /usr/share/tomcat6/conf

      And then just point to /usr/share/tomcat6

      ReplyDelete
    2. Thanks for the tip. This is a very helpful.

      NawaMan

      ReplyDelete