4 Replies Latest reply on Nov 15, 2011 11:33 AM by Thibaud VIBES

    EJB - Injection did not work with JavaArchive

    Thomas Wiesner Newbie



      my environment is jboss as 7.0.2 and arqullian 1.0.0.CR1.


      I've written a little test with some jpa entities and a session bean as a crud service. The test failed because the injected crud bean was null. I figured out, that the test is running if i create WebArchive.



      import java.util.HashSet;
      import java.util.Set;
      import javax.ejb.EJB;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.Archive;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.asset.EmptyAsset;
      import org.jboss.shrinkwrap.api.spec.JavaArchive;
      import org.jboss.shrinkwrap.api.spec.WebArchive;
      import org.junit.Assert;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      public class PersistAccountTest {
          GenericCRUDControl<LocationEntity> locationCRUDControl;
          GenericCRUDControl<PersonEntity> personCRUDControl;
          public static Archive<?> create(){
              return ShrinkWrap.create(JavaArchive.class, "server.ja").addClasses(PersonEntity.class,RoleEntity.class,RightEntity.class,LocationEntity.class,GenericCRUDControl.class).addAsManifestResource("persistence.xml", "persistence.xml");
          public void testCreatingSimpleAccount(){
              RoleEntity roleEntity  = new RoleEntity();
              PersonEntity personEntity = new PersonEntity();
              Set<RoleEntity> roles = new HashSet<RoleEntity>();
              LocationEntity locationEntity = new LocationEntity();
              Assert.assertNotNull("The location crud control must not be null", locationCRUDControl);
              Assert.assertNotNull("The person crud control must not be null", personCRUDControl);


      I've run the test in managed container and aso in remote container. The remote container was started with the standalone configuration and also with the standalone-preview configuration.


      Has anybody a hint, how to get running the test in a java archive without failures ?


      Kind regards, Thomas