Groups > Weblogic > WebLogic Developers workshop > Could be a fix for Tomcat 6 issue




Could be a fix for Tomcat 6 issue

Could be a fix for Tomcat 6 issue
Mon, 7 Apr 2008 00:06:58 -0700
Getting Eclipse 3.2, Tomcat 6.0 and JSF 1.2 playing together nicely is a task
that is certainly not for the faint of heart. Tomcat 6 seems to have issues at
the moment but I'm loathed to push too much of the blame on to it as generally
Tomcat has been rock solid. The big problem is really with Eclipse. The WTP (Web
Tools Platform) is not as good as it could be and doesn't currently support
Tomcat 6. Fortunately there is a work around to fool Eclipse into thinking that
Tomcat 6 is really an install of Tomcat 5.5.
Running Tomcat 6 Under Eclipse

Find the file org.eclipse.jst.server.tomcat.core_1.0.103.v20060904b.jar which
lives in the plugins directory under the Eclipse install directory. Copy the
file somewhere else and unzip it. Modify the file verifyInstall.properties so
that the verify55install line looks like this:

verify55install=bin/bootstrap.jar,conf,webapps

Re-zip the files to create a jar with the same name as the one that you
unzipped. Place the tweeked jar back in the Eclipse plugin directory and restart
Eclipse. Configure a new Tomcat 5.5 instance but point it at a Tomcat 6
install.
Installing JSF 1.2

There is currently no myFaces version of JSF 1.2 so you are stuck with the RI
from sun. Grab this and place it in the WEB-INF/lib directory. Update the
web.xml file of you applicaiton so that it loads the faces servlet:

 <!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping> 

When you come to fire up the applicaiton you may well receive this error
message:

java.lang.IllegalStateException: Application was not properly initialized at
startup, could not find Factory: 
javax.faces.context.FacesContextFactory 

This is apparently due to some hot deploy issues with Tomcat. It would seem that
Tomcat has a bit of a blind spot for configuring listener specified inside TLDs.
Quite why sun release a RI that shows this bug up in the most widely used
container is beyond me. The solution to this issue is to add the following
listener to the web.xml file:

 	<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<!-- Listener implementation to handle web application lifecycle
events -->
<listener>
<listener-class>
com.sun.faces.application.WebappLifecycleListener
</listener-class>
</listener>

That should be all that's required. I've noticed that Tomcat 6 seems to behave
somewhat strangely under Eclipse. Hot deploy of JSPs doesn't work from Eclipse
and Eclipse is unable to detect that Tomcat 6 is running - it always shows
Tomcat 6 as starting. Some of the rendering of pages also seems to be strange
but that could well be changes that I haven't yet discovered. 


http://www.crazysquirrel.com/computing/java/jsf/eclipse-with-tomcat-6-and-j
Post Reply
about | contact