<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
#email-body { min-width: 30em !important; }
#email-page { padding: 8px !important; }
#email-banner { padding: 8px 8px 0 8px !important; }
#email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
#email-fields { padding: 0 8px 8px 8px !important; }
#email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
<tr valign="top">
<td id="email-page" style="padding:16px !important;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
<tr valign="top">
<td bgcolor="#3b4d64" style="background-color:#3b4d64;color:#ffffff;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="https://issues.jboss.org/s/en_US-x52yjt-1988229788/6109/58/_/jira-logo-scaled.png" alt="" style="vertical-align:top;" /></td>
</tr><tr valign="top">
<td id="email-banner" style="padding:32px 32px 0 32px;">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
<img id="email-avatar" src="https://community.jboss.org/people/nuno.godinhomatos/avatar/16.png" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
<div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
<a class="user-hover" rel="nuno.godinhomatos" id="email_nuno.godinhomatos" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=nuno.godinhomatos" style="color:#3b73af;">Nuno Godinho de Matos</a>
updated <img src="https://issues.jboss.org/images/icons/issuetypes/bug.png" height="16" width="16" border="0" align="absmiddle" alt="Bug"> <a style='color:#3b73af;text-decoration:none;' href='https://issues.jboss.org/browse/WELD-1619'>WELD-1619</a>
</div>
<div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
<a style='color:#3b73af;text-decoration:none;' href='https://issues.jboss.org/browse/WELD-1619'><strong>Java SE (weld-se) With surefire threaded perl class fails after the first thread call to weld.shutdown</strong></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td id="email-fields" style="padding:0 32px 32px 32px;">
<table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
<tr valign="top">
<td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Change By:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a class="user-hover" rel="nuno.godinhomatos" id="email_nuno.godinhomatos" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=nuno.godinhomatos" style="color:#3b73af;">Nuno Godinho de Matos</a>
(13/Mar/14 9:55 AM)
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Description:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<span class="diffaddedchars" style="background-color:#ddfade;"><br>Project that tries to illustrate error:<br>https://drive.google.com/file/d/0B_dEiNBGUsxqaG5tdTVuT2RqT00/edit?usp=sharing<br><br>Summary:<br>- surefire threaded option<br>- test thread calls weld.shutdown()<br>- all other threads still working will have random problems using their own non shared weld containers<br><br><br>Context:<br></span>
<span class="diffcontext">I am creating some UI Tests based on selenium. UI testing is overall a slow process with the opening of the browser and all the orchestration, so multi-threading the tests is a must.<br><br></span>
<span class="diffremovedchars" style="background-color:#ffe7e7;text-decoration:line-through;">Intially</span>
<span class="diffaddedchars" style="background-color:#ddfade;">Initially</span>
<span class="diffcontext"> I was using Google Guice for IoC, but I have switched to weld. <br>The UI tests used to be successful in Guice using surefire <threadCound></threadCoun> configuration property.<br>When I switched to Weld, this stopped being the case.<br>The tests consistently break with several different exceptions at several different points of the life cycle of the test.<br><br>Summary of test policy:<br>Each test class contains a Weld and WeldContainer object that is unique to itself and not shared in any way. There are no race conditions on these objects, since each test class contains a single test, and each test is given a single thread by the surefire plugin.<br><br>What seems to be happening here is that the <br>weld.shutdown();<br><br>call seems to have a cross cutting power across all the running threads.<br>That is, even though each test class has its own weld object that it uses to create a weld container.<br>As soon as the first test thread concludes the test and reaches the tearDown() moment, and invokes weld.shutdown(), from this point onward the ramaining tests seem to start dieing with arbitrary exceptions.<br><br>For example, I have head tests where the container.initilize() appears to be very successful, but after that trying to get a bean from the container will result in a:<br>WELD-001308 Unable to resolve any beans for Types: <br><br>Other tests that seem to have passe the @Test() point ad have reached teh tearDown() phase, these will failing trying to close the weld instance variable with arbtirary erros, such as:<br><br>java.lang.NullPointerException<br>        at org.jboss.weld.environment.se.ShutdownManager.shutdown(ShutdownManager.java:42)<br>        at org.jboss.weld.environment.se.ShutdownManager$Proxy$_$$_WeldClientProxy.shutdown(ShutdownManager$Proxy$_$$_WeldClientProxy.java)<br>        at org.jboss.weld.environment.se.Weld.shutdown(Weld.java:218)<br><br><br>Or such as:<br>java.lang.IllegalStateException: Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly?<br> at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)<br> at org.jboss.weld.Container.instance(Container.java:67)<br> at org.jboss.weld.bean.AbstractBean.initialize(AbstractBean.java:134)<br> at org.jboss.weld.bean.AbstractClassBean.initialize(AbstractClassBean.java:205)<br> at org.jboss.weld.bean.ManagedBean.initialize(ManagedBean.java:327)<br> at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:116)<br> at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:217)<br> at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:365)<br> at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:70)<br> at org.jboss.weld.environment.se.Weld.initialize(Weld.java:137)<br> at WeldBugReportSurefireTest.setUp(WeldBugReportSurefireTest.java:65)<br><br><br><br>It is very hard to decide on an exception to report, so many take place an arbitrarly. <br><br>To make the tests pass I have have to use surefire configured for forking, witout re-use of forks. This solves my multi-threading issue.<br>But I am concerned with the erros I am getting, because I can envision scenarios where an application really needs to created different container objects that it shutsdown when appropriate without disturbing the other opened containers, as you can do with guice.<br><br><br>I have tried to compile a small project where this error can be reproduced.<br>I cannot use the real project for privacy reasons, so the exceptions that my sample project yields do not correspond exactly to the ones I get in my project... <br><br>In this project, tests can be triggered through the comand line with either:<br>mvn test<br>mvn -P parallel test<br>the mvn test runs one test at a time, the normal way, and should be successful.<br>the mvn -P parallel test <br>should break most of the time with arbitrary exceptions on arbitrary test classes<br><br>And if the managed bean DummyManagedBean.java has a flag property that can be used to get the tests to pass when in parallel.<br>what this flag will do is make the thread postpone the test for long enough, for all other threads to complete their business logic, thus avoiding a weld shutdown to occur before the tests complete.<br><br></span>
<span class="diffaddedchars" style="background-color:#ddfade;"><br></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><!-- End #email-page -->
</tr>
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
This message is automatically generated by JIRA.<br />
If you think it was sent incorrectly, please contact your JIRA administrators<br />
For more information on JIRA, see: <a style='color:#3b73af;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
</td>
</tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->