1

I create an example on eclipse to use push of primefaces 5 with glassfish 4.0. I copy code of primefaces's push (http://www.primefaces.org/showcase/push/chat.xhtml). I configuration in pom.xml like bellow:

pom.xml

   <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>webapp</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
    <finalName>${project.artifactId}</finalName>
</build>

<repositories>
    <repository>
        <id>prime-repo</id>
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
        <layout>default</layout>
    </repository>
</repositories>
<dependencies>
    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <!-- Faces Implementation -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.4</version>
    </dependency>
    <!-- Faces Library -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.4</version>
    </dependency>
    <!-- Primefaces Version 5 -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
    </dependency>

    <!-- Atmosphere -->
    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-runtime</artifactId>
        <version>2.1.3</version>
    </dependency>        
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
      </dependency>

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.1</version>
    </dependency>

<!-- File Upload -->
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.2</version>
    </dependency>

    <!-- JSP Library -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <!-- JSTL Library -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
</dependencies>

and for web.xml:

    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <async-supported>true</async-supported>
   </servlet>



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

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <async-supported>true</async-supported>
</servlet>

<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

<!-- Following param only needed for MyFaces (TomEE, etc) -->
<context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

<context-param>
    <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

After I finish all code like primefaces's push and deploy directly from eclipse to glassfish 4 and have error like bellow:

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Lorg/primefaces/push/EventBus;.

Please help me to find out the issue and deploy successful.

1 Answers1

0

I'm a newbie in PFP/Atmosphere but for me it seems like the atmosphere API is missing. And since I've struggled a lot on making Primefaces 5.1 Push to work on Glassfish 4 I would like to share my setup with the community :)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  
 <display-name>MyProject</display-name>
  
 <context-param>
     <param-name>javax.faces.PROJECT_STAGE</param-name>
     <param-value>Development</param-value>
 </context-param>
 
 
 <welcome-file-list>
    <welcome-file>login.html</welcome-file>
 </welcome-file-list>
 
 <!-- **************** FACES CONFIGURATION ******************** -->
 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <async-supported>true</async-supported>
 </servlet>
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
  
   <!-- **************** Primefaces PUSH (Athmosphere based)  ******************** -->
 <servlet>
     <servlet-name>Push Servlet</servlet-name>
     <servlet-class>org.primefaces.push.PushServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
     <async-supported>true</async-supported>
 </servlet>
 <servlet-mapping>
     <servlet-name>Push Servlet</servlet-name>
     <url-pattern>/primepush/*</url-pattern>
 </servlet-mapping>

 <!-- **************** Primefaces FILE UPLOAD  ******************** -->
 <filter>
   <filter-name>PrimeFaces FileUpload Filter</filter-name>
   <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
 </filter>
 <filter-mapping>
   <filter-name>PrimeFaces FileUpload Filter</filter-name>
   <servlet-name>Faces Servlet</servlet-name>
 </filter-mapping>
 
 
 
 
 <!-- ********* PARTIAL SUBMIT <ENABLED> ********* --> 
 <context-param>
   <param-name>primefaces.SUBMIT</param-name>
   <param-value>partial</param-value>
 </context-param>
 
 <!-- ********* CLIENT_SIDE_VALIDATION <ENABLED> ********* -->
 <context-param>
   <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
   <param-value>true</param-value>
 </context-param>
 
 <!-- ********* FACELETS_SKIP_COMMENTS <ENABLED> ********* -->
 <context-param>
   <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
   <param-value>true</param-value>
 </context-param>
 
 <context-param>
   <param-name>primefaces.UPLOADER</param-name>
   <param-value>auto</param-value>
 </context-param>
 
 <context-param>
     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
     <param-value>client</param-value>
 </context-param>
    
</web-app>

My library setup is as follows: WEB-INF/lib/

-primefaces-5.1.jar
-vaadin-slf4j-jdk14-1.6.1.jar -atmosphere-runtime-2.2.4.vaadin5.jar
-slf4j-api-1.7.10.jar -commons-fileupload-1.3.1.jar

Note: I'm using Luna Service Release 1a (4.4.1) and I've found out that when I change my setup I have to remove my App from the Server, reboot the server, redeploy and Project->clean in order to make it work. Hope this post can help.

Svetoslav
  • 563
  • 6
  • 14