2 Replies Latest reply: May 5, 2012 4:44 AM by hrrbrt99 RSS

    "BeanManager not found" when using WebArchive

    hrrbrt99 Newbie

      What's wrong with the following arquillian test:

       

       

      @RunWith(Arquillian.class)

      public class SelectionMap2Test {

         

        @Deployment

        public static WebArchive  createDeployment() {

          File[] libs = DependencyResolvers.use(MavenDependencyResolver.class).includeDependenciesFromPom("pom.xml").resolveAsFiles();

       

          WebArchive war = ShrinkWrap.create(WebArchive.class)

              .addClasses(SelectionMap.class, Globals.class)

              .addAsLibraries(libs)

                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

       

            war.toString(true);

              return war;

        }

       

          @Inject private SelectionMap sm;

       

      .....

       

      It returns NPE as CDI does not work as beans.xml not found?!

      What am I missing?

       

      Stacktrace & pom.xml attached

        • 1. Re: "BeanManager not found" when using WebArchive
          jaikiran pai Master

          07:21:49,957 INFO  [org.jboss.web] (MSC service thread 1-12) JBAS018210: Registering web context: /9a35bceb-401a-4773-8b8e-3a38d56c9bc2

          07:21:50,036 INFO  [org.jboss.as.server] (management-handler-thread - 67) JBAS018559: Deployed "9a35bceb-401a-4773-8b8e-3a38d56c9bc2.war"

          07:21:50,105 ERROR [org.jboss.as.weld] (pool-4-thread-12) JBAS016000: Failed to setup Weld contexts: javax.naming.NameNotFoundException; remaining name 'java:comp/BeanManager'

              at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:634) [jetty-jndi-8.0.0.RC0.jar:8.0.0.RC0]

              at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:680) [jetty-jndi-8.0.0.RC0.jar:8.0.0.RC0]

              at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:165) [jetty-jndi-8.0.0.RC0.jar:8.0.0.RC0]

              at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0]

              at org.jboss.as.weld.arquillian.WeldContextSetup.setup(WeldContextSetup.java:70) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]

          This looks strange. Why is Jetty naming context being used in JBoss AS7? Do you have any jndi.properties in that application? Also what does the war.toString(true); output show?

          • 2. Re: "BeanManager not found" when using WebArchive
            hrrbrt99 Newbie

            Thanks a lot jaikiran!

             

            the "rewrite-test-harness" package (com.ocpsoft.rewrite) has a dependency on jetty. After excluding jetty in the pom.xml like this, everything works as expected!

             

             

            <dependency>
                <groupId>com.ocpsoft.rewrite</groupId>
                <artifactId>rewrite-test-harness</artifactId>
                <version>${rewrite-version}</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>arquillian-jetty-embedded-7</artifactId>
                        <groupId>org.jboss.arquillian.container</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jetty-webapp</artifactId>
                        <groupId>org.eclipse.jetty</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jetty-plus</artifactId>
                        <groupId>org.eclipse.jetty</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            
            

             

            Thanks a lot!!

             

            Message was edited by: jaikiran pai - Fixed formatting of xml