dev@javaserverfaces.java.net

Re: cannot be cast to com.sun.faces.application.ApplicationAssociate

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Thu, 02 Aug 2007 11:19:23 -0700

Tom Kalafut wrote:
>
> Hi. I’m trying to run a JSF 1.2_04 app with Tomcat 6.0.13.
>
> I had a problem with ExpressionFactoryImpl but solved that by getting
> el-ri-1.1.11.jar from facelets, but now I’m stuck again. Anybody seen
> this puzzling “cannot cast Class ApplicationAssociate to Class
> ApplicationAssociate” before with JSF 1.2_04?
>
> ((Could “”INFO: validateJarFile(C:\Program Files\Apache Software
> Foundation\Tomcat 6.0\web
>
> apps\smfadmin\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See
> Servlet Spe
>
> c 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class””
> have anything to do with it?))
>
The message above means you have Servlet classes included with the web
application. Since the spec
disallows overriding these classes that are provided by the container,
Tomcat gives you this message.
I would remove any javax.servlet classes from your web application.

More inline....,
>
> Thanks,
> Tom
>
> =====Tomcat Startup Trace=========
>
> Aug 2, 2007 1:34:16 PM org.apache.coyote.http11.Http11Protocol init
>
> INFO: Initializing Coyote HTTP/1.1 on http-8080
>
> Aug 2, 2007 1:34:16 PM org.apache.catalina.startup.Catalina load
>
> INFO: Initialization processed in 376 ms
>
> Aug 2, 2007 1:34:16 PM org.apache.catalina.core.StandardService start
>
> INFO: Starting service Catalina
>
> Aug 2, 2007 1:34:16 PM org.apache.catalina.core.StandardEngine start
>
> INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
>
> Aug 2, 2007 1:34:16 PM org.apache.catalina.startup.HostConfig deployWAR
>
> INFO: Deploying web application archive smfadmin.war
>
> Aug 2, 2007 1:34:16 PM org.apache.catalina.loader.WebappClassLoader
> validateJarF
>
> ile
>
> INFO: validateJarFile(C:\Program Files\Apache Software
> Foundation\Tomcat 6.0\web
>
> apps\smfadmin\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See
> Servlet Spe
>
> c 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
>
> Aug 2, 2007 1:34:17 PM com.sun.faces.config.ConfigureListener
> contextInitialized
>
> INFO: Initializing Sun's JavaServer Faces implementation
> (1.2_04-b16-p02) for co
>
> ntext '/smfadmin'
>
> Aug 2, 2007 1:34:17 PM com.sun.faces.config.ConfigureListener
> contextInitialized
>
> INFO: Initializing Sun's JavaServer Faces implementation
> (1.2_04-b16-p02) for co
>
> ntext '/smfadmin'
>
> Aug 2, 2007 1:34:17 PM org.apache.catalina.core.StandardContext
> listenerStart
>
> SEVERE: Exception sending context initialized event to listener
> instance of clas
>
> s com.sun.faces.config.GlassFishConfigureListener
>
> *java.lang.ClassCastException:
> com.sun.faces.application.ApplicationAssociate can*
>
> *not be cast to com.sun.faces.application.ApplicationAssociate*
>
> at com.sun.faces.application.ApplicationAssociate.getInstance(Applicatio
>
> nAssociate.java:208)
>
I'm thinking this is because ApplicationAssociate is loaded in two
different classloaders.
The presence of GlassFishConfigureListener in the stacktrace kinda
confirms this.
GlassFishConfigureListener was a JSF 1.2 FCS artifact and shouldn't be
present in
1.2_04 P02.

Where have you installed JSF 1.2_04 P02? In WEB-INF/lib of the web
application,
or in TOMCAT_HOME/lib?

> at com.sun.faces.config.JSFVersionTracker.publishInstanceToApplication(J
>
> SFVersionTracker.java:269)
>
> at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureLi
>
> stener.java:551)
>
> at com.sun.faces.config.GlassFishConfigureListener.contextInitialized(Gl
>
> assFishConfigureListener.java:47)
>
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
>
> t.java:3827)
>
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
>
> 334)
>
> at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
>
> .java:791)
>
> at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
>
> 1)
>
> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>
> at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
>
> at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714
>
> Tom Kalafut
>
> I3/CG Crew Member
>
> Trident Systems Inc.
>
> tommyk_at_tridsys.com <mailto:tommyk_at_tridsys.com>
>
> (919)388-1264
>
> * *
>
> *============***
>
> *The opinions expressed in this e-mail may not necessarily reflect the
> opinions of Trident Systems Inc.*
>