12 Replies Latest reply on Nov 6, 2008 5:11 AM by Kamil Demecki

    Embedded JBoss and Maven

    Samuel Santos Newbie

      I see a lot of examples how to use Embedded JBoss, but all of them add classes manually one by one like the example at http://www.jboss.org/community/docs/DOC-9684.

      Does anyone use maven and have an example about how to deploy directly the target/classes folder?

        • 1. Re: Embedded JBoss and Maven
          Matt Nirgue Newbie

          I got my integration tests running using Embedded JBoss with Maven, thanks to this :
          https://jira.jboss.org/jira/browse/JBSEAM-2371 (especially the project testproject-master-JBSEAM-2371)

          Hopefully this will help you too...

          • 2. Re: Embedded JBoss and Maven
            Samuel Santos Newbie

            Thanks Matt,

            Unfortunately my problem is not related with the classpath problem present in Embedded JBoss Beta3. I use Beta3.SP2 that seems to have this bug fixed.
            No more need to add:


            to the maven-surefire-plugin.

            This is how I start the Embedded JBoss:

            But it seems that is not deploying correctly, at least my EJBs:
            setUp(com.foo.bar.core.business.ConfigServiceTest) Time elapsed: 0.007 sec <<< FAILURE!
            javax.naming.NameNotFoundException: configService not bound
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:542)
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:550)
             at org.jnp.server.NamingServer.getObject(NamingServer.java:556)
             at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:669)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
             at javax.naming.InitialContext.lookup(InitialContext.java:392)
             at com.foo.bar.core.business.ConfigServiceTest.setUp(ConfigServiceTest.java:40)

            I'm I doing something wrong? Do you need me to post more info in order to help me?


            • 3. Re: Embedded JBoss and Maven
              Matt Nirgue Newbie

              I have had a lot of issues trying to make Embedded JBoss work with Maven... and I did get this one! but I can't remember what I've done to solve THIS problem... :/

              can you post your components.xml please?

              • 4. Re: Embedded JBoss and Maven
                Samuel Santos Newbie

                Hello Matt,

                I don't use Seam.

                The problem is probably due to my Embedded JBoss configuration since the application runs on JBoss AS and the tests run successfully with Embeddable EJB 3.0.

                • 5. Re: Embedded JBoss and Maven
                  Matt Nirgue Newbie

                  Ok... don't know why I assumed that you used Seam oO

                  anyway... where/how did you configure your JNDI then?

                  • 6. Re: Embedded JBoss and Maven
                    Samuel Santos Newbie

                    Hey Matt,

                    This is how I configure my initial context:

                    protected static InitialContext getInitialContext() throws NamingException {
                     Hashtable<String, String> props = getInitialContextProperties();
                     return new InitialContext(props);
                    private static Hashtable<String, String> getInitialContextProperties() {
                     Hashtable<String, String> props = new Hashtable<String, String>();
                     props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
                     props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                     props.put(Context.SECURITY_PRINCIPAL, "test");
                     props.put(Context.SECURITY_CREDENTIALS, "test");
                     props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
                     return props;

                    and this is how I get my bean:
                    InitialContext ctx = AdvertisementServiceTest.getInitialContext();
                    service = (AdvertisementService) ctx.lookup("advertisementService");

                    This works fine with Embeddable EJB 3.0.

                    • 7. Re: Embedded JBoss and Maven
                      Matt Nirgue Newbie

                      Here's what I use for the tests that use Embedded JBoss:


                      Try this out and let me know what you get when using this...

                      • 8. Re: Embedded JBoss and Maven
                        Samuel Santos Newbie

                        Thanks Matt,

                        I've tried to use the JBossRemotingContextFactory but I get exactly the same error.

                        I can't understand why my EJBs aren't deployed...

                        • 9. Re: Embedded JBoss and Maven
                          Matt Nirgue Newbie

                          I don't understand why either... :/ I'll try to take a look at this tomorrow... but I'm afraid I won't be very useful cause I really don't know where the problem comes from...

                          • 10. Re: Embedded JBoss and Maven
                            Kamil Demecki Novice

                            "target/classes" depends on runtime. On windows System.getProperty("java.class.path") returns "C:\\XXX\target\\classes" and jboss embedded check "C:\\XXX\target\\classes".contains("target/classes") which is false.

                            I had the same problem, and solved after searching (nothing found) and debugging. Later I found in book Java Persistence in Hibernate Bauer errata which describes this and propose: ("target/classes".replace(File.separator))

                            • 11. Re: Embedded JBoss and Maven
                              Samuel Santos Newbie

                              Thanks Matt and Kamil,

                              The problem was related with the Embedded JBoss not supporting the @LocalBinding annotation.
                              I've managed to get a little further.

                              I've created a new topic for this, maybe you can help me: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4187075#4187075.

                              Thanks again.

                              • 12. Re: Embedded JBoss and Maven
                                Kamil Demecki Novice

                                Right ! I had the same problem.

                                Localization of @LocalBinding had move in JBoss 5 (Jboss Embedded Beta 3 is on JBoss 5) and is diffrent with @LocalBindidng from Jboss 4.

                                I had tried change global strategy to jndi policy in aop*.xml with success but my project is using predicatable jndi names (full class name of bean implementation with suffixes: "/local" or "/remote").