<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Running AS7 embedded in Arquillian
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/thomas.diesler%40jboss.com">Thomas Diesler</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/message/572225#572225">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>This post describes what I have done and have seen when running AS7 embedded in Arquillian. There is a large overlap with what Kabir has done with embedded AS7 so lets try to converge.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The <a class="jive-link-external-small" href="https://github.com/jbosgi/arquillian/blob/jbas7/containers/jbossas-embedded-7/src/main/java/org/jboss/arquillian/container/jbossas/embedded_7/JBossASEmbeddedContainer.java">JBossASEmbeddedContainer</a> the <a class="jive-link-external-small" href="https://github.com/jbosgi/jboss-as/blob/arquillian/server/src/main/java/org/jboss/as/server/StandaloneServerFactory.java">StandaloneServerFactory</a> and waits for the Arquillian MBean to become available</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>         Properties sysprops = new Properties();<br/>         sysprops.putAll(System.getProperties());<br/>         sysprops.setProperty("jboss.home.dir", jbossHomeDir.getAbsolutePath());<br/>         sysprops.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");<br/>         sysprops.setProperty("logging.configuration", "file:" + jbossHomeDir + "/standalone/configuration/logging.properties");<br/>         sysprops.setProperty("org.jboss.boot.log.file", jbossHomeDir + "/standalone/log/boot.log");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>         server = StandaloneServerFactory.create(jbossHomeDir, sysprops);<br/>         server.start();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The StandaloneServerFactory uses the <a class="jive-link-external-small" href="https://github.com/jbosgi/jboss-as/blob/arquillian/server/src/main/java/org/jboss/as/server/InitialModuleLoaderFactory.java">InitialModuleLoaderFactory</a> to bootstrap modules with a controlled set of packages from the app classpath. I agree with Jason, it is impossible to put stuff on the appclasspath and somehow hope the test deployemnts will behave like they would in a running server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>For this to work in ARQ it is necessary that nothing initializes jdk logging before we have a chance to load the LoggingManager from the "org.jboss.logmanager" module. Therefore, I added a <a class="jive-link-external-small" href="https://github.com/jbosgi/arquillian/commit/6a7e152a1416a634047cf11178c7a901eee5d5cd">looging abstraction</a> to ARQ that allows you do disable or redirect ARQ logging to System.out</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml">         <span class="jive-xml-tag"><plugin></span>
            <span class="jive-xml-tag"><artifactId></span>maven-surefire-plugin<span class="jive-xml-tag"></artifactId></span>
            <span class="jive-xml-tag"><configuration></span>
              <span class="jive-xml-tag"><systemProperties></span>
                <span class="jive-xml-tag"><property></span>
                  <span class="jive-xml-tag"><name></span>java.util.logging.manager<span class="jive-xml-tag"></name></span>
                  <span class="jive-xml-tag"><value></span>org.jboss.logmanager.LogManager<span class="jive-xml-tag"></value></span>
                <span class="jive-xml-tag"></property></span>
                <span class="jive-xml-tag"><property></span>
                  <span class="jive-xml-tag"><name></span>arquillian.logging<span class="jive-xml-tag"></name></span>
                  <span class="jive-xml-tag"><value></span>system<span class="jive-xml-tag"></value></span>
                <span class="jive-xml-tag"></property></span>
              <span class="jive-xml-tag"></systemProperties></span>
            <span class="jive-xml-tag"></configuration></span>
          <span class="jive-xml-tag"></plugin></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The StandaloneServerFactory loads the server module and uses reflection and a proxy to bootstrap the server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Currently, the server comes up and deployment fails with</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">12:46:07,295 ERROR [org.jboss.as.protocol.connection] (pool-1-thread-2) Failed to read a message: java.util.ServiceConfigurationError: org.jboss.marshalling.ProviderDescriptor: Provider org.jboss.marshalling.river.RiverProviderDescriptor could not be instantiated: java.lang.ClassCastException
    at java.util.ServiceLoader.fail(ServiceLoader.java:207) [:1.6.0_21]
    at java.util.ServiceLoader.access$100(ServiceLoader.java:164) [:1.6.0_21]
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353) [:1.6.0_21]
    at java.util.ServiceLoader$1.next(ServiceLoader.java:421) [:1.6.0_21]
    at org.jboss.marshalling.Marshalling.loadMarshallerFactory(Marshalling.java:78) [jboss-marshalling-1.3.0.CR8.jar:1.3.0.CR8]
    at org.jboss.marshalling.Marshalling.getMarshallerFactory(Marshalling.java:74) [jboss-marshalling-1.3.0.CR8.jar:1.3.0.CR8]
    at org.jboss.as.protocol.ProtocolUtils.<clinit>(ProtocolUtils.java:50) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
    at org.jboss.as.protocol.mgmt.ManagementProtocolHeader.read(ManagementProtocolHeader.java:75) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
    at org.jboss.as.protocol.mgmt.ManagementResponseHeader.read(ManagementResponseHeader.java:60) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
    at org.jboss.as.protocol.mgmt.ManagementProtocolHeader.<init>(ManagementProtocolHeader.java:55) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
    at org.jboss.as.protocol.mgmt.ManagementResponseHeader.<init>(ManagementResponseHeader.java:45) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
    at org.jboss.as.protocol.mgmt.ManagementRequest$1.handle(ManagementRequest.java:124) [jboss-as-protocol-7.0.0.Alpha1.jar:7.0.0.Alpha1]
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>StandaloneServer is now an interface that also supports StandaloneServer.stop(). The idea is that the factory installs a service that can be used to bring down the server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>To try this out you need to checkout these branches</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><a class="jive-link-external-small" href="https://github.com/jbosgi/arquillian/tree/jbas7" target="_blank">https://github.com/jbosgi/arquillian/tree/jbas7</a></p><p><a class="jive-link-external-small" href="https://github.com/jbosgi/jboss-as/tree/arquillian" target="_blank">https://github.com/jbosgi/jboss-as/tree/arquillian</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Build AS7 and in arquillian run</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">mvn -Djboss.home=/home/tdiesler/git/jboss-as/build/target/jboss-7.0.0.Alpha2 -pl container/jbossas-embedded-7 -am install
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'll talk this through with Kabir. So hopefully the demos and other smoke/integration tests can be embedded ARQ tests soon.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>cheers</p><p>-thomas</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/572225#572225">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>