7 Replies Latest reply on Sep 9, 2013 2:06 PM by bleathem

    RichFaces Showcase and TomEE

    ccaspanello

      Has anyone sucessfully got RichFaces to work with TomEE?

       

      I've downloaded the Showcase from https://github.com/richfaces4/showcase/tree/4.3.2.20130513-Final and used Maven to build the project using:  mvn clean package.  However, when I run the application I get the following stack trace in my log.

       

      I've done some research and saw this link https://community.jboss.org/thread/221213.  I attempted the suggested solution did not have any success.

       

      We are trying TomEE 1.5.1 and RichFaces 4.3.2.  I know there is a new version of RichFaces, however, we need to still support IE7.

       

      The errors we are getting are the following:

      INFO: Server startup in 1415 ms
      Aug 22, 2013 2:27:43 PM org.apache.catalina.startup.HostConfig deployWAR
      INFO: Deploying web application archive C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6.war
      Aug 22, 2013 2:27:43 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
      INFO: -------------------------
      TomcatWebAppBuilder.init /richfaces-showcase-tomcat6
      Aug 22, 2013 2:27:43 PM org.apache.openejb.util.JarExtractor extract
      INFO: Extracting jar: C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6.war
      Aug 22, 2013 2:27:49 PM org.apache.openejb.util.JarExtractor extract
      INFO: Extracted path: C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\cdi-api-1.0-SP4.jar' contains offending class: javax.enterprise.context.ApplicationScoped. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar' contains offending class: javax.persistence.Entity. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\javax.inject-1.jar' contains offending class: javax.inject.Inject. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\jboss-transaction-api_1.1_spec-1.0.0.Final.jar' contains offending class: javax.transaction.Transaction. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\jms-api-1.1-rev-1.jar' contains offending class: javax.jms.Queue. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\jsr250-api-1.0.jar' contains offending class: javax.annotation.PostConstruct. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\validation-api-1.0.0.GA.jar' contains offending class: javax.validation.Validation. It will be ignored.
      Aug 22, 2013 2:27:49 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher validateJarFile
      WARNING: jar 'C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\WEB-INF\lib\weld-servlet-1.1.4.Final.jar' contains offending class: javax.enterprise.context.ApplicationScoped. It will be ignored.
      Aug 22, 2013 2:27:50 PM org.apache.openejb.config.DeploymentLoader mergeBeansXml
      SEVERE: Unable to read beans.xml from :file:/C:/apache-tomee-plus-1.5.1/webapps/richfaces-showcase-tomcat6/WEB-INF/beans.xml
      Aug 22, 2013 2:27:51 PM org.apache.openejb.config.ConfigurationFactory configureApplication
      INFO: Configuring enterprise application: C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6
      Aug 22, 2013 2:27:53 PM org.apache.openejb.config.ConfigurationFactory configureService
      INFO: Configuring Service(id=BeanManager, type=Resource, provider-id=ProvidedByTomcat)
      Aug 22, 2013 2:27:53 PM org.apache.openejb.config.AutoConfig deploy
      INFO: Configuring PersistenceUnit(name=richfaces-showcase, provider=org.hibernate.ejb.HibernatePersistence)
      Aug 22, 2013 2:27:53 PM org.apache.openejb.config.AutoConfig setJtaDataSource
      INFO: Adjusting PersistenceUnit richfaces-showcase  to Resource ID 'My DataSource' from 'null'
      Aug 22, 2013 2:27:53 PM org.apache.openejb.config.AutoConfig setNonJtaDataSource
      INFO: Adjusting PersistenceUnit richfaces-showcase  to Resource ID 'My Unmanaged DataSource' from 'null'
      Aug 22, 2013 2:27:53 PM org.apache.openejb.config.AppInfoBuilder build
      INFO: Enterprise application "C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6" loaded.
      Aug 22, 2013 2:27:53 PM org.apache.openejb.assembler.classic.Assembler createApplication
      INFO: Assembling app: C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6
      Aug 22, 2013 2:27:55 PM org.apache.openejb.assembler.classic.PersistenceBuilder createEntityManagerFactory
      INFO: PersistenceUnit(name=richfaces-showcase, provider=org.hibernate.ejb.HibernatePersistence) - provider time 1672ms
      Aug 22, 2013 2:27:55 PM org.apache.openejb.cdi.CdiBuilder initSingleton
      INFO: Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@65713428
      Aug 22, 2013 2:27:55 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
      INFO: OpenWebBeans Container is starting...
      Aug 22, 2013 2:27:55 PM org.apache.webbeans.plugins.PluginLoader startUp
      INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
      Aug 22, 2013 2:27:55 PM org.apache.webbeans.plugins.PluginLoader startUp
      INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
      Aug 22, 2013 2:27:55 PM org.apache.openejb.cdi.BeansDeployer validateInjectionPoints
      INFO: All injection points are validated successfully.
      Aug 22, 2013 2:27:55 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
      INFO: OpenWebBeans Container has started, it took 31 ms.
      Aug 22, 2013 2:27:55 PM org.apache.tomee.catalina.TomcatWebAppBuilder deployWebApps
      INFO: using context file C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6\META-INF\context.xml
      Aug 22, 2013 2:27:55 PM org.apache.openejb.assembler.classic.Assembler createApplication
      INFO: Deployed Application(path=C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6)
      Aug 22, 2013 2:27:56 PM org.apache.catalina.core.StandardContext startInternal
      SEVERE: Error listenerStart
      Aug 22, 2013 2:27:56 PM org.apache.catalina.core.StandardContext startInternal
      SEVERE: Context [/richfaces-showcase-tomcat6] startup failed due to previous errors
      Aug 22, 2013 2:27:56 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
      INFO: Undeploying app: C:\apache-tomee-plus-1.5.1\webapps\richfaces-showcase-tomcat6
      Aug 22, 2013 2:27:56 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
      WARNING: cant unbind resource BeanManager
      Aug 22, 2013 2:27:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
      SEVERE: The web application [/richfaces-showcase-tomcat6] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
      Aug 22, 2013 2:27:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
      SEVERE: The web application [/richfaces-showcase-tomcat6] appears to have started a thread named [HSQLDB Timer @1669e7e7] but has failed to stop it. This is very likely to create a memory leak.
      
      
      
        • 1. Re: RichFaces Showcase and TomEE
          bleathem

          The *-tomcat6 war of the showcase is meant for a tomcat (sevlet container) deployment.  You will want to use a Java EE deployment for TomEE (ie. doesn't bundle the jsf jars, etc.).  I'd recommend trying the -openshift war.

           

          Yes, our showcase profiles names need some cleaning up...

           

          Brian

          1 of 1 people found this helpful
          • 2. Re: RichFaces Showcase and TomEE
            ccaspanello

            Thank you for your response Brian, I will give that a shot today and let you know how we make out.

            1 of 1 people found this helpful
            • 3. Re: RichFaces Showcase and TomEE
              ccaspanello

              So I've attempted Brian's solution and I am happy to say I did get a little farther.  At least the application deploys.  However, I am still not able to get the showcase to work.  I am getting the following error:

               

              HTTP Status 500 - java.lang.NullPointerException

              type Exception report
              
              message java.lang.NullPointerException
              
              description The server encountered an internal error that prevented it from fulfilling this request.
              
              exception
              
              org.apache.jasper.JasperException: java.lang.NullPointerException
                   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:472)
                   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
                   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                   org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:172)
              
              root cause
              
              java.lang.NullPointerException
                   org.richfaces.demo.arrangeablemodel.PersistenceLifecycle.execute(PersistenceLifecycle.java:60)
                   javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
                   org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:172)
                   org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:746)
                   org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
                   org.apache.jsp.index_jsp._jspService(index_jsp.java:68)
                   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
                   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
                   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                   org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:172)
              
              

               

              Class from "GrepCode" Build 4.3.1.CR1

              private static final class PersistenceServiceRef
              {
                static final PersistenceService PERSISTENCE_SERVICE = (PersistenceService) FacesContext.getCurrentInstance()
                              .getExternalContext().getApplicationMap().get("persistenceService");
                private  PersistenceServiceRef()
                {
                }
              }
               
               . . .
               
              public void execute(FacesContext context) throws FacesException
              {
                try
                {
                  lifecycle.execute(context);
                }
                finally
                {
                  PersistenceServiceRef.PERSISTENCE_SERVICE.closeEntityManager();
                }
              }
              

               

              I am guessing this has to do with the DataSource and PersistenceContext not being configured properly.

               

              Can you advise on what configuration you guys are using for the showcase and if I need to include any other jars (ie, maybe the in memory Hibernate DB if that is what your using).


              Thanks,

              Chris

              • 4. Re: RichFaces Showcase and TomEE
                bleathem

                Right, so the openshift profile gets the EE dependencies right for tomee, but uses the JBoss AS versions of the persistence.xml.  Try using the tomcat one:

                https://github.com/richfaces4/showcase/blob/master/src/main/resources-tomcat/META-INF/persistence.xml

                 

                Additionally, there may be some things in the web.xml that are important for tomcat:

                https://github.com/richfaces4/showcase/blob/master/src/main/webapp-tomcat/WEB-INF/web.xml

                 

                If you get this working, and are up for it, a Github pull request with a working TomEE profile would be very much appreciated!

                • 5. Re: Re: RichFaces Showcase and TomEE
                  ccaspanello

                  Thanks for your reply Brian.  I copy/modified the openshift profile to create a tomee profile.  I also copied in the persistence.xml from the tomcat profile like you suggested.  However, in doing so I came across a few issues.  The first issue was NoClassDefinition errors relating to Hibernate.  This was expected as TomEE uses OpenJPA instead of Hibernate.  I went to the TomEE site and followed their directions for hooking up Hibernate (http://tomee.apache.org/tomee-and-hibernate.html).  When I cranked up the server the NoClassDefinition errors went away; however I still got the same NullPointerExceptions as described above.  I then decided to take another approach; I reverted the hibernate libraries and changed the persistence.xml to use the OpenJPA implementation.  This resulted in the same NullPointerException as described above.

                   

                  I then decided to abandon trying to get the RichFaces Showcasse to work on TomEE.  Instead I used Netbeans to create a basic Web application in which I hooked up RichFaces to it.  When I launch TomEE I was able to see a "rich:panel" with all the appropriate styling.  This was a good first step.  However, when I tried to do a basic HelloWorld AJAX call (see below) I get a different NullPointerException:

                   

                  java.lang.NullPointerException

                   

                  viewId=/index.xhtml

                  location=%USER_HOME%\RichfacesShowcase\target\RichfacesShowcase-1.0-SNAPSHOT\index.xhtml

                  phaseId=RENDER_RESPONSE(6)

                   

                  Caused by:

                  java.lang.NullPointerException

                  at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:53)

                   

                  HelloWorld.java

                  @ManagedBean
                  @RequestScoped
                  public class HelloWorld implements Serializable
                  {
                      private String name;
                      private String message;
                  
                      public void submit()
                      {
                          if ("".equals(name))
                          {
                              message = "Hello World!";
                          }
                          else
                          {
                              message = "Hello, " + name + "!";
                          }
                      }
                      . . . .
                      // Getters and Setters
                      . . . .
                  }
                  
                  
                  

                   

                  JSF Page (index.xhtml)

                     <h:body>
                          <rich:panel header="Ajax Example">
                              <h:form id="frmAjax">
                                  <h:panelGrid columns="2">
                                      <h:outputLabel value="Name:"/>
                                      <h:inputText value="#{helloWorld.name}" />
                                  </h:panelGrid>
                                  <a4j:commandButton value="Say Hello" action="#{helloWorld.submit}" render="msg" />
                                  <h:outputText id="msg" value="#{helloWorld.message}"/>
                              </h:form>
                          </rich:panel>
                      </h:body>
                  
                  
                  

                   

                  Any thoughts?

                  • 6. Re: RichFaces Showcase and TomEE
                    bleathem

                    That's a shame you can't get the showcase to work, but it does highlight a problem with our current showcase.  Namely that it tries to hard to demonstrate Java EE technology, rather than simply showcasing our components.  The Java EE interop is valuable, but is better left to dedicated developer examples.  This is something we are addressing in our re-vamp of the showcase for RichFaces 5.

                     

                    As for your more simple application, can you post the full stacktrace?

                    • 7. Re: RichFaces Showcase and TomEE
                      bleathem

                      I built a sample RichFaces application from the org.apache.openejb.maven:tomee-webapp-archetype:1.5.2 archetype, and adding RichFaces dependencies to the pom. The app deploys and runs fine, using an a4j:commandButton on the initial page.

                       

                      See the Readme for instructions on building the above application, and running it in an embedded TomEE container:

                      https://github.com/bleathem/tomee-richfaces-app/blob/master/README.md

                       

                      Note however that RichFaces Push (RF-13178)  and Resource Optimisation (RF-12801) both currently have issues when run on OpenWebBeans.