1

Up to this point I've been running JSF 1.2 apps on Tomcat 6.0. I have now started a new JSF 2.0 project on a different instance of Tomcat (For testing).

I would like to deploy the new JSF 2.0 project on the main Tomcat 6.0 server and am facing the challenge of "telling" the new project to use the 2.0 libraries while the old projects should keep on using the old libraries.

All the libraries are common per server (Although the build path is obviously per project). What I would like to know is how to tell a project to use the JSF 2.0 API.

Thanks!

jmj
  • 225,392
  • 41
  • 383
  • 426
Ben
  • 9,162
  • 21
  • 89
  • 151

3 Answers3

3

Tomcat does not ship with JSF at all, so just giving each project their own correct versioned JSF libraries in the /WEB-INF/lib should work without any issues.

Update I overlooked that the JSF 1.2 libs are supplied by Tomcat itself. In this case you need to upgrade the JSF 1.2 libs in Tomcat to JSF 2.0 libs. JSF 2.0 is fully backwards compatible with JSF 1.2. For Tomcat servers it is not possible to configure the webapp in some way that it overrides the Tomcat-supplied libs with the webapp-supplied libs. You will end up with collisions in the classpath.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • We deploy without libraries. As I mentioned "All the libraries are common per server". – Ben May 04 '11 at 12:20
  • That was a bad idea from the beginning on. I don't quite understand how the answer of Jigar did solve this. The ones supplied by Tomcat would still get precedence over the ones in webapp. More fledged appservers have specific configuration settings to let webapps override the server-supplied libraries, see also http://stackoverflow.com/questions/5815623/jsf-2-issues-in-application-servers At any way, you should be able to keep using your JSF 1.2 apps while updating the Tomcat-libs from 1.2 to 2.0. JSF 2.0 is fully backwards compatible with JSF 1.2. – BalusC May 04 '11 at 12:25
  • This is done to reduce the size of deployment. Is there another way? I don't see how referring to the libraries through the build path is not better than including the actual libraries in the `war` file. (Seems like a library-duplication mess) Is it just because there is no better solution? – Ben May 04 '11 at 12:31
  • The Tomcat libs have precedence over webapp libs in classloading. For Tomcat you cannot change it from the webapp side on. The IDE buildpath is irrelevant. Did you test it yourself anyway? – BalusC May 04 '11 at 12:34
  • I did test it but the environment may have been setup incorrectly. For that reason I removed the marking of correct answer and I am testing it now again. – Ben May 04 '11 at 12:35
  • After some reconsiderations i've decided to move all my webapps to JSF 2.0 as you suggested. – Ben May 04 '11 at 12:42
  • Pay attention to the startup log. Mojarra should print the implementation version. If this is 1.2, then JSF 2.0 specific features may not work at all. – BalusC May 04 '11 at 12:44
  • Hey BalusC, Theres seems to be some conflict with what you wrote here: http://stackoverflow.com/questions/1993493/error-servlet-jar-not-loaded – Ben May 04 '11 at 12:53
  • Tomcat does not ship with JSF. Tomcat ships with JSP/Servlet only and some related libs. You should not supply JSP/Servlet libs yourself by the webapp, this would only lead to conflicts. It boils down to that it's a bad idea to have libs of different impls/versions in appserver lib and the webapp lib. – BalusC May 04 '11 at 12:54
  • 1
    Sorry, I now see what you're getting at. For the API the webapp-supplied libs will be loaded, but for the impl this will not happen, instead the appserver-supplied libs will be loaded. JSP/Servlet/JSF/etc exist of 2 libs: API and impl. The API is whatever you import in your classes. `javax.faces.*` and on. It's almost one and all interfaces and abstract classes. The impl, however, is the real concrete code. For Mojarra this is `com.sun.*` classes. So if you put JSF 1.2 API/impl in Tomcat and JSF 2.0 API/impl in webapp, then your webapp will run with JSF 2.0 API and JSF 1.2 impl. This collides. – BalusC May 04 '11 at 13:46
0

Well you can take the JSF jar out of Tomcat's classpath & pack the needed version with each WAR, other than that, I don't think you'll be able to do it...

TC1
  • 2,984
  • 3
  • 18
  • 31
0

Well.. You just need to make required lib available in your class path and you need to do these changes in your configurations and it should pick up correct lib

Community
  • 1
  • 1
jmj
  • 225,392
  • 41
  • 383
  • 426