1 2 Previous Next 22 Replies Latest reply on Jul 5, 2014 11:37 AM by eanunezt

    Primefaces lib not found by WAR

    rafaelbf

      Hi.

       

      I googled a lot and didnt find any answer.

      If there is a discussion abount this, sorry I didnt find.

       

      I have an EAR project that contains an EJB and a WAR projects.

      Every libs are in ear.lib folder and EJB and WAR uses those libs with no errors.

       

      The problems is with primefaces lib. It only works when i put it in war.WEB-INF/lib.

      If i put the lib in ear/lib or as a module i jboss as7 I get a

      java.lang.ClassNotFoundException: org.primefaces.model.ScheduleModel

       

      I need to make the primefaces lib ear scooped.

      How can I do this?

      The same ear works with glassfish or jboss as6.

       

      Thanks in advance.

        • 1. Re: Primefaces lib not found by WAR
          jaikiran

          Rafael, welcome to the forums!

           

          Please post the entire exception stacktrace for a start.

          • 2. Re: Primefaces lib not found by WAR
            rafaelbf

            Hi jaikiran. Thanks for the reply.

            Here is the stacktrace of the start process of jboss.

             

            With this configuration, the primefaces lib is a module of jboss.

             

            10:20:18,393 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."dockeep.ear"."dockeepWeb.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."dockeep.ear"."dockeepWeb.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "dockeepWeb.war" of deployment "dockeep.ear"

                      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_41]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_41]

                      at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_41]

            Caused by: java.lang.NoClassDefFoundError: org/primefaces/model/ScheduleModel

                      at java.lang.Class.getDeclaredConstructors0(Native Method) [classes.jar:1.6.0_41]

                      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398) [classes.jar:1.6.0_41]

                      at java.lang.Class.getConstructor0(Class.java:2708) [classes.jar:1.6.0_41]

                      at java.lang.Class.getConstructor(Class.java:1659) [classes.jar:1.6.0_41]

                      at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108)

                      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                      ... 5 more

            Caused by: java.lang.ClassNotFoundException: org.primefaces.model.ScheduleModel from [Module "deployment.dockeep.ear.dockeepWeb.war:main" from Service Module Loader]

                      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]

                      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]

                      ... 11 more

             

            buildpath.png

            • 3. Re: Primefaces lib not found by WAR
              jaikiran

              Have you declared the dependency on the module which contains that class? How have you done it? Post the relevant MANIFEST.MF or jboss-deployment-structure.xml

              • 4. Re: Primefaces lib not found by WAR
                rafaelbf

                No, I haven't. MANIFEST.INF or jboss-deployment-structure.xml.

                • 5. Re: Primefaces lib not found by WAR
                  jaikiran

                  With this configuration, the primefaces lib is a module of jboss.

                  If you are deploying it as a module you'll have to declare the dependency. See this for more details https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

                  • 6. Re: Primefaces lib not found by WAR
                    rafaelbf

                    I added the line at MANIFIEST.INF of the WAR project:

                    Dependencies: org.primefaces

                    And I got the same error.

                    I do not thing this is necessary, since there is WAR classes that references modules of jboss without any configuration.

                     

                    I didn't understand this points:

                    1. The jboss as7 documents says: "Sub deployments (wars and ejb-jars) always have a dependency on the parent module, which gives them access to classes in EAR/lib, however they do not always have an automatic dependency on each other." When I put the primefaces lib in EAR/lib, the WAR don't see it from managed beans within this WAR. But, every other classes in WAR see every lib in EAR/lib. The WAR don't see libs from ear if referenced from managed beans. Why?
                    2. If I put primefaces as a module of jboss, the same occurs.
                    3. If I put primefaces in WAR/WebContent/WEB-INF/lib, everything works ok.

                     

                    Thanks for your attention.

                    • 7. Re: Primefaces lib not found by WAR
                      jaikiran

                      Rafael Ferreira wrote:

                       

                      I added the line at MANIFIEST.INF of the WAR project:

                      The file should be named MANIFEST.MF.

                       

                       

                      Rafael Ferreira wrote:

                       

                      I do not thing this is necessary, since there is WAR classes that references modules of jboss without any configuration.

                       

                      It is necessary. Without that, the module classloader will not be able to see the classes you have packaged as a JBoss Module.

                      • 8. Re: Primefaces lib not found by WAR
                        rafaelbf

                        jaikiran pai wrote:

                         

                        Rafael Ferreira wrote:

                         

                        I added the line at MANIFIEST.INF of the WAR project:

                        The file should be named MANIFEST.MF.

                        Sorry, I wrote MANIFEST.INF wrong.

                        The file is typed rigth as MANIFEST.MF and its content is:

                        Manifest-Version: 1.0

                        Dependencies: org.primefaces

                        So, the same error.

                         

                         

                         

                        jaikiran pai wrote:

                        Rafael Ferreira wrote:

                         

                        I do not thing this is necessary, since there is WAR classes that references modules of jboss without any configuration.

                         

                        It is necessary. Without that, the module classloader will not be able to see the classes you have packaged as a JBoss Module.

                        Why this configuration is necessary only for primefaces lib? The WAR project references all other modules without the configuration.

                         

                         

                        If I put all libs in EAR/lib, the same problem occurs.

                        • 9. Re: Primefaces lib not found by WAR
                          nickarls

                          Why this configuration is necessary only for primefaces lib? The WAR project references all other modules without the configuration.

                           

                          The deployment processors adds some implicit stuff depending on what it finds in your application.

                          • 10. Re: Primefaces lib not found by WAR
                            lafr

                            "org.primefaces" is the name of your module?

                            <module xmlns="..." name="org.primefaces">

                            ...

                            </module>

                            Please show us the content of your module.xml.

                             

                            You also had a look at https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments? Some references are added automatically.

                            What you mean with "The WAR project references all other modules without the configuration."? What's your war using not containing itself?

                             

                            Libraries in EAR/lib indeed should be available to all war and jar files in the EAR root folder.

                            Your war is mentioned in EAR/META-INF/application.xml?

                            • 11. Re: Primefaces lib not found by WAR
                              rafaelbf

                              Frank Langelage wrote:

                               

                              "org.primefaces" is the name of your module?

                              <module xmlns="..." name="org.primefaces">

                              ...

                              </module>

                              Please show us the content of your module.xml.

                               

                              Here is the content of the module.xml of primefaces:

                              <module xmlns="urn:jboss:module:1.1" name="org.primefaces">

                                  <resources>

                                      <resource-root path="primefaces-3.4.2.jar"/>

                                  </resources>

                               

                               

                                  <dependencies>

                                      <module name="javax.faces.api" />

                                      <module name="org.apache.commons.fileupload" />

                                  </dependencies>

                              </module>

                               

                               

                              You also had a look at https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments? Some references are added automatically.

                              I see the guide, thanks for the information.

                               

                               

                              What you mean with "The WAR project references all other modules without the configuration."? What's your war using not containing itself?

                              My WAR are using the modules that I added: org.apache.commons.fileupload. Other modules like org.apache.commons.*, javax.mail etc. And some libs in EAR/lib

                               

                              The WAR references those libs with no problems. But primefaces module (or any lib) that is referenced by my WAR managed beans doesn't load to my WAR.

                               

                               

                              Libraries in EAR/lib indeed should be available to all war and jar files in the EAR root folder.

                              That is true to all classes in my WAR. But not to the classes annotaded with @ManagedBean.

                               

                               

                              Your war is mentioned in EAR/META-INF/application.xml?

                              Here is the application.xml

                              <?xml version="1.0" encoding="UTF-8"?>

                              <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"

                                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"

                                version="6">

                                <display-name>dockeep</display-name>

                                <module>

                                                  <ejb>dockeepJpa.jar</ejb>

                                </module>

                                <module>

                                <web>

                                                            <web-uri>dockeepWeb.war</web-uri>

                                <context-root>dockeepWeb</context-root>

                                </web>

                                </module>

                              </application>

                              • 12. Re: Primefaces lib not found by WAR
                                rafaelbf

                                I made an EAR to illustrate the error.

                                Using a brand new jboss-as-7.1.1.Final.

                                 

                                If you move primefaces lib to war/WebContent/WEB-INF/lib, it will work.

                                If you move primefaces lib to a jboss module, it wil not work.

                                 

                                My questions: Why primefaces lib only load properly to the war if it was within war/WebContent/WEB-INF/lib?

                                • 13. Re: Primefaces lib not found by WAR
                                  nickarls

                                  Where have you defined the module dependency if you use the module approach?

                                  • 14. Re: Primefaces lib not found by WAR
                                    lafr

                                    Deployed ear.ear on AS7 7.2.0-Alpha1-SNAPSHOT.

                                     

                                    The final cause for me was

                                    Caused by: java.lang.ClassNotFoundException: javax.faces.context.PartialViewContextFactory from [Module "deployment.ear.ear:main" fr

                                        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.3.GA]                      

                                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA

                                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA]

                                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.3.GA]

                                        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA]       

                                        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA]             

                                     

                                    So you have to add

                                    Dependencies: javax.faces.api

                                    to your META-INF/MANIFEST.MF.

                                     

                                    Having this done I get

                                    11:02:28,282 INFO  [org.jboss.as.server.deployment#start] JBAS015876: Starting deployment of "ear.ear" (runtime-name: "ear.ear")
                                    11:02:28,735 INFO  [org.jboss.as.server.deployment#start] JBAS015876: Starting deployment of "null" (runtime-name: "war.war")  
                                    11:02:28,898 INFO  [org.jboss.web#doStart] JBAS018210: Register web context: /war                                              

                                    11:02:28,924 INFO  [javax.enterprise.resource.webcontainer.jsf.config#contextInitialized] Initializing Mojarra 2.1.16-jbossorg-1 201

                                    11:02:30,958 INFO  [org.primefaces.webapp.PostConstructApplicationEventListener#processEvent] Running on PrimeFaces 3.4.2      
                                    11:02:31,011 INFO  [stdout#write] Hello Bean                                                                                   
                                    11:02:31,012 INFO  [stdout#write] Hello Utils                                                                                  
                                    11:02:31,195 INFO  [org.jboss.as.server#handleResult] JBAS018559: Deployed "ear.ear" (runtime-name : "ear.ear")                
                                    1 2 Previous Next