5 Replies Latest reply on Aug 1, 2011 9:55 AM by Nick de Graeve

    Exceptions when running multiple tests, none when ran individually

    Nick de Graeve Newbie

      I have a bunch of tests that use Arquillian 1.0.0.Alpha5 with Glassfish Embedded 3.1. If my tests are run individually via Maven3 or Eclipse they all pass. When I run multiple tests together, eg. in a TestSuite exceptions are thrown.

       

      Truncated stacktrace:

       

      WARNING: A system exception occurred during an invocation on EJB XSSServiceBean method public void com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean.checkFiles(java.io.File,java.io.File[]) throws com.jnj.gtsc.services.filebrowser.model.exception.XSSException
      javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
          at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:454)
      [...]    
      Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
          at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:726)
      [...]
      Caused by: javax.ejb.CreateException: Could not create stateless EJB
          at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:534)
      [...]
      Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean/mailService,Remote 3.x interface =com.jnj.gtsc.framework6.mail.api.MailService resolved to intra-app EJB MockMailServiceBean in module test,ejb-link=MockMailServiceBean,lookup=,mappedName=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,jndi-name=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,refType=Session into class com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean
          at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:698)[...]
      [...]
      Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean/mailService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean/mailService,Remote 3.x interface =com.jnj.gtsc.framework6.mail.api.MailService resolved to intra-app EJB MockMailServiceBean in module test,ejb-link=MockMailServiceBean,lookup=,mappedName=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,jndi-name=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean#com.jnj.gtsc.framework6.mail.api.MailService' [Root exception is javax.naming.NamingException: Lookup failed for 'com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean#com.jnj.gtsc.framework6.mail.api.MailService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jnj.gtsc.framework6.mail.api.MailService [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]]]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
      [...]
      Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.jnj.gtsc.services.filebrowser.services.util.XSSServiceBean/mailService,Remote 3.x interface =com.jnj.gtsc.framework6.mail.api.MailService resolved to intra-app EJB MockMailServiceBean in module test,ejb-link=MockMailServiceBean,lookup=,mappedName=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,jndi-name=com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean#com.jnj.gtsc.framework6.mail.api.MailService' [Root exception is javax.naming.NamingException: Lookup failed for 'com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean#com.jnj.gtsc.framework6.mail.api.MailService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jnj.gtsc.framework6.mail.api.MailService [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]]
          at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:178)
      [...]
      Caused by: javax.naming.NamingException: Lookup failed for 'com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean#com.jnj.gtsc.framework6.mail.api.MailService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jnj.gtsc.framework6.mail.api.MailService [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
      [...]
          Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.jnj.gtsc.framework6.mail.api.MailService [Root exception is java.lang.IllegalArgumentException: argument type mismatch]
          at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:434)
      [...]
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      [...]
      

      The full stacktrace can be found in attached error.txt. Also attached is the log of a succesful run (output.txt).

       

      The problem seems to be with the mail service which is a remote EJB3. It is injected in the XSSServiceBean EJB as follows:

       

      @EJB(mappedName = "com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean")
      private MailService mailService;
      

       

      The mail service is mocked like this:

       

      @Stateless(mappedName = "com/jnj/gtsc/framework6/mail/services/ext/FireAndForgetMailServiceBean")
      @Remote(MailService.class)
      public class MockMailServiceBean extends BaseService implements MailService {
      
          /** The logger. */
          private final Logger logger = LoggerFactory.getLogger(MockMailServiceBean.class);
      
          /**
           * {@inheritDoc}
           */
          @Override
          public void sendMail(final Mail mail) {
              this.logger.info("Mail sent - from: {}; to: {}; subject: {}; content: {}",
                      new Object[] { mail.getSender(), mail.getReceivers(), mail.getSubject(), mail.getContent() });
          }
      
      }
      

       

      In my tests MockMailServiceBean is added in test archive create method:

       

      @Deployment
      public static JavaArchive createTestArchive() {
          return ShrinkWrap.create(JavaArchive.class, "test.jar").addClasses(..., MailService.class, MockMailServiceBean.class);
      }
      

       

      The weirdest thing is that the exceptions occur in test methods that don't trigger the mail service.

       

      Any idea how to get it working?