14 Replies Latest reply on Aug 5, 2011 5:05 AM by tnfink

    How to package an EAR with an embedded SAR in AS 7.0.0.CR1?

    tnfink

      I am trying to build an EAR with an embedded SAR using the new AS 7.0.0.CR1. If I deploy my SAR separately it is recognized and the MBean is registered at the MBean server.

       

      If I embed it into an EAR without any additional configuration, I get a ClassNotFoundException regarding my MBean implementation.

       

      If I add a jboss-app.xml deployment descriptor with JBoss 5 syntax, I do not get an error, but my MBean is not registered.

       

      The quickstarts do not contain any SAR example. In the integration tests of the AS I do not find an embedded SAR.

       

      Does anyone know if SARs embedded in an EAR are supported in AS 7.0.0.CR1?

        • 1. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
          jaikiran

          Torsten Fink wrote:

           

          If I embed it into an EAR without any additional configuration, I get a ClassNotFoundException regarding my MBean implementation.

           

          That should have worked. Can you please post the entire exception stacktrace?

          • 2. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
            tnfink

            sure:

             

            18:59:56,382 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-11) MSC00001: Failed to start service jboss.deployment.subunit."as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear"."as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear"."as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar".INSTALL: Failed to process phase INSTALL of subdeployment "as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar" of deployment "as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear"

                      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

                      at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

                      at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]

            Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Component class not found

                      at org.jboss.as.service.ReflectionUtils.getClass(ReflectionUtils.java:102)

                      at org.jboss.as.service.ParsedServiceDeploymentProcessor.addServices(ParsedServiceDeploymentProcessor.java:111)

                      at org.jboss.as.service.ParsedServiceDeploymentProcessor.deploy(ParsedServiceDeploymentProcessor.java:102)

                      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

                      ... 5 more

            Caused by: java.lang.ClassNotFoundException: de.akquinet.jbosscc.as7eval.mbean.sar.ApplicationManagement from [Module "deployment.as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear.as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar:main" from Service Module Loader]

                      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:358)

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:330)

                      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)

                      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)

                      at java.lang.Class.forName0(Native Method) [:1.6.0_26]

                      at java.lang.Class.forName(Class.java:247) [:1.6.0_26]

                      at org.jboss.as.service.ReflectionUtils.getClass(ReflectionUtils.java:100)

                      ... 8 more

             

             

            18:59:56,587 INFO  [org.jboss.as.server.controller] (pool-2-thread-30) Deployment of "as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear" was rolled back with failure message {"Failed services" => {"jboss.deployment.subunit.\"as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear\".\"as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear\".\"as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar\".INSTALL: Failed to process phase INSTALL of subdeployment \"as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar\" of deployment \"as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear\""},"Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear\".CLEANUP"]}

            • 3. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
              jaikiran

              I couldn't reproduce this locally. Here's a testcase that I added https://github.com/jaikiran/jboss-as/commit/5f3e54aa2442ad1ad34a826d92e9c8211f9a8531 and it works fine. The .sar within the .ear deploys fine. Can you post the output of:

               

              jar -tf as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear

               

              and

               

              jar -tf as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar

               

              Or, if it's possible, then please attach a reproducible .ear.

              • 4. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                tnfink

                You can download the EAR here:

                https://files.me.com/torsten.fink/hfhf51

                 

                You can download the (nearly empty) Maven project here:

                https://files.me.com/torsten.fink/3nwdvh

                 

                Thanks for your help!

                • 5. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                  jaikiran

                  In your application.xml, you have marked it as a connector:

                   

                  <module>
                      <connector>as7-mbean-prototype-sar-0.0.1-SNAPSHOT.sar</connector>
                    </module>
                  

                   

                  Remove that entry. That's incorrect. The .sar doesn't need any mapping in the application.xml.

                  • 6. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                    tnfink

                    Yes I noticed too, that a connector-module looks strange. It is generated by the Maven ear plugin using the sarModule configuration. I changed it manually to a "java" module which leads to the same error message.

                     

                    When I remove the module tag in the application.xml the ear is deployed without an error. But, the MBean is not deployed.

                     

                    Can you give me a sar embedded in an ear which is deployable? Is it possible to export the ear of your test case which is generated with ShrinkWrap?

                    • 7. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                      jaikiran

                      Torsten Fink wrote:

                       

                      Yes I noticed too, that a connector-module looks strange. It is generated by the Maven ear plugin using the sarModule configuration. I changed it manually to a "java" module which leads to the same error message.

                      Those module types have different meaning. Don't use those to point to a .sar (which is a JBoss specific type).

                       

                       

                      Torsten Fink wrote:

                       

                       

                       

                      When I remove the module tag in the application.xml the ear is deployed without an error. But, the MBean is not deployed.

                       

                      Yes, removing the module element from the application.xml should work. Infact you don't even need a application.xml.

                       

                       

                      Torsten Fink wrote:

                       

                       

                      Can you give me a sar embedded in an ear which is deployable? Is it possible to export the ear of your test case which is generated with ShrinkWrap?

                      Yes, it's possible to export the archive via ShrinkWrap as follows (just one addition line of code):

                       

                      @Deployment(testable = false)
                          public static EnterpriseArchive getDeployment() {
                              final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "simple-sar.sar");
                              sar.addClasses(SarWithinEarServiceMBean.class, SarWithinEarService.class);
                              sar.addAsManifestResource("sar/jboss-service.xml", "jboss-service.xml");
                      
                              final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
                              ear.addAsModule(sar);
                              // export the ear to filesystem
                              ear.as(ZipExporter.class).exportTo(new File(".", ear.getName()), true);
                              return ear;
                          }
                      

                       

                      I've attached the .ear that was generated by that testcase, to this thread.

                      1 of 1 people found this helpful
                      • 8. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                        tnfink

                        First, thanks for your advise!

                         

                        I removed the module in the application.xml and it did not work. I then removed the application.xml completely and it worked.

                         

                        To get the use case a little bit more realistic I added an ejb module to the ear.

                         

                        Version 1: The ejb module ist listed in the application.xml

                        => only the ejb module is deployed, the sar module is not.

                         

                        Version2: I removed the application.xml

                        => both the ejb and the sar modules are deployed.

                         

                        I attached both ears. as7-mbean-prototype-ear-0.0.1-SNAPSHOT.ear is the one with the application.xml.

                         

                        Is this a bug in the CR1?

                        • 9. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                          jaikiran

                          I filed an enhancement for this https://issues.jboss.org/browse/AS7-1248

                          • 10. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                            tnfink

                            thanks a lot!

                            • 11. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                              jaikiran

                              This is now fixed in AS7 upstream.

                              • 12. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                                tnfink

                                great, thanks again!

                                • 13. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                                  qixunyuan

                                  hello,please give me a guideline for ear project that can deployed within jboss as 7?

                                   

                                  your previous link can't access.

                                  • 14. Re: How to package an EAR with an embedded SAR in AS 7.0.0.CR1?
                                    tnfink