6 Replies Latest reply on Apr 23, 2013 2:56 AM by specialed

    Richfaces 4.3.1 CSS resources not being referrenced in compiled <h:head> component

    specialed Newbie

      Hi all,

       

      I am having troubles migrating a project from RF 3.x to 4.3.1. Here's 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

               id="WebApp_ID" version="3.0">

       

          <display-name>Project</display-name>

       

          <context-param>

              <param-name>javax.faces.PROJECT_STAGE</param-name>

              <param-value>Development</param-value>

          </context-param>

       

          <context-param>

              <param-name>org.richfaces.resourceOptimization.enabled</param-name>

              <param-value>true</param-value>

          </context-param>

       

          <context-param>

              <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

              <param-value>server</param-value>

          </context-param>

       

          <context-param>

              <param-name>org.richfaces.skin</param-name>

              <param-value>blueSky</param-value>

          </context-param>

       

          <context-param>

              <param-name>org.richfaces.enableControlSkinning</param-name>

              <param-value>true</param-value>

          </context-param>

       

          <context-param>

              <param-name>javax.faces.DEFAULT_SUFFIX</param-name>

              <param-value>.xhtml</param-value>

          </context-param>

       

          <!-- 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>*.xhtml</url-pattern>

          </servlet-mapping>

       

          <servlet>

              <servlet-name>Resource Servlet</servlet-name>

              <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>

              <load-on-startup>1</load-on-startup>

          </servlet>

       

          <servlet-mapping>

              <servlet-name>Resource Servlet</servlet-name>

              <url-pattern>/org.richfaces.resources/*</url-pattern>

          </servlet-mapping>

       

          <session-config>

              <session-timeout>999</session-timeout>

          </session-config>

       

          <!-- Welcome files -->

          <welcome-file-list>

              <welcome-file>index.xhtml</welcome-file>

          </welcome-file-list>

       

          <login-config>

              <auth-method>BASIC</auth-method>

          </login-config>

      </web-app>

       

      As you can see in the HTML output, only javascript resources are being injected, but no stylesheets (blueSky). All depenedencies are valid, since the container is JBoss AS 7 (most libaries are "built in"), I was only required to add cssparser library.

       

      <head>

                <link type="text/css" rel="stylesheet" href="/Project/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo">

                <script type="text/javascript" src="/Project/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/packed/packed.js"></script>

                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

                <title>Project</title>   

                <link rel="shortcut icon" href="../../images/symbols/favicon.ico">

      </head>

       

      And since I was able to get "helloworld-rf" (jboss quickstarts) to run almost correctly (at least stylesheet was injected there, but ajax stopped working), I doubt that the migration process should be that of a big deal. So my question is; Does Richfaces support the WAR in EAR mechanism for deployment?

      My deployment hierarchy has the following pattern:

       

      Project.ear

         +-- lib

            +-- project_util_module.jar

         +-- META-INF

            +-- application.xml

            +-- jboss-deployment-structure.xml

            +-- MANIFEST.MF

         +-- project_moduleA.jar

         +-- project_moduleB.jar

         +-- project_moduleC.jar

         +-- project_moduleD.jar

         +-- project_modeleWEB.war

            +-- css

               +-- custom.css

            +-- faces

               +-- all XHTML files

            +-- images (self explanatory)

            +-- META-INF

               +-- MANIFEST.MF (javax.faces.api, com.google.guava, org.w3c.css.sac, com.sun.jsf-impl)

            +-- WEB-INF

               +-- classes

               +-- lib (cssparser.jar and all richfaces.jar)

               +-- faces-config.xml

               +-- web.xml

            +-- index.xhtml

       

      Legend:

      • folders
      • WAR package

       

      If there are further question, just feel free to ask.

        • 1. Re: Richfaces 4.3.1 setup as WAR in EAR
          Radim Hanus Expert

          I don't see any problem in your deployment at all

          war inside ear with richfaces libs in WEB-INF/libs is common deployment option

           

          I'm not sure about Resource Servlet, try to comment it out...

          a bit strange for me are the resource paths in html

          <link type="text/css" rel="stylesheet" href="/Project/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo">

          <script type="text/javascript" src="/Project/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/packed/packed.js"></script>

          <link rel="shortcut icon" href="../../images/symbols/favicon.ico">


          • 2. Re: Richfaces 4.3.1 setup as WAR in EAR
            specialed Newbie

            Hi Radim,

             

            thanks for your hint, but removing the Resource Servlet does not change the fact that stylesheet is not being injected.

             

            I just masked out the String "Project" (the name of the project is *********)

             

            I also do not have any errors during startup/deploy, that any dependencies are missing or any other error concerning stylesheet or resource loading...

            • 3. Re: Richfaces 4.3.1 setup as WAR in EAR
              Radim Hanus Expert

              hm... read this thread to ensure that richfaces are properly installed

              • 4. Re: Richfaces 4.3.1 setup as WAR in EAR
                specialed Newbie

                It is...

                 

                222215:31:29,984 INFO  [org.richfaces.log.Cache] (MSC service thread 1-5) Selected fallback cache factory
                222315:31:29,985 INFO  [org.richfaces.log.Cache] (MSC service thread 1-5) Creating LRUMap cache instance using parameters: {org.richfaces.resourceOptimization.enabled=true, org.richfaces.skin=blueSky, javax.faces.PROJECT_STAGE=Development, org.richfaces.enableControlSkinning=true, javax.faces.STATE_SAVING_METHOD=server, javax.faces.DEFAULT_SUFFIX=.xhtml}
                222415:31:29,987 INFO  [org.richfaces.log.Cache] (MSC service thread 1-5) Creating LRUMap cache instance of 512 items capacity
                222515:31:29,989 INFO  [org.richfaces.log.Application] (MSC service thread 1-5) RichFaces Core Implementation by JBoss by Red Hat, version 4.3.1.Final

                 

                this is the recent log output from a redeploy...

                I also made sure, to check all differences from the famous "helloworld-rf" project and mine.

                I can also assure having used <h:head> component so that the resources can be injected. A second approval is also, that javascript is being injected:

                 

                <script type="text/javascript" src="/Project/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/jquery.js"></script>

                 

                I've red the migration guide over and over, otherwise the skin parameter would still be in capital letters...

                 

                UPDATE

                I've recently changed the title to catch proper attention.

                 

                UPDATE 2

                The following example is what I would expect:

                 

                <head>

                    <title>helloworld-rf</title>

                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

                    <link type="text/css" rel="stylesheet" href="/helloworld-rf/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/blueSky/skinning.css">

                    <script type="text/javascript" src="/helloworld-rf/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development"></script>

                    <script type="text/javascript" src="/helloworld-rf/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/jquery.js"></script>

                    <script type="text/javascript" src="/helloworld-rf/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/packed/packed.js"></script>

                    <link type="text/css" rel="stylesheet" href="/helloworld-rf/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/blueSky/packed/packed.css">

                    <link type="text/css" rel="stylesheet" href="/helloworld-rf/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/packed/packed.css">

                </head>

                 

                WORKAROUND

                I'm hard wiring the two styles (minificated) which are required the most (skinning.css not needed). Allthough this works to migrate all components and try to get rid of the "RF 3.3.3 spacer", but it's not regarded as a production solution.

                 

                <link type="text/css" rel="stylesheet" href="/Project/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/blueSky/packed/packed.css" />

                <link type="text/css" rel="stylesheet" href="/Proeject/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.1.Final/Packed/packed/packed.css" />

                • 5. Re: Richfaces 4.3.1 setup as WAR in EAR
                  specialed Newbie

                  Are there any other suggestions, I'm really stuck here...

                  • 6. Re: Richfaces 4.3.1 CSS resources not being referrenced in compiled <h:head> component
                    specialed Newbie

                    Just to let the community know, what went wrong here:

                     

                    Some components of our frontend (not Richfaces) require Primefaces to be displayed properly. It either seems that Richfaces 4.3.1 has some complications working properly with Primfaces (in our case, version 3.5).

                    By removing the library, Richfaces was able to generate all resources inside the "h:head" component without any issues. I wonder if it's only a version issue of if Richfaces doesn't work with Primefaces at all anymore.