TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
246 stars 102 forks source link

Bootsfaces components not rendering. #636

Closed tg47 closed 7 years ago

tg47 commented 7 years ago

I’ve encountered a problem with Bootsfaces and it seems like it could either be a bug or a configuration issue that I am missing.

I’ve been developing a web application that uses Bootsfaces components (Version 1.0.2). At times the Bootsfaces components are not being rendered. Everything else in the application renders except for Bootsfaces. Originally I thought this may be due to an incompatibility with PrimeFaces. I had a few of these components in the application as well. So I went and created an entirely new web application that didn’t include Primefaces. This application was developed using Netbeans (version 8.2), built using Gradle and Deployed on the Payara Server (version 4.1.1). I also tested the war by deploying it on a separate Glassfish server (version 4.1.1).

Initially this web application worked fine and the Bootsfaces components were being rendered as they should. Eventually I plugged in some Shiro components and the next time I deployed the project the Bootsfaces components wouldn’t render. So I removed the Shiro components and deployed the project again and the Bootsfaces components did appear again. I next added a backing bean and deployed the project. This caused the Bootsfaces components not to render again.

I have a simple login screen, login.xhtml, to show what is happening. This is the code for the page.

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:b="http://bootsfaces.net/ui">
    <h:head>       
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        </f:facet>           
        <title>Login Form</title>       
        <h:outputStylesheet library="css" name="login.css"/>               
    </h:head>   
    <h:body>  
        <h:form id="login" prependId="false">                          
            <div class="banner-block">
                <div class="title-block">                     
                    <h2>Test Login Page</h2> 
                </div>
            </div>
            <div class="info-block">
                <h2>Please Sign In</h2>
                <b:inputText id="username" placeholder="User Name"/>
                <b:inputSecret id="password" placeholder="Password"/>
                <b:commandButton id="subbutton" ajax="false" type="submit" value="Log In"/>
            </div>            
        </h:form>
    </h:body>
</html>

You can see that there are 3 Bootsfaces components in this page.

When the page is displayed these components are missing from the page source in the browser. This occurs in IE, Firefox and Chrome. This is what the page source shows for this div block:

            <div class="info-block">
                <h2>Please Sign In</h2>
            </div>

However these components are in the component tree of the page:

<div class="banner-block"> <div class="title-block"> <h2>Test Login Page</h2> </div> </div> <div class="info-block"> <h2>Please Sign In</h2>

<InputText ajax="false" col-lg="-1" col-md="-1" col-sm="-1" col-xs="-1" colLg="-1" colMd="-1" colSm="-1" colXs="-1" disabled="false" display="block" id="username" immediate="false" inView="true" inline="false" label-col-lg="-1" label-col-md="-1" label-col-sm="-1" label-col-xs="-1" label-large-screen="-1" label-medium-screen="-1" label-small-screen="-1" label-tiny-screen="-1" labelColLg="-1" labelColMd="-1" labelColSm="-1" labelColXs="-1" labelLargeScreen="-1" labelMediumScreen="-1" labelSmallScreen="-1" labelTinyScreen="-1" large-screen="-1" largeScreen="-1" localValueSet="false" maxlength="-2147483648" medium-screen="-1" mediumScreen="-1" placeholder="User Name" readonly="false" render-label="true" renderLabel="true" rendered="true" required="false" size="-2147483648" small-screen="-1" smallScreen="-1" tags="false" tiny-screen="-1" tinyScreen="-1" tooltip-container="body" tooltip-delay="0" tooltip-delay-hide="0" tooltip-delay-show="0" tooltipContainer="body" tooltipDelay="0" tooltipDelayHide="0" tooltipDelayShow="0" transient="false" typeahead="false" typeahead-highlight="true" typeahead-hint="true" typeahead-limit="5" typeahead-min-length="1" typeaheadHighlight="true" typeaheadHint="true" typeaheadLimit="5" typeaheadMinLength="1" valid="true"/>

<InputSecret ajax="false" col-lg="-1" col-md="-1" col-sm="-1" col-xs="-1" colLg="-1" colMd="-1" colSm="-1" colXs="-1" disabled="false" display="block" id="password" immediate="false" inView="true" inline="false" label-col-lg="-1" label-col-md="-1" label-col-sm="-1" label-col-xs="-1" label-large-screen="-1" label-medium-screen="-1" label-small-screen="-1" label-tiny-screen="-1" labelColLg="-1" labelColMd="-1" labelColSm="-1" labelColXs="-1" labelLargeScreen="-1" labelMediumScreen="-1" labelSmallScreen="-1" labelTinyScreen="-1" large-screen="-1" largeScreen="-1" localValueSet="false" maxlength="-2147483648" medium-screen="-1" mediumScreen="-1" placeholder="Password" readonly="false" render-label="true" renderLabel="true" rendered="true" required="false" size="-2147483648" small-screen="-1" smallScreen="-1" tags="false" tiny-screen="-1" tinyScreen="-1" tooltip-container="body" tooltip-delay="0" tooltip-delay-hide="0" tooltip-delay-show="0" tooltipContainer="body" tooltipDelay="0" tooltipDelayHide="0" tooltipDelayShow="0" transient="false" typeahead="false" typeahead-highlight="true" typeahead-hint="true" typeahead-limit="5" typeahead-min-length="1" typeaheadHighlight="true" typeaheadHint="true" typeaheadLimit="5" typeaheadMinLength="1" valid="true"/>

<CommandButton ajax="false" col-lg="-1" col-md="-1" col-sm="-1" col-xs="-1" colLg="-1" colMd="-1" colSm="-1" colXs="-1" disabled="false" display="block" icon-spin="false" iconSpin="false" id="subbutton" immediate="false" inView="true" large-screen="-1" largeScreen="-1" medium-screen="-1" mediumScreen="-1" rendered="true" small-screen="-1" smallScreen="-1" tiny-screen="-1" tinyScreen="-1" tooltip-container="body" tooltip-delay="0" tooltip-delay-hide="0" tooltip-delay-show="0" tooltipContainer="body" tooltipDelay="0" tooltipDelayHide="0" tooltipDelayShow="0" transient="false" type="submit" value="Log In"/>

</div>

So for some reason, BootsFaces is not rendering correctly even though the components are present in the component tree. I’ve tried removing the different caches associated with the project and that has helped at times. However is does not consistently resolve the problem.

stephanrauh commented 7 years ago

Just to be sure: the error occurs only when you've activated Shiro? Does removing Shiro solve the bug, even in your new Login.xhtml you've posted above?

stephanrauh commented 7 years ago

You could also help us by telling us how to integrated Shiro in your project (web.xhtml, shiro.ini, pom.xml etc.). I'm not familiar with this framework. All I know is that it's popular and that many folks say it's good.

tg47 commented 7 years ago

This happened when I implemented the Shiro components. Which consisted of the Shiro jars, an ini file and some custom java classes. Then I removed those components, cleared all the cache and ran the project again and the Bootsfaces components rendered again.

Next I added a backing bean. This bean interacts with an ejb to retrieve data from the database. This backing bean does not interact with Shiro. At this point there were no Shiro components in the project. When I ran the project in Netbeans after adding the bean the problem reoccurred and the Bootsfaces Components were not being rendered. I also took the war file and deployed it on a separate Glassfish server and Bootsfaces was not rendering there either.

I originally had a project that I had been working on the past few weeks. As I worked with it everything would seem fine. Bootsfaces would work as it should. Then at a certain point the components would just stop rendering. I haven't been able to isolate exactly when this happens. Bootsfaces has run with the two features I mentioned above. Shiro and the Backing bean in this project but at a certain point through the course of development work it would just disappear. The other components of the project such as Primefaces would still render. However at that point Bootsfaces would not.

So I decided to create the project all over again and see when Bootsfaces stopped working as I added the different components. As I mentioned it stopped working when I separately added the Shiro components and the backing bean to this new project. Though it has worked in the other project in Netbeans with these components in the past.

One last element of this problem is I often see the scenario where the Bootsfaces components will render in Netbeans. Then I deploy the war on a server running glassfish and when I run the application Bootsfaces is not rendering. So when I say it is working, it can work in Netbeans and not as depolyed on the server. Then again I see the scenario where it stops working in Netbeans as well.

The login.xhtml file that I showed as an example yesterday was run without Shiro. I had made it the welcome page of the new project I created at that point. This did have the backing bean as part of the project at that point.

tg47 commented 7 years ago

One last thing just to reiterate, is this problem happens without Shiro in the project at all. It happens with the presence of just the backing bean.

stephanrauh commented 7 years ago

It's good to know it's not a Shiro problem. That would have made me very nervous :). But I know of at least one project using BootsFaces and Shiro successfully, so it seems unlikely.

I have three ideas:

If everything fails: can you send me us a copy of the source code of a broken version? If copyright allows, I'd prefer you to create a public or private GitHub repository and to send us the link.

jepsar commented 7 years ago

FYI, I use Shiro in combination with BootsFaces on Payara without any problems.

tg47 commented 7 years ago

Thanks for the feedback. I took a closer look at the build as you said. There was one source of caching that Gradle uses that I was not aware of. This appears under the users home directory in the path .gradle\caches. I deleted the contents of this folder and this seems to resolve the problem.

I had been running Bootsfaces in Netbeans when I encountered the problem. So I deleted the contents of the gradle cache. I also deleted some of the other cache sources, such as the glassfish osgi cache, netbeans cache and undeployed the application. When I ran the application again in Netbeans the bootsfaces components were rendering again. I took the war file and deployed it on a separate server and this worked correctly as well.

I had also been having this problem on another computer that I had been working on. When I cleared the gradle cache on this machine everything worked correctly as well. So it appears that the problem is related to how Gradle is performing caching.

maschiojv commented 7 years ago

I had the same problem. I downloaded Payara today. Maybe is a problem with Payara 171 release.

tg47 commented 7 years ago

Hello, I believe you can close this issue. It seems to be related to the caching and not to Bootsfaces. I occasionally get this error while performing development work. I just remove the different cache sources and the next time I build the project everything works fine.

Thanks so much for your help.

stephanrauh commented 7 years ago

@tg47 Thanks for reporting back! I suspected something like that - caching, or whatever. The problem is I couldn't tell exactly what "whatever" means. Caching sounds like a likely cause of problems. So I'll follow your recommendation to close the bug.

gaidai commented 6 years ago

Hello friend , I had this problem with GlassFish 4.2.0 , but downloaded new 5.0 and added this parameter to glassfish-web.xml :

<parameter-encoding default-charset="UTF-8"/> 

Put it inside - and Bootsfaces will nice render!!

nando2301 commented 6 years ago

Tengo el mismo problema. Uso GlassFish 4.1.2, Apache Shiro 1.3.2, Shiro Faces 2.0, BootsFaces 1.2.0, Apache Cayenne 4.0.B2, pero tengo un proyecto con los mismos componentes, al copiar partes del proyecto mi página de login no muestra componentes BootsFaces.

Proyecto Original

Proyecto 1

Copia de Proyecto

Proyecto 2

pom.xml de proyecto que no muestra componentes BootsFaces

    <dependencies>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cayenne</groupId>
            <artifactId>cayenne-server</artifactId>
            <version>4.0.B2</version>
        </dependency>
        <dependency>
            <groupId>net.bootsfaces</groupId>
            <artifactId>bootsfaces</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-faces</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-quartz</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.7.25</version>
        </dependency>
    </dependencies>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <display-name>Reuniones</display-name>
    <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>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <!-- Activates the waitcursor and the double-click protection -->
    <context-param>
        <param-name>net.bootsfaces.blockUI</param-name>
        <param-value>true</param-value>
    </context-param>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <mime-mapping>
        <extension>json</extension>
        <mime-type>application/json</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff2</extension>
        <mime-type>application/x-font-woff</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff</extension>
        <mime-type>application/x-font-woff</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot</extension>
        <mime-type>application/x-font-eot</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>ttf</extension>
        <mime-type>application/x-font-ttf</mime-type>
    </mime-mapping>

    <!-- Apache Shiro Begin -->
    <listener>
        <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    </listener>
    <filter>
        <filter-name>ShiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ShiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <!-- Apache Shiro End-->

    <!--Apache Cayenne-->
    <filter>
        <filter-name>cayenne-meetings</filter-name>
        <filter-class>org.apache.cayenne.configuration.web.CayenneFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>cayenne-meetings</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--Apache Cayenne End-->
</web-app>

glassfish-web.xml por defecto.

shiro.ini

[main]
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.authenticationQuery = SELECT password from user where username = ?
jdbcRealm.userRolesQuery = select r.rolename from role r, userrole ur, user u where ur.role_idrole = r.idrole and ur.user_idusername = u.idusername and u.username = ?;

ds = com.mysql.jdbc.jdbc2.optional.MysqlDataSource
ds.serverName = 
ds.port =
ds.user =
ds.password =
ds.databaseName =
jdbcRealm.dataSource= $ds

passwordMatcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
credentialsMatcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher
credentialsMatcher.hashAlgorithmName = SHA-256
credentialsMatcher.storedCredentialsHexEncoded = true
credentialsMatcher.hashIterations = 5000

multipleroles = org.nando.meetings.utils.MultipleRolesAuthorizationFilter

;authc = org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter
authc.loginUrl = /faces/login.xhtml
authc.successUrl = /faces/index.xhtml
multipleroles.unauthorizedUrl = /faces/unauthorized.xhtml

ssl.enabled = false

# Use default password matcher (SHA-256, 500000 hash iterations)
passwordMatcher = org.apache.shiro.authc.credential.PasswordMatcher

# Filter Setup
[urls]
/javax.faces.resource/** = anon
/resources/** = anon
/login.xhtml = authc
/faces/index.xhtml = authc
/logout = logout

/ = authc, multipleroles[admin,moderador,organizador,asistente]
/faces/users/** = authc, multipleroles[admin]