Announcement Announcement Module
Collapse
No announcement yet.
Problems running a JSF application as S2AP web module Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems running a JSF application as S2AP web module

    Hi,

    I have a problem with running a simple JSF sample application as a Web module on S2AP.
    What I do is the following:
    1. I provide a service library that registers some service in OSGi registry. Works fine - I can deploy the bundle and see the expected state in the OSGi console.
    2. I try to write a JSF Web app which is deployed as Web module and which uses the registered OSGi service of the service library.

    The MANIFEST.MF of my Web module looks like this:

    Manifest-Version: 1.0
    Built-By: Tester
    Created-By: Apache Maven Bundle Plugin
    Import-Package: com.test.s2ap.jsf.service.statemngt.scope.api,com. sun.facelets,com.sun.facelets.tag,javax.el,jav
    ax.faces,javax.faces.application,javax.faces.compo nent,javax.faces.co
    ntext,javax.faces.event,javax.servlet,org.springfr amework.context,org
    .springframework.web.context,org.springframework.w eb.context.support,
    org.springframework.web.servlet
    Bnd-LastModified: 1217343252142
    Web-WelcomeFiles: index.jsp, index.html
    Export-Package: com.test.s2ap.jsf.service.statemngt.scope.api;uses :=
    "javax.faces.context"
    Bundle-Version: 1.0.0.SNAPSHOT
    Platform-ModuleType: Web
    Build-Jdk: 1.5.0_15
    Web-ContextPath: s2ap-testapp
    Web-ContextParams: com.sun.faces.validateXml;param-value:="false",
    com.sun.faces.verifyObjects;param-value:="false", facelets.DEV
    ELOPMENT;param-value:="false", facelets.VIEW_MAPPINGS;param-valu
    e:="*.xhtml", facelets.SKIP_COMMENTS;param-value:="true", face
    lets.RESOURCE_RESOLVER;param-value:="com.test.template.helper.Clas
    spathResourceResolver", contextClass;param-value:="com.springs
    ource.platform.web.dm.PlatformOsgiBundleXmlWebAppl icationContext",
    contextConfigLocation;param-value:="/MODULE-INF/WEB-INF/spring/bea
    ns.xml /MODULE-INF/WEB-INF/spring/beans-osgi.xml"
    Originally-Created-By: Apache Maven Bundle Plugin
    Bundle-Vendor: TESTER
    Bundle-ManifestVersion: 2
    Web-Servlets: FacesServlet;servlet-class:="javax.faces.webapp.FacesSer
    vlet"; load-on-startup:="1";url-patterns:="/faces/*"
    Bundle-SymbolicName: com.test,s2ap.service.s2ap-services-testapp-web
    Tool: Bnd-0.0.255

    When I deploy the module to S2AP, I find following entries in the trace:

    [2008-07-29 16:54:51.908] async-delivery-thread-1 ingsource.platform.catalina].[localhost].[/s2ap-testapp].unknown E StandardWrapper.Throwable
    java.lang.IllegalStateException: No WebApplicationContext found: initializer not registered?
    at org.springframework.web.servlet.FrameworkServlet.f indWebApplicationContext(FrameworkServlet.java:356 )
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:311 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:282)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1161)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:981)
    ...

    The generated web.xml on the file system of the SpringSource platform (-> i.e the one under springsource-ap-1.0.0.RC1workcom.springsource.platform.deployerMod ules2ap-services-testapp-web.jar-0s2ap-services-testapp-web.jarMODULE-INFWEB-INF) looks like this - no FacesServlet, etc. contained in there:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns="http://java.sun.com/xml/ns/javaee">
    <servlet>
    <servlet-name>com.test.s2ap.service.s2ap-services-testapp-web-DispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    <init-param>
    <param-name>contextAttribute</param-name>
    <param-value>com.test.s2ap.service.s2ap-services-testapp-web-ApplicationContext</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>com.test.s2ap.service.s2ap-services-testapp-web-DispatcherServlet</servlet-name>
    <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    </web-app>

    I haven't registered in the MANIFEST.MF the org.springframework.web.context.ContextLoaderListe ner. Is this required? Is so, how can I do it?

    Thanks and best regards,
    Timo

  • #2
    Problems running a JSF application as S2AP web module

    Could you try to define the FacesServlet in a web.xml fragment instead of in the manifest? I think this is causing your issue: the Platform seems to wrap it in an HttpServletBean that cannot find the WebApplicationContext, judging from the stacktrace.
    The Web-Servlets header has been deprecated since beta 9, so you'll have to do that anyway as support for it will be removed in the final 1.0 release AFAIK.

    Comment


    • #3
      Problems running a JSF application as S2AP web module

      Hi,

      I added the FacesServlet to the web.xml fragment of the application and now the generated web.xml in the S2AP "deployer/Module" file system looks better - at least it contains the FacesServlet definition:


      <?xml version="1.0" encoding="ISO-8859-1"?>
      <web-app xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns="http://java.sun.com/xml/ns/javaee">
      <servlet>
      <servlet-name>com.test.s2ap.service.s2ap-services-testapp-web-DispatcherServlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
      <load-on-startup>2</load-on-startup>
      <init-param>
      <param-name>contextAttribute</param-name>
      <param-value>com.test.s2ap.service.s2ap-services-testapp-web-ApplicationContext</param-value>
      </init-param>
      </servlet>
      <servlet-mapping>
      <servlet-name>com.test.s2ap.service.s2ap-services-testapp-web-DispatcherServlet</servlet-name>
      <url-pattern>*.htm</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <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>
      </web-app>

      I also added the packages javax.faces.webapp and javax.faces.context to the import-package list of the MANIFEST.MF.


      When I try to run the application in the browser, I get a "HTTP Status 500" with detailed stacktrace:

      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
      javax.faces.FactoryFinder.getFactory(FactoryFinder .java:267)
      javax.faces.webapp.FacesServlet.init(FacesServlet. java:164)
      org.apache.catalina.valves.CometConnectionManagerV alve.invoke(CometConnectionManagerValve.java:256)
      org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:568)
      ...


      When looking into the trace, I see following exception which is written during deployment of the web module:

      [2008-07-30 08:46:38.166] async-delivery-thread-1 ingsource.platform.catalina].[localhost].[/s2ap-testapp].unknown E StandardWrapper.Throwable
      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
      at javax.faces.FactoryFinder.getFactory(FactoryFinder .java:267)
      at javax.faces.webapp.FacesServlet.init(FacesServlet. java:164)
      at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1161)
      at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:981)
      at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4058)
      at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4364)
      at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)

      With the OSGi console, I see that javax.faces bundle is installed and active:

      40 ACTIVE com.springsource.javax.faces_1.2.0.08

      My test web module is also active:

      111 ACTIVE com.test.s2ap.service.s2ap-services-testapp-web_1.0.0.SNAPSHOT

      I also tried to import the whole "com.springsource.javax.faces" bundle instead of single packages, but this resulted in the same exception.
      Can anybody help me with this issue?

      Thanks and best regards,
      Timo

      Comment


      • #4
        Problems running a JSF application as S2AP web module

        Hi Timo,

        As Joris pointed out, most Web-* manifest headers have been fully deprecated as of the 1.0.0 RC1 release. You'll find further detailed information in the Programmer Guide here:

        http://static.springsource.com/projects/applicationplatform/1.0.x/programmer-guide/html/ch05s02.html#developing-applications-packaging-web-module-headers

        Thus, you'll need to migrate all of the non-supported web manifest headers to standard web.xml configuration via the web.xml fragment that you're already using. Based on your original post, you'll specifically need to migrate Web-WelcomeFiles and
        Web-ContextParams. You've already migrated Web-Servlets as Joris recommended.

        Note: for a web module, in contrast to a shared services WAR, you do _not_ need to specify the contextClass or contextConfigLocation context-params. Thus you should not migrate the following entries from your original Web-ContextParams declaration:

        contextClass;param-value:="com.springsource.platform.web.dm.PlatformO sgiBundleXmlWebApplicationContext",
        contextConfigLocation;param-value:="/MODULE-INF/WEB-INF/spring/beans.xml /MODULE-INF/WEB-INF/spring/beans-osgi.xml"

        Hope this helps,

        Sam

        Comment

        Working...
        X