You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ma...@procon.co.at on 2008/03/11 10:11:07 UTC

myfaces 1.2.2 - Java Servlet 2.5 implementation doesnt work

Hi!

 

I use:

myfaces-api 1.2.2

myfaces-impl 1.2.2

tomahawk 1.1.6

jstl 1.2

servlet-api 2.5

tomcat 6

sysdeo plugin for eclipse

 

I need following:


FacesContext fc = FacesContext.getCurrentInstance();

ServletContext sc = (ServletContext) fc.getExternalContext().getContext();

FileInputStream  propOutFile = new
FileInputStream(sc.getRealPath(Globals.RULES_CONFIG_FILE));

 

But for "ServletContext" I need the servlet-api and if I include the JAR in
my project, I always get an exception while starting the server:

 

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
addApplicationListener

INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener"
is already configured for this context. The duplicate definition has been
ignored.

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
addApplicationListener

INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener"
is already configured for this context. The duplicate definition has been
ignored.

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext filterStart

SCHWERWIEGEND: Exception starting filter extensionsFilter

java.lang.ClassCastException:
org.apache.myfaces.webapp.filter.ExtensionsFilter cannot be cast to
javax.servlet.Filter

      at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter
Config.java:255)

      at
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFil
terConfig.java:397)

      at
org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterCon
fig.java:108)

      at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:37
09)

      at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)

      at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

      at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

      at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)

      at
org.apache.catalina.core.StandardService.start(StandardService.java:516)

      at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)

      at org.apache.catalina.startup.Catalina.start(Catalina.java:578)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start

SCHWERWIEGEND: Error filterStart

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start

SCHWERWIEGEND: Context [/TMCWeb] startup failed due to previous errors

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
addApplicationListener

INFO: The listener "listeners.ContextListener" is already configured for
this context. The duplicate definition has been ignored.

11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
addApplicationListener

INFO: The listener "listeners.SessionListener" is already configured for
this context. The duplicate definition has been ignored.

11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log

INFO: ContextListener: contextInitialized()

11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log

INFO: SessionListener: contextInitialized()

11.03.2008 10:01:51 org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

11.03.2008 10:01:51 org.apache.jk.common.ChannelSocket init

INFO: JK: ajp13 listening on /0.0.0.0:8009

11.03.2008 10:01:51 org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=0/31  config=null

11.03.2008 10:01:51 org.apache.catalina.startup.Catalina start

INFO: Server startup in 2102 ms

 

Whats going wrong?

Do I forgot a JAR?


AW: myfaces 1.2.2 - Java Servlet 2.5 implementation doesnt work

Posted by ma...@procon.co.at.
Thanks, it fixed the problem.

Regards
markus

-----Ursprüngliche Nachricht-----
Von: simon.kitching@chello.at [mailto:simon.kitching@chello.at] 
Gesendet: Dienstag, 11. März 2008 10:43
An: MyFaces Discussion
Betreff: Re: myfaces 1.2.2 - Java Servlet 2.5 implementation doesnt work

markus.pfeiffer@procon.co.at schrieb:
>
> Hi!
>
> I use:
>
> myfaces-api 1.2.2
>
> myfaces-impl 1.2.2
>
> tomahawk 1.1.6
>
> jstl 1.2
>
> servlet-api 2.5
>
> tomcat 6
>
> sysdeo plugin for eclipse
>
> I need following:
>
>
> FacesContext fc = FacesContext./getCurrentInstance/();
>
> ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
>
> FileInputStream propOutFile = *new*
> FileInputStream(sc.getRealPath(Globals./RULES_CONFIG_FILE/));
>
> But for “ServletContext” I need the servlet-api and if I include the
> JAR in my project, I always get an exception while starting the server:
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener
> "org.apache.myfaces.webapp.StartupServletContextListener" is already
> configured for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener
> "org.apache.myfaces.webapp.StartupServletContextListener" is already
> configured for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext filterStart
>
> SCHWERWIEGEND: Exception starting filter extensionsFilter
>
> _java.lang.ClassCastException_:
> org.apache.myfaces.webapp.filter.ExtensionsFilter cannot be cast to
> javax.servlet.Filter
>
> at
>
org.apache.catalina.core.ApplicationFilterConfig.getFilter(_ApplicationFilte
rConfig.java:255_)
>
> at
>
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(_ApplicationFi
lterConfig.java:397_)
>
> at
>
org.apache.catalina.core.ApplicationFilterConfig.<init>(_ApplicationFilterCo
nfig.java:108_)
>
> at
>
org.apache.catalina.core.StandardContext.filterStart(_StandardContext.java:3
709_)
>
> at
>
org.apache.catalina.core.StandardContext.start(_StandardContext.java:4356_)
>
> at org.apache.catalina.core.ContainerBase.start(_ContainerBase.java:1045_)
>
> at org.apache.catalina.core.StandardHost.start(_StandardHost.java:719_)
>
> at org.apache.catalina.core.ContainerBase.start(_ContainerBase.java:1045_)
>
> at
> org.apache.catalina.core.StandardEngine.start(_StandardEngine.java:443_)
>
> at
> org.apache.catalina.core.StandardService.start(_StandardService.java:516_)
>
> at
> org.apache.catalina.core.StandardServer.start(_StandardServer.java:710_)
>
> at org.apache.catalina.startup.Catalina.start(_Catalina.java:578_)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(_Native Method_)
>
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(_NativeMethodAccessorImpl.java:3
9_)
>
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(_DelegatingMethodAccessorImp
l.java:25_)
>
> at java.lang.reflect.Method.invoke(_Method.java:597_)
>
> at org.apache.catalina.startup.Bootstrap.start(_Bootstrap.java:288_)
>
> at org.apache.catalina.startup.Bootstrap.main(_Bootstrap.java:413_)
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start
>
> SCHWERWIEGEND: Error filterStart
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start
>
> SCHWERWIEGEND: Context [/TMCWeb] startup failed due to previous errors
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener "listeners.ContextListener" is already configured
> for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener "listeners.SessionListener" is already configured
> for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log
>
> INFO: ContextListener: contextInitialized()
>
> 11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log
>
> INFO: SessionListener: contextInitialized()
>
> 11.03.2008 10:01:51 org.apache.coyote.http11.Http11Protocol start
>
> INFO: Starting Coyote HTTP/1.1 on http-8080
>
> 11.03.2008 10:01:51 org.apache.jk.common.ChannelSocket init
>
> INFO: JK: ajp13 listening on /0.0.0.0:8009
>
> 11.03.2008 10:01:51 org.apache.jk.server.JkMain start
>
> INFO: Jk running ID=0 time=0/31 config=null
>
> 11.03.2008 10:01:51 org.apache.catalina.startup.Catalina start
>
> INFO: Server startup in 2102 ms
>
> Whats going wrong?
>
> Do I forgot a JAR?
>
Tomcat already provides the servlet-api.jar.

You do need this jar in your classpath when compiling. However you must
*not* include that in your .war file, as this means it is present twice,
and will cause these ClassCastException problems.

If you are using maven to build, then you should be specifying scope of
"provided" for the servlet-api.jar file.

Regards,
Simon



Re: myfaces 1.2.2 - Java Servlet 2.5 implementation doesnt work

Posted by "simon.kitching@chello.at" <si...@chello.at>.
markus.pfeiffer@procon.co.at schrieb:
>
> Hi!
>
> I use:
>
> myfaces-api 1.2.2
>
> myfaces-impl 1.2.2
>
> tomahawk 1.1.6
>
> jstl 1.2
>
> servlet-api 2.5
>
> tomcat 6
>
> sysdeo plugin for eclipse
>
> I need following:
>
>
> FacesContext fc = FacesContext./getCurrentInstance/();
>
> ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
>
> FileInputStream propOutFile = *new*
> FileInputStream(sc.getRealPath(Globals./RULES_CONFIG_FILE/));
>
> But for “ServletContext” I need the servlet-api and if I include the
> JAR in my project, I always get an exception while starting the server:
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener
> "org.apache.myfaces.webapp.StartupServletContextListener" is already
> configured for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener
> "org.apache.myfaces.webapp.StartupServletContextListener" is already
> configured for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext filterStart
>
> SCHWERWIEGEND: Exception starting filter extensionsFilter
>
> _java.lang.ClassCastException_:
> org.apache.myfaces.webapp.filter.ExtensionsFilter cannot be cast to
> javax.servlet.Filter
>
> at
> org.apache.catalina.core.ApplicationFilterConfig.getFilter(_ApplicationFilterConfig.java:255_)
>
> at
> org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(_ApplicationFilterConfig.java:397_)
>
> at
> org.apache.catalina.core.ApplicationFilterConfig.<init>(_ApplicationFilterConfig.java:108_)
>
> at
> org.apache.catalina.core.StandardContext.filterStart(_StandardContext.java:3709_)
>
> at
> org.apache.catalina.core.StandardContext.start(_StandardContext.java:4356_)
>
> at org.apache.catalina.core.ContainerBase.start(_ContainerBase.java:1045_)
>
> at org.apache.catalina.core.StandardHost.start(_StandardHost.java:719_)
>
> at org.apache.catalina.core.ContainerBase.start(_ContainerBase.java:1045_)
>
> at
> org.apache.catalina.core.StandardEngine.start(_StandardEngine.java:443_)
>
> at
> org.apache.catalina.core.StandardService.start(_StandardService.java:516_)
>
> at
> org.apache.catalina.core.StandardServer.start(_StandardServer.java:710_)
>
> at org.apache.catalina.startup.Catalina.start(_Catalina.java:578_)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(_Native Method_)
>
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(_NativeMethodAccessorImpl.java:39_)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(_DelegatingMethodAccessorImpl.java:25_)
>
> at java.lang.reflect.Method.invoke(_Method.java:597_)
>
> at org.apache.catalina.startup.Bootstrap.start(_Bootstrap.java:288_)
>
> at org.apache.catalina.startup.Bootstrap.main(_Bootstrap.java:413_)
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start
>
> SCHWERWIEGEND: Error filterStart
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext start
>
> SCHWERWIEGEND: Context [/TMCWeb] startup failed due to previous errors
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener "listeners.ContextListener" is already configured
> for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.StandardContext
> addApplicationListener
>
> INFO: The listener "listeners.SessionListener" is already configured
> for this context. The duplicate definition has been ignored.
>
> 11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log
>
> INFO: ContextListener: contextInitialized()
>
> 11.03.2008 10:01:50 org.apache.catalina.core.ApplicationContext log
>
> INFO: SessionListener: contextInitialized()
>
> 11.03.2008 10:01:51 org.apache.coyote.http11.Http11Protocol start
>
> INFO: Starting Coyote HTTP/1.1 on http-8080
>
> 11.03.2008 10:01:51 org.apache.jk.common.ChannelSocket init
>
> INFO: JK: ajp13 listening on /0.0.0.0:8009
>
> 11.03.2008 10:01:51 org.apache.jk.server.JkMain start
>
> INFO: Jk running ID=0 time=0/31 config=null
>
> 11.03.2008 10:01:51 org.apache.catalina.startup.Catalina start
>
> INFO: Server startup in 2102 ms
>
> Whats going wrong?
>
> Do I forgot a JAR?
>
Tomcat already provides the servlet-api.jar.

You do need this jar in your classpath when compiling. However you must
*not* include that in your .war file, as this means it is present twice,
and will cause these ClassCastException problems.

If you are using maven to build, then you should be specifying scope of
"provided" for the servlet-api.jar file.

Regards,
Simon