JSF & Richfaces / Primefaces - Maven - Netbeans 8.0.1 - Glassfish 4.1

You have a very similar problem: Richfaces in netbeans with maven i.e. there is a problem when the JSF project is deployed to GlassFish 4. 1

  • I tried to create a JSF project with:
    • a) Maven and javax.faces-war-archetype ver 2.2 and
    • b) as a NetBeans project
  • I've tried using:
    • a) Guide rails 5 → working
    • b) Richfaces 4.3 -> not working
  • The project works fine with Glassfish 4.0

    andWildFly 8.1

The exception I am getting in netbeans is:

Warning: StandardWrapperValve [Faces Servlet]: Servlet.service () for Servlet Faces Servlet throws java.lang.IllegalStateException at com.sun.faces.context.FacesContextImpl.assertNotReleased (FacesContextImpl.java:705) at com.sun.faces.context.FacesContextImpl.assertNotReleased (FacesContextImpl.java:705). context.FacesContextImpl.getAttributes (FacesContextImpl.java:237) at org.richfaces.context.ExtendedPartialViewContext.setInstance (ExtendedPartialViewContext.java:55) at org.richfaces.context.ExtendedPartialViewContext.release (ExtendedPartialViewContext.release.ExtendedPartialViewContext.release (ExtendedPartialView) .context.ExtendedPartialViewContextImpl.release (ExtendedPartialViewContextImpl.java:424) at com.sun.faces.context.FacesContextImpl.release (FacesContextImpl.java:591) at javax.faces.webapp.FacesServlet.service (at faces. org.apache.catalina.core.StandardWrapper.service (StandardWrapper.java: 1682) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:160) at org.apache.catalina .StandardPipeline.doInvoke (StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke (WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService (CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable.call (ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service (ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService (HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle (Http175 ).java at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead (HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute (ExecutorChainResolver.java:119.grizzlyzzlyglass DefaultFilterChain.executeFilter (DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart (DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DinFilterCheap3. .glassfish.grizzly.filterchain.DefaultFilterChain.process (DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute (ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent (TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent (AbstractIOS112 ).java: .glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0 (WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100 (WorkerThreadIOStrategy.java:56) at orzzly.glassergies.grizzly. run (WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork (AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java at java.lang.Thread.run (Thread.java:745)nio.transport.TCPNIOTransport.fireIOEvent (TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent (AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategiestWorkerreadThavaerthratethrateg. 117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100 (WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThread:IOStrategy.java:56) threadpool.AbstractThreadPool $ Worker.doWork (AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) at java.lang.Thread.run (Thread.java:745)nio.transport.TCPNIOTransport.fireIOEvent (TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent (AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategiestWorkerreadThavaerthratethrateg. 117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100 (WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThread:IOStrategy.java:56) threadpool.AbstractThreadPool $ Worker.doWork (AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) at java.lang.Thread.run (Thread.java:745)AbstractIOStrategy.fireIOEvent (AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0 (WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.Worker.WorkerThreadIOS $trate:56) org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadfishlyPool $ Worker.doWork (AbstractThreadfishlyfish.javalass:565) at AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) in java.lang.Thread.run (Thread.java:745)AbstractIOStrategy.fireIOEvent (AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0 (WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.Worker.WorkerThreadIOS $trate:56) org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadfishlyPool $ Worker.doWork (AbstractThreadfishlyfish.javalass:565) at AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) in java.lang.Thread.run (Thread.java:745)access $ 100 (WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfishool.grizzly.threadWoodpool.AbstractThreadPool $ ) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) at java.lang.Thread.run (Thread.java:745)access $ 100 (WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfishool.grizzly.threadWoodpool.AbstractThreadPool $ ) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) at java.lang.Thread.run (Thread.java:745)

I will describe the steps that I performed when building a Maven project: This is following the steps I follow to create: A JSF

project, with NetBeans 8.0.1

, GlassFish 4.1

which uses RichFaces

. The project is built using the maven archetype javax.faces-war-archetype ver 2.2

.

  • New project-> Maven-> Project from archetype
  • Search for javax , so the only option in the available arhcetypes would be javax.faces-war-archetype

    - ver2.2

    . Choose it.
  • Enter the name of the place, etc. I choose a name:test_richfaces_with_archetype

  • Click on Finish

pom.xml

created project:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mydomain.myproject</groupId>
    <artifactId>test_richfaces_with_archetype</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>${project.artifactId}</name>
    <description>A simple project with war packaging that depends on JSF 2.2 and 
        javaee 6, in that order.</description>
    <url>http://jsf-spec.java.net/</url>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                  <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

        </plugins>
    </build>
    <properties>
      <spec.snapshot.version>2.2</spec.snapshot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>${spec.snapshot.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>java.net-maven2-SNAPSHOT-repository</id>
            <name>Java.net SNAPSHOT-Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/snapshots/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net-maven2-repository</id>
            <name>Java.net Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
    </repositories>
</project>

      

  1. Right click on the project and select properties

  2. Go to Frameworks

    : you will see the library is JSF 2.2

    already selected for you
  3. Go to tab components

    and checkRichFaces

  4. Click OK and NeatBeans will download the libraries RichFaces

    and put them in the local

    maven repository

pom.xml

changed and now looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.com.mydomain.myproject</groupId>
    <artifactId>test_richfaces_with_archetype</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>${project.artifactId}</name>
    <description>A simple project with war packaging that depends on JSF 2.2 and 
        javaee 6, in that order.</description>
    <url>http://jsf-spec.java.net/</url>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                  <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

        </plugins>
    </build>
    <properties>
      <spec.snapshot.version>2.2</spec.snapshot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>${spec.snapshot.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.richfaces.core</groupId>
            <artifactId>richfaces-core-impl</artifactId>
            <version>4.3.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.richfaces.ui</groupId>
            <artifactId>richfaces-components-ui</artifactId>
            <version>4.3.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>java.net-maven2-SNAPSHOT-repository</id>
            <name>Java.net SNAPSHOT-Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/snapshots/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net-maven2-repository</id>
            <name>Java.net Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
            <id>RichFaces-maven-lib</id>
            <layout>default</layout>
            <name>Repository for library RichFaces-maven-lib</name>
        </repository>
    </repositories>
</project>

      

welcomeRichfaces.xhtml

-

<?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:rich="http://richfaces.org/rich"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Richfaces Welcome Page</title>
    </h:head>
    <h:body>
        <rich:panel header="Welcome to Richfaces">
            RichFaces is an advanced UI component framework for easily integrating Ajax capabilities into business applications using JSF.  Check out the links below to lear more about using RichFaces in your application.
            <ul>
                <li><h:outputLink value="http://richfaces.org" >Richfaces Project Home Page</h:outputLink></li>
                <li><h:outputLink value="http://showcase.richfaces.org" >Richfaces Showcase</h:outputLink></li>
                <li><h:outputLink value="https://community.jboss.org/en/richfaces?view=discussions" >User Forum</h:outputLink></li>
                <li><h:outputLink value="http://www.jboss.org/richfaces/docs" >Richfaces documentation...</h:outputLink>
                    <ul>
                        <li><h:outputLink value="http://docs.jboss.org/richfaces/latest_4_X/Developer_Guide/en-US/html_single/" >Development Guide</h:outputLink></li>
                        <li><h:outputLink value="http://docs.jboss.org/richfaces/latest_4_X/Component_Reference/en-US/html/" >Component Reference</h:outputLink></li>
                        <li><h:outputLink value="http://docs.jboss.org/richfaces/latest_4_X/vdldoc/" >Tag Library Docs</h:outputLink></li>
                    </ul>
                </li>
            </ul>
        </rich:panel>
    </h:body>
</html>

      

AND web.xml

<web-app version="3.0"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <display-name>mojarra-regression-test</display-name>
    <description>A simple regression test to make it easier to get your bug fixed. The only reason we need a web.xml is to set the PROJECT_STAGE to Develoment.  If you have a web.xml, then you need to map the FacesServlet.</description>

    <context-param>
        <description>
            Tell the runtime where we are in the project development
            lifecycle.  Valid values are: 
            Development, UnitTest, SystemTest, or Production.
            The runtime will display helpful hints to correct common mistakes
            when the value is Development.
        </description>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</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>

   <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
   </servlet-mapping>

   <welcome-file-list>
     <welcome-file>faces/main.xhtml</welcome-file>
   </welcome-file-list>

</web-app>

      

Also if you hit the plus sign in the node dependencies you will see:

  • Javaee-api-6.0.jar
  • javax.faces-api-2.2.jar
  • Richfaces-component-ui-4.3.3.Final.jar
  • cssparser-0.9.5.jar
  • guava-13.0.1.jar
  • Richfaces-components-api-4.3.3.Final.jar
  • Richfaces-core-api-4.3.3.Final.jar
  • bursa-1.3.jar

Note: in my case there was an error with the guava library when I tried to compile the project (clean-build). I deleted the google folder that I already had in my repository, did a clean build again. Everything was re-downloaded and the project compiled.

  1. Right click project

    , go to properties

    , select run

    and select GlassFish

    from the server list. Click OK.
  2. Right click on the project and choose Run. At this point, the browser will open: http://localhost:8080/test_richfaces_with_archetype

    . You will have something like First name: Duke Last name: Java

    submit buttons.
  3. Go to main.xhtml

    edit it to add an action to the command button element: <h:commandButton value="submit" action="welcomeRichfaces"/>

    . Savemain.xhtml.

  4. Reload the page and click the button. The greetings richfaces xhtml should render in your browser.
  5. END
+3


source to share


1 answer


I had the same problem with Wildfly 8.2. My solution was to "downgrade" the jsf. Please see Upgrading to Wildfly 8.2 with a bug



+1


source







All Articles