3 Replies Latest reply on Jan 19, 2011 8:28 PM by Michael Schuetz

    Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed

    Michael Schuetz Novice

      Hi to all,

       

      I am hunting strange error:

       

      I would like to execute multiple tests running against JBoss AS5.1 Managed (following does _not_ occur while running against AS5.1 Remote) at once.

       

      Executing single tests does work.

       

      What I do get:

       

      WARN  [org.jboss.seam.integration.jbossas.vfs.VFSScanner] Error handling item 'com.acme/MyServiceItTest.class': java.lang.IllegalStateException: Cannot load com/acme/MyServiceItTest.class from org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@6e69df65 (using getResourceAsStream() returned null)

      2011-01-19

       

       

      That's the testcase from the previously deplpoyed archive.

       

      Is this an Arquillian issue?

       

      As dirty workaround we did provide own EJB for test purpose and configured Binding by hand:

      @LocalBinding(jndiBinding = "test/XATransactionTestServiceBean/local")

       

       

      Just to provide context of test: http://community.jboss.org/thread/161408?tstart=0

       

      Thanks for any help.

       

       

      Cheers

      Michael

        • 1. Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
          Aslak Knutsen Master

          Can you provide the test cases that shows the issue so I can reproduce?

          • 2. Re: Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
            Michael Schuetz Novice

            Sure, Thanks Aslak.

             

            public class XATransactionTest extends AbstractItTest {

             

                private static final String EAR_NAME = "xaTransactionTest";

             

                @Deployment

                public static Archive<?> getDeployment() {

                    return getTestArchive(EAR_NAME, new String[]{"com.acme.common:commons-jsonservice:0.1",

                            "com.acme.common:commons-jms:0.1"},

                            new String[]{"net.sf.json-lib:json-lib:2.3:jdk15"},

                            XATransactionTest.class, MyService.class, MyServiceBean.class,

                            MyDao.class, MyDaoBean.class, My.class,

                            MessageFilterRegistrationSender.class, MessageFilterRegistrationSenderBean.class, MessageFilter.class,

                            RegistrationMessageCreator.class, XATransactionTestService.class, XATransactionTestServiceBean.class);

                }

             

                @EJB

                private XATransactionTestService xaTransactionTestService;

             

                @Test

                public void testHeuristicMixedException() {

                    Exception caughtException = null;

                    try {

                        xaTransactionTestService.accessXAResources();

                    } catch (Exception e) {

                        caughtException = e;

                    }

                    assertNotNull(caughtException);

                    StringWriter writer = new StringWriter();

                    PrintWriter printWriter = new PrintWriter(writer);

                    caughtException.printStackTrace(printWriter);

                    printWriter.close();

                    LOG.info(writer.toString());

                    assertTrue(caughtException.getCause() instanceof HeuristicMixedException);

                }

            }

             

            ###

             

            @Stateless

            @LocalBinding(jndiBinding = "test/XATransactionTestServiceBean/local")

            public class XATransactionTestServiceBean implements XATransactionTestService {

                @EJB

                private MyService myService;

             

                @EJB

                private MessageFilterRegistrationSender messageFilterRegistrationSender;

             

                @Override

                public void accessXAResources() {

                    myService.getAll();

                    messageFilterRegistrationSender.sendRegisteredIDsRequest();

                }

            }

            • 3. Re: Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
              Michael Schuetz Novice

              BTW, "EAR_NAME" will be replaced in components.xml. See method in AbstractItTest:

               

                private static Asset getComponentsXML(final String earName) {

                      return new Asset() {

                          @Override

                          public InputStream openStream() {

                              try {

                                  final InputStream inputStream = AbstractItTest.class.getResourceAsStream("/war/components.xml");

                                  final InputStreamReader streamReader = new InputStreamReader(inputStream, "UTF-8");

                                  final ReplacingReader replacingReader =

                                          new ReplacingReader(streamReader, Collections.singletonMap("earName", earName));

                                  return new ReaderInputStream(replacingReader, "UTF-8");

                              } catch (UnsupportedEncodingException e) {

                                  throw new RuntimeException(e);

                              }

                          }

                      };

                  }

               

               

              The other stuff is basic Arquillian Seam2 glue code.

               

              Cheers