I have set up tomcat (5.0.18). Having spent quite some time trying to compile a "helloworld" servlet, I found out that I had to add servlet.jar to the CLASSPATH. more interesting (or not) is thet there is no servlet.jar on gentoo's tomcat. the file is named servlet-api.jar. When I added to /etc/env.d/21tomcat the line: CLASSPATH=${CATALINA_HOME}/common/lib/servlet-api.jar and then ran 'env-update' and 'source /etc/profile', could compile. If I add only the lib folder, it does not work. I don't know if this is the *right* way, but it worked for me. Since I have installed tomcat, there is a high chance I will compile things too, so it makes sense that the tomcat ebuild should set it up for the user. Reproducible: Always Steps to Reproduce: 1. emerge tomcat 2. try to compile anything that uses javax.servlet 3. kaboom Actual Results: servlets do not compile Expected Results: servlet should compile
This seems normal to me. Typically when creating servlets, you need to include the servlet-api.jar in the compile classpath (in the environment if you are using javac from the command line, or through build.xml if you are using ant). One of the ways to include it in the environment (so that it always happens) is: emerge servletapi then, if you want the servlet api to be in classpath for all users, run: java-config -B servletapi-2.4 of if you want it for just you: java-config -b servletapi-2.4 and follow the instructions from java-config.
This bug scratches the surface on a rather complex problem. There are multiple servlet providers. You should not need to have tomcat installed to compile against the servletapi, just installing the servletapi should suffice. However, once you have tomcat installed, and given that no other servletapi provider was present, you'd expect tomcat to provide it for you. This has been discussed a bit, but nobody has found the time to implement it properly. The currently envisioned solution is to create virtual/servletapi, and have the servlet containers PROVIDE this. One should be able to do java-config -b servleapi-<interface version>, where interface version is the version of the servletapi interface you're requesting. This part is a bit more tricky, as java-config does not currently understand virtuals. Additionally, we will most likely be removing the env var file from tomcat, to ensure proper operation in the face of users inadvertently experimenting with their env vars.
Talked to Stu in the webapps herd. They are not considering Java webapps at the moment, so this task is squarely on our shoulders. We should gang up on this this problem and come up with a semi-decent solution that plays nice with the existing webapps infrastructure (webapp-config, webapp.eclass).
Unfortunately, we don't currently have the manpower to develop and maintain such a system. I hope we will be able to in the future though, so I'm going to resolve this with REMIND, so we can come back to it.