<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <base href="https://issues.jboss.org" />
<title>Message Title</title>
</head>
<body class="jira" style="color: #333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429">
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<!-- header here -->
<tr>
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px"> <img id="header-avatar-image" class="image_fix" src="https://community.jboss.org/gravatar/330a2b4b2b915d75303b916ce14cda24?d=mm&s=48" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top" />
</td>
<td id="header-text-container" valign="middle" style="padding: 0px; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="jharting" id="email_jharting" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=jharting" style="color:#3b73af;; color: #3b73af; text-decoration: none">Jozef Hartinger</a> <strong>updated</strong> an issue
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0px; border-collapse: collapse; padding: 0 20px">
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: separate">
<tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<td class="email-content-rounded-top mobile-expand" style="padding: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 15px; background-color: #fff; border-left: 1px solid #ccc; border-top: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly">
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td class="page-title-pattern-first-line " style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; padding-top: 10px"> <a href="https://issues.jboss.org/browse/WELD" style="color: #3b73af; text-decoration: none">Weld</a> / <a href="https://issues.jboss.org/browse/WELD-1619" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-static-bug-16857f84-ecbf-4d12-8839-4d9d6978eb9a" height="16" width="16" border="0" align="absmiddle" alt="Bug" style="vertical-align: text-bottom" /></a> <a href="https://issues.jboss.org/browse/WELD-1619" style="color: #3b73af; text-decoration: none">WELD-1619</a>
</td>
</tr>
<tr>
<td style="vertical-align: top;; padding: 0px; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://issues.jboss.org/browse/WELD-1619" style="color: #3b73af; text-decoration: none">Java SE (weld-se) With surefire threaded per/class (not method) fails after the first thread call to weld.shutdown()</a> </span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand wrapper-special-margin" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff; padding-top: 10px; padding-bottom: 5px">
<table class="keyvalue-table" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Change By:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <a class="user-hover" rel="jharting" id="email_jharting" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=jharting" style="color:#3b73af;; color: #3b73af; text-decoration: none">Jozef Hartinger</a>
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Fix Version/s:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <span class="diffaddedchars" style="background-color:#ddfade;">2.2.2.Final</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand issue-description-container" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff; padding-top: 5px; padding-bottom: 10px">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0px; border-collapse: collapse; padding: 0 0 10px 0"> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"><br /></span> <span class="diffcontext">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 />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 />Initially 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 /><br /></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0px; vertical-align: middle"> <a href="https://issues.jboss.org/browse/WELD-1619#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-f569bdbc-ce47-43d6-8620-5ee5826f3a0a" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle" /> </a>
</td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://issues.jboss.org/browse/WELD-1619#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<tr>
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #fff; border-top: 0; border-left: 1px solid #ccc; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px; border-collapse: collapse; color: #999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px">
This message was sent by Atlassian JIRA <span id="footer-build-information">(v6.2.3#6260-<span title="63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558" data-commit-id="63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558}">sha1:63ef1d6</span>)</span>
</td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0px; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-040c12ec-6b76-4650-b2b8-4c78447bfe73" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>