1 2 Previous Next 25 Replies Latest reply on Jun 11, 2010 1:10 PM by Aslak Knutsen

    Arquillian and embedded Glassfish builds

    Laird Nelson Apprentice

      Hi there; first of all, thanks for a great product.  This reminds me of the old Cactus project back in the day, but done much, much better.

       

      I noticed that the version of embedded Glassfish you guys selected was build 3.0.1-b02.  Now, that build is actually very interesting, because in my own travels, I've found it to be the ONLY build that Glassfish has produced that actually works out of dozens of possibilities.  First question: did you deliberately select 3.0.1-b02 for the same reason?

       

      Recently, the folks over on the Glassfish forums pushed me to try out the 3.1-SNAPSHOT builds, after I complained about the ancient versions of various libraries in the 3.0.1-b02 build.

       

      When I run Arquillian 1.0.0.Alpha2 using the 3.1-SNAPSHOT build, I get regular Connection refused errors when the Arquillian JUnit runner attempts to launch my test.  If I bump the Glassfish version back to 3.0.1-b02 everything works fine.  (I'm not sure who's trying to connect to what.)

       

      I was wondering: is this a known problem?  I've attached a dumb Maven project to illustrate what I mean.  I suspect that the issue is with Glassfish, but perhaps it's with the way that Arquillian is calling Glassfish.

       

      Anyhow, thanks for any help and pointers along the way.  The equivalent Glassfish forum post is here: http://forums.java.net/jive/thread.jspa?messageID=473551

       

      Best,

      Laird

        • 1. Re: Arquillian and embedded Glassfish builds
          Aslak Knutsen Master

          Laird Nelson wrote:

           

          Hi there; first of all, thanks for a great product.  This reminds me of the old Cactus project back in the day, but done much, much better.

          Thank you!

           

          I noticed that the version of embedded Glassfish you guys selected was build 3.0.1-b02.  Now, that build is actually very interesting, because in my own travels, I've found it to be the ONLY build that Glassfish has produced that actually works out of dozens of possibilities.  First question: did you deliberately select 3.0.1-b02 for the same reason?

           

          Recently, the folks over on the Glassfish forums pushed me to try out the 3.1-SNAPSHOT builds, after I complained about the ancient versions of various libraries in the 3.0.1-b02 build.

           

          When I run Arquillian 1.0.0.Alpha2 using the 3.1-SNAPSHOT build, I get regular Connection refused errors when the Arquillian JUnit runner attempts to launch my test.  If I bump the Glassfish version back to 3.0.1-b02 everything works fine.  (I'm not sure who's trying to connect to what.)

           

          I was wondering: is this a known problem?  I've attached a dumb Maven project to illustrate what I mean.  I suspect that the issue is with Glassfish, but perhaps it's with the way that Arquillian is calling Glassfish.

           

          The GlassFish v. used is really just the latest v. that was available at the time the integration was written..

          But it has bugs as well, CDI BeanArchives in EAR lib is not picked up correctly;  https://glassfish.dev.java.net/issues/show_bug.cgi?id=11497

          This is fixed in 3.1-SNAPSHOT, but Arquillian changed the way it packages the Test Cases so the whole issue is avoided.

           

          I haven't tried 3.1-SNAPSHOT much, but I'll give your tests a spin to see if I can figure out what is wrong.

           

          -aslak-

          1 of 1 people found this helpful
          • 2. Re: Arquillian and embedded Glassfish builds
            Laird Nelson Apprentice

            Thanks, Aslak.  I've made some progress in the meantime.  If you use Glassfish build 3.1-b04 (yesterday's promoted build? today's? not sure), then the Connection refused error goes away.

             

            In my "real" project (from which I've extracted the test case) I am now encountering a problem that EJB injection doesn't appear to work properly with this build.  I'm going to keep digging here; if you get past the Connection refused issue, you might see if adding an @EJB bean to my (dumb) test case succeeds or fails.

             

            Thanks again for this most useful project.

             

            Best,

            Laird

            • 3. Re: Arquillian and embedded Glassfish builds
              Laird Nelson Apprentice

              Another interesting problem.

               

              In my real project, I'm creating an EnterpriseArchive like this:

               

              final EnterpriseArchive ear = ShrinkWrap.create("test.ear", EnterpriseArchive.class);

               

              final JavaArchive myEjbJar = ShrinkWrap.create("my-ejb-jar.jar", JavaArchive.class);

              // add stuff to myEjbJar

              ear.addModule(myEjbJar);

               

              return ear;

               

              My embedded Glassfish (build 3.1-b04) logs this:

               

              INFO: Portable JNDI names for EJB FooBean : [java:global/test/my-ejb-jar/FooBean, java:global/test/my-ejb-jar/FooBean!com.foobar.Foo]

               

              Then Arquillian pukes, and it tells me that EJB injection couldn't be accomplished.  It says it tried the following names.  Note the mismatch in the following (snipped) tail end of the stack trace:

               

              Caused by: java.lang.RuntimeException: Could not inject members
                  at org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher.injectClass(EJBInjectionEnricher.java:125)
                  at org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher.enrich(EJBInjectionEnricher.java:50)
                  at org.jboss.arquillian.impl.handler.TestCaseEnricher.callback(TestCaseEnricher.java:42)
                  at org.jboss.arquillian.impl.handler.TestCaseEnricher.callback(TestCaseEnricher.java:32)
                  at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                  ... 50 more
              Caused by: javax.naming.NamingException: No EJB found in JNDI, tried the following names: java:global/test.ear/test/FooBean, java:global/test.ear/test/Foo, java:global/test/Foo, java:global/test/FooBean, java:global/test/Foo/no-interface, test/FooBean/local, test/FooBean/remote, test/Foo/no-interface, FooBean/local, FooBean/remote, Foo/no-interface,
                  at org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher.lookupEJB(EJBInjectionEnricher.java:159)
                  at org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher.injectClass(EJBInjectionEnricher.java:100)
                  ... 54 more

               

              In particular, note the absence of my-ejb-jar anywhere in the names that are tried.

               

              Best,

              Laird

               

              (Edited the message to remove wiki markup; apparently didn't chant the right stuff; don't have the patience to figure it out right now)

              • 4. Re: Arquillian and embedded Glassfish builds
                Aslak Knutsen Master

                Laird Nelson wrote:

                 

                Another interesting problem.

                 

                In my real project, I'm creating an EnterpriseArchive like this:

                 

                final EnterpriseArchive ear = ShrinkWrap.create("test.ear", EnterpriseArchive.class);

                 

                final JavaArchive myEjbJar = ShrinkWrap.create("my-ejb-jar.jar", JavaArchive.class);

                // add stuff to myEjbJar

                ear.addModule(myEjbJar);

                 

                return ear;

                 

                 

                Yea, a known limitation with the EJB injection atm. See  http://community.jboss.org/message/546797

                 

                Name you myEjbJar "test.jar" and it should work..

                • 5. Re: Arquillian and embedded Glassfish builds
                  Laird Nelson Apprentice

                  Actually, that doesn't, because it looks like Glassfish...this is just weird.  So I did what you suggested (and saw the problem in the EJB enricher source code, so I know what's going on, and your suggestion makes perfect sense), but Glassfish insists on (now, oddly) appending "ejb" to the test.jar name.

                   

                  That is, the portable JNDI name is now:

                   

                  java:global/test/testejb/FooBean

                   

                  Note the bizarre "testejb" name component.  It's like...it's like Glassfish doesn't want there to be two "test" tokens in the path or something?

                   

                  I suppose this means that for the moment I'm hosed.  :-)  My next attempt will be to rename the EnterpriseArchive to something else and see if the "ejb" suffix is dropped.

                   

                  Best,

                  Laird

                  • 6. Re: Arquillian and embedded Glassfish builds
                    Laird Nelson Apprentice

                    Aaaaand that didn't work either.  Sooo.  Do you know if the "ejb" suffixing is happening in Arquillian land or Glassfish land?

                     

                    Again, to be clear, if I add a JavaArchive named "test.jar"--and only "test.jar"--as a module to an EnterpriseArchive, and if I then deploy the EnterpriseArchive, Glassfish reports that effectively the test.jar module shows up in portable JNDI names as "testejb".  I don't know where the "ejb" portion of that name component is coming from, since I didn't specify it.

                     

                    Best,

                    Laird

                    • 7. Re: Arquillian and embedded Glassfish builds
                      Aslak Knutsen Master

                      hehe..

                       

                      for EAR JNDI binding it's suppose to be:

                       

                      java:global/[application-name]/[module-name]/BeanInstanceSimpleClassName

                       

                       

                      You don't have a applicaiton.xml or ejb-jar.xml that change the default module name ?

                      (strange tho that it didn't in the previous attempts.. hmm)

                       

                      -aslak-

                      • 8. Re: Arquillian and embedded Glassfish builds
                        Laird Nelson Apprentice

                        Nope; just straight assembling as described.  Now, perhaps I'm adding the EJB jar in some lousy way: I'm creating a regular old JavaArchive (I didn't see anything like an EjbArchive) and calling myEar.addModule(myJavaArchive).

                         

                        L

                        • 9. Re: Arquillian and embedded Glassfish builds
                          Dan Allen Master

                          You can see what Arquillian ultimately deploys by adding this arquillian.xml to the test classpath (src/test/resources):

                           

                          <arquillian xmlns="http://jboss.com/arquillian"
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                           
                             <engine>
                                <deploymentExportPath>/tmp/</deploymentExportPath>
                             </engine>
                           
                          </arquillian>
                          
                          • 10. Re: Arquillian and embedded Glassfish builds
                            Laird Nelson Apprentice

                            (Also, can you suggest how to build Arquillian from trunk?  I have the JBoss release and snapshot repositories in my settings.xml file, but I get the following error when I attempt to do mvn clean install from the root:

                             

                            mvn clean install
                            [INFO] Scanning for projects...
                            Downloading: http://repo1.maven.org/maven2/org/jboss/ejb3/bom/bom-as6/0.1.2/bom-as6-0.1.2.pom
                            [INFO] Unable to find resource 'org.jboss.ejb3.bom:bom-as6:pom:0.1.2' in repository central (http://repo1.maven.org/maven2)
                            [INFO] ------------------------------------------------------------------------
                            [ERROR] FATAL ERROR
                            [INFO] ------------------------------------------------------------------------
                            [INFO] Error building POM (may not be this project's POM).

                             


                            Project ID: org.jboss.ejb3.bom:bom-as6

                             

                            Reason: POM 'org.jboss.ejb3.bom:bom-as6' not found in repository: Unable to download the artifact from any repository

                             

                              org.jboss.ejb3.bom:bom-as6:pom:0.1.2

                             

                            from the specified remote repositories:
                              central (http://repo1.maven.org/maven2)

                             

                            for project org.jboss.ejb3.bom:bom-as6

                             

                            For whatever reason it's not even consulting the JBoss repositories.  I also tried taking the respositories section from my settings.xml and adding them straight to the root pom in a <repositories> section, and they don't seem to be consulted.

                             

                            Please feel free to point me to the forum message or topic that tells idiots like me how to do this.  :-)

                             

                            Best,

                            Laird

                            • 11. Re: Arquillian and embedded Glassfish builds
                              Aslak Knutsen Master

                              Doh!

                               

                              Since we're not sharing information between the Containers and Arquillian about the deployment there are some assumptions around about naming.

                              I see now one of them.. Arquillian needs a war named "test.war" in the deployment to execute the test inside the container. It's trying to communicate with /test/ArquillianServletRunner. If there is no WebArchive in the defined @Deployment, it will create one for you, e.g. JavaArchive or EnterpriseArchive.

                               

                              So in your case, A WebArchive called test.war is added to your EnterpriseArchive in the background. GlassFish does not like two modules with the same name, test.jar(ejb) and test.war(test runner), so it's appending "ejb" to the ejb module name. (The order of things might have changed in the later v. of GlassFish so it's the test.war that gets it's name changed, which might be why it fails. pure speculation at this point but.. )

                               

                              We're also hardcoded to look for EJBs in test module name space so we're screwed.

                               

                              If you want, you might be able to work around it:

                              if you add a 'empty' WebArchive not named test.war in your EnterpriseArchive @Deployment . In the WebArchive add a web.xml file that sets the ContextRoot to be "/test". Not sure if ContextRoot covers as ModuleName, so you might get lucky.

                               

                              There are a couple of things we're working on that should solve these kinda issues in future releases:

                              http://community.jboss.org/message/543269

                              https://jira.jboss.org/browse/ARQ-77

                              https://jira.jboss.org/browse/ARQ-125

                              https://jira.jboss.org/browse/ARQ-171

                              https://jira.jboss.org/browse/ARQ-167

                               

                               

                               

                              -aslak-

                              • 12. Re: Arquillian and embedded Glassfish builds
                                Aslak Knutsen Master

                                Laird Nelson wrote:

                                 

                                (Also, can you suggest how to build Arquillian from trunk?  I have the JBoss release and snapshot repositories in my settings.xml file, but I get the following error when I attempt to do mvn clean install from the root:

                                 

                                mvn clean install
                                [INFO] Scanning for projects...
                                Downloading: http://repo1.maven.org/maven2/org/jboss/ejb3/bom/bom-as6/0.1.2/bom-as6-0.1.2.pom
                                [INFO] Unable to find resource 'org.jboss.ejb3.bom:bom-as6:pom:0.1.2' in repository central (http://repo1.maven.org/maven2)
                                [INFO] ------------------------------------------------------------------------
                                [ERROR] FATAL ERROR
                                [INFO] ------------------------------------------------------------------------
                                [INFO] Error building POM (may not be this project's POM).

                                 


                                Project ID: org.jboss.ejb3.bom:bom-as6

                                 

                                Reason: POM 'org.jboss.ejb3.bom:bom-as6' not found in repository: Unable to download the artifact from any repository

                                 

                                  org.jboss.ejb3.bom:bom-as6:pom:0.1.2

                                 

                                from the specified remote repositories:
                                  central (http://repo1.maven.org/maven2)

                                 

                                for project org.jboss.ejb3.bom:bom-as6

                                 

                                For whatever reason it's not even consulting the JBoss repositories.  I also tried taking the respositories section from my settings.xml and adding them straight to the root pom in a <repositories> section, and they don't seem to be consulted.

                                 

                                Please feel free to point me to the forum message or topic that tells idiots like me how to do this.  :-)

                                 

                                Best,

                                Laird

                                This is some strange Maven 2.x issue. It can't handle scope import in sub modules dependencies or something simluar.  http://community.jboss.org/message/542270

                                 

                                Use Maven 3 Beta 1 to build (just to download the artifacts if you want). As long as the artifacts are in the local repo, Maven 2.x can build as well

                                • 13. Re: Arquillian and embedded Glassfish builds
                                  Laird Nelson Apprentice

                                  Thanks.  That should do it on the dumb questions.  I'll look at your suggestion regarding context path and whatnot, but I'm not that hopeful.  :-(  Say, when is Alpha3 coming out?  :-)

                                   

                                  Best,

                                  Laird

                                  • 14. Re: Arquillian and embedded Glassfish builds
                                    Andrew Rubinger Master

                                    Aslak Knutsen wrote:

                                     

                                    This is some strange Maven 2.x issue. It can't handle scope import in sub modules dependencies or something simluar.  http://community.jboss.org/message/542270

                                     

                                    Use Maven 3 Beta 1 to build (just to download the artifacts if you want). As long as the artifacts are in the local repo, Maven 2.x can build as well

                                    Let's account for this in the ARQ build instructions.

                                     

                                    I also hear a rumor that baking the repository into our POMs will for in Maven2, but we're already doing that.

                                     

                                    S,

                                    ALR

                                    1 2 Previous Next