6 Replies Latest reply: Aug 15, 2011 10:02 AM by Red Militante RSS

    Migrating ant + JBoss AS 5 project to JBoss AS 7

    Red Militante Newbie

      I'm attempting to migrate a fairly large project from JBoss AS5 to AS7.  The project is built with ant, the build process is pretty complex.  I'm running into a lot of problems.

       

       

      The first thing I did was read through the AS7 documentation - https://docs.jboss.org/author/display/AS7/, focusing on 'How do I migrate my application from AS5 or AS6 to AS7?' https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7

       

       

      I managed to set up a new data source and import my project into AS7.  When I try to build the project I'm getting a lot of class loading errors, which I expected. 

       

       

      [javac] Compiling 199 source files to /Users/me/Documents/hg/myapp/build
          [javac] /Users/me/Documents/hg/myapp/source/com/company/project/common/jms/JMSApplet.java:10: package javax.jms does not exist
          [javac] import javax.jms.*;
          [javac] ^
      

       

       

      Our build.xml sets 'build.classpath' for use during the 'compile' stage of the build process

       

      <path id="build.classpath">
      
      
                          <pathelement location="${war.dir}/WEB-INF/lib/activemq-core-5.5.0.jar"/>
      
      

       

       

      does AS7 not honor these ant directives?

       

       

      I tried to solve this by creating an *ear/meta-inf/MANIFEST.MF file that references the class path

       

       

      Manifest-Version: 1.0
      Class-Path: /opt/apache-activemq-5.5.0/lib/activemq-core-5.5.0.jar
      
      

       

      This doesn't seem to work - I am still getting the package javax.jms does not exist errors.

       

       

      I'm going by the class loading procedures documented in the AS7 manual - what am I doing wrong? 

       

       

      Is it because i'm using ant?  Should I switch to maven?  My project and build are fairly complex, and I'm not sure if it will be worth going down that route if there's a simple solution to fix these errors with ant in AS7.

       

       

      Any advice appreciated - thanks!

        • 1. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
          Kabir Khan Master

          You're right that what we do is based on maven. Your quickest fix is probably to make your build.classpath point to a fileset including all jars under jbossas7/modules

          • 2. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
            Red Militante Newbie

            Thank you - your advice enabled me to be able to build my project successfully in as7.  I have another problem when I attempt to deploy my application.

             

            I deploy my application by creating a myproject.ear.dodeploy file inside the directory where my ear resides.  I then start up as7, which attempts to deploy my project.  I get these errors in the jboss logs

            16:37:28,473 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-14) MSC00001: Failed to start service jboss.deployment.unit."myproject.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."myproject.ear".INSTALL: Failed to process phase INSTALL of deployment "myproject.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: java.lang.RuntimeException: Error getting reflective information for class com.mycompany.myproject.common.jms.JMSListenerServlet
                    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
                    at org.jboss.as.ee.component.EEModuleClassDescription$DefaultConfigurator.configure(EEModuleClassDescription.java:144)
                    at org.jboss.as.ee.component.EEClassConfigurationProcessor.processClasses(EEClassConfigurationProcessor.java:133)
                    at org.jboss.as.ee.component.EEClassConfigurationProcessor.deploy(EEClassConfigurationProcessor.java:76)
                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)
                    ... 5 more
            Caused by: java.lang.NoClassDefFoundError: com/mycompany/myproject/common/businessobjects/Expert
                    at java.lang.Class.getDeclameMethods0(Native Method) [:1.6.0_26]
                    at java.lang.Class.privateGetDeclameMethods(Class.java:2427) [:1.6.0_26]
                    at java.lang.Class.getDeclameMethods(Class.java:1791) [:1.6.0_26]
                    at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:65)
                    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
                    ... 9 more
            Caused by: java.lang.ClassNotFoundException: com.mycompany.myproject.common.businessobjects.Expert from [Module "deployment.myproject.ear.myproject.war: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)
                    ... 14 more
            
            
            16:37:28,682 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "myproject.ear" was rolled back with failure message {"Failed services" => {"jboss.deployment.unit.\"myproject.ear\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myproject.ear\".INSTALL: Failed to process phase INSTALL of deployment \"myproject.ear\""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.myproject.myproject.myproject.ValidatorFactory missing [ jboss.naming.context.java.module.myproject.myproject ]","jboss.naming.context.java.comp.myproject.myproject.myproject.Validator missing [ jboss.naming.context.java.module.myproject.myproject ]"]}
            16:37:28,706 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) Stopped deployment myproject.war in 24ms
            16:37:28,707 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment myproject.ear in 25ms
            16:37:28,709 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Failed services" => {"jboss.deployment.unit.\"myproject.ear\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myproject.ear\".INSTALL: Failed to process phase INSTALL of deployment \"myproject.ear\""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.myproject.myproject.myproject.ValidatorFactory missing [ jboss.naming.context.java.module.myproject.myproject ]","jboss.naming.context.java.comp.myproject.myproject.myproject.Validator missing [ jboss.naming.context.java.module.myproject.myproject ]"]}}}
            

             

             

            The AS7 documentation says the way to resolve NoClassDefFoundError is to find the module name containing the missing class and add it as a dependency in <location of ear>/meta-inf/MANIFEST.MF - but in this case, the class that is missing is a business object class that was created by me - that gets added to my build directory when my project is built, then gets packaged as part of the *har in my *ear.  So I add a MANIFEST.MF

             

            Manifest-Version: 1.0
            Class-Path: /path/to/myproject.ear/myproject.har
            

             

             

            I was uncertain of this approach, but it seemed to be what the documentation was suggesting to do.

             

            When I attempt to deploy my application again I get the error

            17:09:27,472 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"myproject.ear\".CONFIGURE_MODULE missing [ jboss.module.information.service.\"deployment.external./path/to/myproject.ear/myproject.har\".main ]"]}}}
            

            I put an absolute path to the *har file containing the missing class - as I wasn't sure from which directory the deploy would be looking for dependencies, so I thought an absolute path would work.

             

            Any advice on how to get past this error?  Thank you again!

            • 3. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
              sgilda Newbie

              I am sorry, but the information in the Migration Guide was misleading when it comes to debugging ClassNotFoundExceptions for business classes located within the application. I have modified the document to include this type of error. Check out https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7. It explains in more detail how to package WARs and EARs in AS7 to avoid class loading errors.

              • 4. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
                Red Militante Newbie

                The application I'm attempting to migrate from AS5 to AS7 is structured much like the 'getting started' example for AS4 described here http://docs.jboss.org/jbossas/getting_started/v4/html/hibernate.html.  This application packages our hibernate objects as a HAR, we access them from a web application in a WAR file - and the entire application is bundled in an EAR. 

                 

                myapp.ear

                |

                |---myapp.har

                |

                |---myapp.war

                 

                The EAR Class Loading section of https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 states that  the ear-subdeployments-isolated setting in the ee subsystem configuration:

                 

                        </subsystem>
                        <subsystem xmlns="urn:jboss:domain:ee:1.0" >
                            <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
                        </subsystem>
                        <subsystem xmlns="urn:jboss:domain:ejb3:1.0"/>
                        <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">
                
                

                 

                set to 'false' would allow classes in my WAR to access classes in my HAR and vice-versa.  I'm running in standalone mode and my standalone.xml lacked an ear-subdeployments-isolated element in the ee subsystems config.  I added it, restarted my server, but I'm still receiving the NoClassDefFound error I pasted above, indicating that either this setting did not take effect or I'm misinterpreting the cause of the error message.

                 

                My application is deployed with an external deployment-scanner, I'm not sure if that could be part of my problem, I thought I should mention it.

                 

                I'm looking into restructuring my EAR so that all classes are visible to all subdeployments - I just thought the ear-subdeployments-isolated setting could fix this problem quickly.

                • 5. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
                  Red Militante Newbie

                  I tried adding an <EAR directory>/meta-inf/MANIFEST.MF file

                   

                  Manifest-Version: 1.0
                  Class-Path: /path/to/myapp.ear/myapp.har
                  Dependencies: com.mycompany
                  

                   

                  which produces a different error

                   

                  11:23:00,896 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "myapp.ear" was rolled back with failure message {"Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"myapp.ear\".CONFIGURE_MODULE missing [ jboss.module.information.service.\"deployment.external./path/to/myapp.ear/myapp.har\".main ]"]}
                  11:23:00,896 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) Service status report
                     New missing/unsatisfied dependencies:
                        service jboss.module.information.service."deployment.external./path/to/myapp.ear/myapp.har".main (missing)
                  
                  
                  11:23:00,897 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"myapp.ear\".CONFIGURE_MODULE missing [ jboss.module.information.service.\"deployment.external./path/to/myapp.ear/myapp.har\".main ]"]}}}
                  

                   

                  it looks like it's not able to find my HAR - this may be related to the fact that I'm using an external deployment-scanner to deploy my app.  I'm not even sure if adding a MANIFEST.MF is necessary, or if adding ear-subdeployments-isolated should make all subdeployments visible to one another without any additional configuration.

                   

                  I'm still looking into restructuring my app, just thought I'd try this first.

                  • 6. Re: Migrating ant + JBoss AS 5 project to JBoss AS 7
                    Red Militante Newbie

                    I discovered that JBoss AS7 does not support HAR Hibernate archive format.  This is why my subdeployments weren't able to see each other's classes.