java.lang.ClassCastException: javax.faces.webapp.FacesServlet cannot be cast to javax.servlet.Servlet - in OSGI

1.2k Views Asked by At

I add necessary bundles in OSGI framework. I want to see JSF page with tags in OSGI. Page is working but tags are not working. For example my index.xhtml is ;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.prime.com.tr/ui">

<h:head>
        Test JSF1232
        <h:outputText value="TEST!!!" />
</h:head>

<h:body>
    <ui:composition>
        <h:commandButton type="submit" value="#{okLabel}" />
        <h:commandButton type="reset" value="#{cancelLabel}" />
        <h:outputText value="Hello World!" />
    </ui:composition>
</h:body>


</html>

i got "Test JSF1232" but i dont see "TEST!!!" and inside the body.

My bundle name is LastTestWeb and my other bundle's list;

osgi> ss

Framework is launched.

id  State       Bundle
0   ACTIVE      org.eclipse.osgi_3.7.2.v20120110-1415
2   ACTIVE      org.eclipse.gemini.web.core_2.0.2.RELEASE
3   ACTIVE      org.eclipse.gemini.web.extender_2.0.2.RELEASE
4   ACTIVE      org.eclipse.gemini.web.tomcat_2.0.2.RELEASE
5   ACTIVE      com.springsource.javax.activation_1.1.1
6   ACTIVE      com.springsource.javax.ejb_3.0.0
7   ACTIVE      com.springsource.javax.mail_1.4.0
8   ACTIVE      com.springsource.javax.persistence_1.0.0
9   ACTIVE      com.springsource.javax.transaction_1.1.0
10  ACTIVE      com.springsource.javax.xml.bind_2.1.7
11  ACTIVE      com.springsource.javax.xml.rpc_1.1.0.v20110517
12  ACTIVE      com.springsource.javax.xml.soap_1.3.0
13  ACTIVE      com.springsource.javax.xml.stream_1.0.1
14  ACTIVE      com.springsource.org.aopalliance_1.0.0
15  ACTIVE      com.springsource.org.apache.catalina_7.0.26
                Fragments=16, 17, 19, 21, 24
16  RESOLVED    com.springsource.org.apache.catalina.ha_7.0.26
                Master=15
17  RESOLVED    com.springsource.org.apache.catalina.tribes_7.0.26
                Master=15
18  ACTIVE      com.springsource.org.apache.commons.logging_1.1.1
19  RESOLVED    com.springsource.org.apache.coyote_7.0.26
                Master=15
20  ACTIVE      com.springsource.org.apache.el_7.0.26
21  RESOLVED    com.springsource.org.apache.jasper_7.0.26
                Master=15
22  ACTIVE      com.springsource.org.apache.juli.extras_7.0.26
23  ACTIVE      com.springsource.org.apache.tomcat.api_7.0.26
24  RESOLVED    com.springsource.org.apache.tomcat.util_7.0.26
                Master=15
25  ACTIVE      com.springsource.org.eclipse.jdt.core.compiler.batch_3.6.1
26  ACTIVE      com.springsource.slf4j.api_1.6.1
                Fragments=27
27  RESOLVED    com.springsource.slf4j.nop_1.6.1
                Master=26
28  ACTIVE      javax.annotation_1.1.0.v201105051105
29  ACTIVE      javax.el_2.2.0.v201105051105
30  ACTIVE      javax.servlet_3.0.0.v201103241009
31  ACTIVE      javax.servlet.jsp_2.2.0.v201103241009
32  ACTIVE      org.eclipse.virgo.util.common_3.0.1.RELEASE
33  ACTIVE      org.eclipse.virgo.util.io_3.0.1.RELEASE
34  ACTIVE      org.eclipse.virgo.util.math_3.0.1.RELEASE
35  ACTIVE      org.eclipse.virgo.util.osgi_3.0.1.RELEASE
36  ACTIVE      org.eclipse.virgo.util.parser.manifest_3.0.1.RELEASE
37  ACTIVE      org.springframework.aop_3.0.5.RELEASE
38  ACTIVE      org.springframework.beans_3.0.5.RELEASE
39  ACTIVE      org.springframework.context_3.0.5.RELEASE
40  ACTIVE      org.springframework.core_3.0.5.RELEASE
41  ACTIVE      org.springframework.osgi.core_1.2.1
42  ACTIVE      org.springframework.osgi.io_1.2.1
55  ACTIVE      com.springsource.javax.servlet.jsp.jstl_1.2.0
56  ACTIVE      org.apache.commons.beanutils_1.8.3
57  ACTIVE      org.apache.commons.collections_3.2.1
58  ACTIVE      org.apache.commons.digester_2.1.0
59  ACTIVE      org.apache.commons.validator_1.4.0
61  ACTIVE      org.apache.myfaces.core.bundle_2.2.7
63  ACTIVE      org.primefaces_3.5.0
64  ACTIVE      org.jboss.weld.osgi-bundle_1.1.6.Final
65  ACTIVE      org.apache.servicemix.bundles.jaxp-ri_1.4.2.1
68  ACTIVE      org.knopflerfish.bundle.jsdk-API_2.5.0.kf3-2
69  ACTIVE      org.apache.servicemix.bundles.commons-codec_1.3.0.2
70  ACTIVE      org.apache.servicemix.bundles.commons-digester_1.8.0.1
73  ACTIVE      com.springsource.javax.el_1.0.0
74  ACTIVE      org.glassfish.com.sun.faces_2.1.6.SNAPSHOT
79  ACTIVE      LastTestWeb_1.0.0.qualifier

And i import some bundles for jsf tags are working. My manifest folder is ;

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LastTestWeb
Bundle-SymbolicName: LastTestWeb
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: WEB-INF/classes/
Import-Package: javax.el,
 javax.faces.webapp;version="2.1.0",
 javax.servlet,
 javax.servlet.http,
 javax.servlet.jsp,
 javax.servlet.jsp.el,
 javax.servlet.jsp.tagext,
 org.apache.myfaces.application;version="2.2.7",
 org.apache.myfaces.application.cdi;version="2.2.7",
 org.apache.myfaces.application.jsp;version="2.2.7",
 org.apache.myfaces.application.viewstate;version="2.2.7",
 org.apache.myfaces.cdi.dependent;version="2.2.7",
 org.apache.myfaces.cdi.impl;version="2.2.7",
 org.apache.myfaces.cdi.util;version="2.2.7",
 org.apache.myfaces.cdi.view;version="2.2.7",
 org.apache.myfaces.component;version="2.2.7",
 org.apache.myfaces.component.visit;version="2.2.7",
 org.apache.myfaces.config.annotation;version="2.2.7",
 org.apache.myfaces.config.element;version="2.2.7",
 org.apache.myfaces.config.element.facelets;version="2.2.7",
 org.apache.myfaces.config.impl.digester.elements;version="2.2.7",
 org.apache.myfaces.config.impl.digester.elements.facelets;version="2.2.7",
 org.apache.myfaces.ee6;version="2.2.7",
 org.apache.myfaces.flow;version="2.2.7",
 org.apache.myfaces.flow.builder;version="2.2.7",
 org.apache.myfaces.flow.cdi;version="2.2.7",
 org.apache.myfaces.flow.impl;version="2.2.7",
 org.apache.myfaces.shared.taglib;version="2.2.7",
 org.apache.myfaces.shared.taglib.core;version="2.2.7",
 org.apache.myfaces.shared_impl.webapp.webxml;version="2.2.7",
 org.apache.myfaces.spi;version="2.2.7",
 org.apache.myfaces.taglib.core;version="2.2.7",
 org.apache.myfaces.taglib.html;version="2.2.7",
 org.apache.myfaces.view;version="2.2.7",
 org.apache.myfaces.view.facelets.component;version="2.2.7",
 org.apache.myfaces.view.facelets.el;version="2.2.7",
 org.apache.myfaces.view.facelets.tag.jsf;version="2.2.7",
 org.apache.myfaces.webapp;version="2.2.7",
 org.primefaces.webapp;version="3.5.0"
Web-ContextPath: /LastTestWeb

and the last one. here is my web.xml ;

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>LastTestWeb</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>  
           <servlet-name>Faces Servlet</servlet-name>  
           <url-pattern>/faces/*</url-pattern>  
      </servlet-mapping>  
      <servlet-mapping>  
           <servlet-name>Faces Servlet</servlet-name>  
           <url-pattern>*.jsf</url-pattern>  
      </servlet-mapping>  
      <servlet-mapping>  
           <servlet-name>Faces Servlet</servlet-name>  
           <url-pattern>*.faces</url-pattern>  
      </servlet-mapping>  
      <servlet-mapping>  
           <servlet-name>Faces Servlet</servlet-name>  
           <url-pattern>*.xhtml</url-pattern>  
      </servlet-mapping>
</web-app>

why it didn't work, I got this error:

java.lang.ClassCastException: javax.faces.webapp.FacesServlet cannot be cast to javax.servlet.Servlet.

0

There are 0 best solutions below