9 Replies Latest reply on Jul 1, 2011 2:14 PM by aslak

    Migration to JBoss 7

    juergen.zimmermann

      I tried to migrate from Eclipse 3.6.2 / JBossTools 3.2.0 / JBossAS 6 to Eclipse 3.7.RC3 / JBossTools 3.3.0.M2 snapshot / JBossAS 7.0.alpha4 snapshot. So far everything compiles fine inside Eclipse.

       

      Now I tried the Arquillian tests using the *UN*changed pom.xml, and as expected: "Failed to connect to server". Which changes for the pom.xml are required to make the Arquillian tests connectable and deployable at JBossAS 7? Any hint is appreciated.

        • 1. Re: Migration to JBoss 7
          aslak

          There is no official Arquillian AS7 support at the moment. But it's coming with AS7 CR1 that is due in a week or so.

          • 2. Re: Migration to JBoss 7
            tomjenkinson

            Hi,

             

            Now that AS7 CR1 is out, I was wondering if there was any update to this? I too am trying to get a jbossas-embedded-7 container ran by Arquillian.

             

            Thanks,
            Tom

            • 3. Re: Migration to JBoss 7
              aslak

              Look at these:

               

              https://gist.github.com/1053571

              https://github.com/jbossas/quickstart/tree/master/quickstarts/kitchensink

               

              No AS7 Embedded yet, but Remote and Managed are supported.

              • 4. Re: Migration to JBoss 7
                tomjenkinson

                Hi Aslak,


                Those examples really helped me out! Thanks so much!

                 

                Now, I do have a small issue but I would say I dont know where the bug arises:

                1. my code

                2. arquillian

                3. AS7

                 

                I have a Servlet which looks like the following:

                 

                @WebServlet(displayName = "hello", urlPatterns = "/hello")
                public class SimpleServlet extends HttpServlet {

                @EJB(lookup = "java:module/SimpleEJBImpl")
                private SimpleEJB simpleEJB;

                <SNIP/>

                public String createCustomer(String name) {

                <SNIP/>

                toWrite.append("<p>" + simpleEJB.createCustomer(name) + "</p>");

                <SNIP/>

                }

                }

                 

                When I access it as a servlet in the container from a browser, the simpleEJB is initialized correctly by the @EJB annotation.

                 

                When I access it from my test it (simpleEJB) is null and I get a null pointer exception from the createCustomer call:


                @Test
                public void checkThatDoubleCallIncreasesListSize() throws NamingException {
                SimpleServlet simpleServlet = new SimpleServlet();
                simpleServlet.createCustomer("tom1");
                }

                 

                The reason I have arquillian in the frame for potentially having the bug is because when I use AS6 embedded configuration for Arquillian this test passes just fine, its when I have moved to AS7 with arq that the problem has occurred.

                 

                The quickstart I have developed is rather small and is in svn if you don't have enough info from the above to hazard a guess you are welcome to take a look:

                https://svn.jboss.org/repos/labs/labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration (revision 37198)

                 

                Like I mentioned above, it could well be my code as I do create the new SimpleServlet directly, but I did this before and the @EJB annotation still fired and ensured the simpleEJB was initialized...

                 

                Tom

                • 5. Re: Migration to JBoss 7
                  aslak

                  I have no idea how that would pass on AS6 or any where else for that matter. Servlet is a managed object and can't be created with new like that (if you expect the injections etc to work anyway..)

                   

                  To test servlets you have to invoke the servlet container they are deployed in via their exposed procotol(http). You can define your deployment as @Deployment.testable=false and just have it deploy as a simple War, then invoke it using HTML Unit or URL.openStream

                   

                  (There is a @ArquillianResource(SimpleServlet.class) URL url; injection option, but it's currently not working in AS7 CR1)

                  • 6. Re: Migration to JBoss 7
                    tomjenkinson

                    Yeah, I thought the same too to be honest hence why I included option 1

                     

                    I am pretty sure it worked before, but to be honest I wanted it working on AS7 and as you are telling me it wont work there the way I have done it I am happy with that.

                     

                    The only thing I am thinking now is maybe I had @EJB in my arquillian test class? Would that have maybe work? I will give it a quick check.

                    • 7. Re: Migration to JBoss 7
                      tomjenkinson

                      Yeah, it must have been that. I changed my test class to perform the same code as the servlet and have an @EJB annotation in my test class and that compiles and runs OK. Sorry for the invalid report there:

                       

                      @RunWith(Arquillian.class)
                      public class TestBusinessLogic {
                      @Deployment
                      public static WebArchive createDeployment() {
                      return ShrinkWrap
                                     .<SNIP/>

                      }

                       


                      @EJB(lookup = "java:module/SimpleEJBImpl")
                      private SimpleEJB simpleEJB;

                      @Test
                      public void checkThatDoubleCallIncreasesListSize() throws NamingException {
                           <SNIP/>

                      simpleEJB.createCustomer("tom");

                      • 8. Re: Migration to JBoss 7
                        tomjenkinson

                        I suppose the only thing left to know is what kind of estimate do you have for delivering AS7 embedded?

                         

                        By the way Arquillian is ace

                        • 9. Re: Migration to JBoss 7
                          aslak

                          Yea, you can inject the EJB in the TestCase and set it on the Servlet. At this point the Servlet is just a class, not a Servlet..  but works.

                           

                           

                          Thank you!

                           

                           

                          -aslak-