title: How to specify portable data source in web.xml or elsewhere in Arquillian?
body: <p>I'm getting started with Arquillian and noticed that one has to specify data sources to be used with JTA in JPA in the server specific files (<code>jboss-ds.xml</code>, <code>glassfish-resources.xml</code>, etc.), however in Java EE > 6 it should be possible to specify it in <code>web.xml</code> (or <code>ejb-jar.xml</code>, <code>application.xml</code> or <code>application-client.xml</code>), e.g.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
      [...]
      &lt;data-source&gt;
          &lt;name&gt;jdbc/project1&lt;/name&gt;
          &lt;class-name&gt;org.apache.derby.jdbc.EmbeddedDataSource&lt;/class-name&gt;
          &lt;server-name&gt;localhost&lt;/server-name&gt;
          &lt;database-name&gt;project1&lt;/database-name&gt;
          &lt;user&gt;project1&lt;/user&gt;
          &lt;password&gt;project1&lt;/password&gt;
          &lt;property&gt;
              &lt;name&gt;connectionAttributes&lt;/name&gt;
              &lt;value&gt;create=true&lt;/value&gt;
          &lt;/property&gt;
          &lt;transactional&gt;true&lt;/transactional&gt;
          &lt;isolation-level&gt;TRANSACTION_READ_COMMITTED&lt;/isolation-level&gt;
          &lt;initial-pool-size&gt;2&lt;/initial-pool-size&gt;
          &lt;max-pool-size&gt;10&lt;/max-pool-size&gt;
          &lt;min-pool-size&gt;5&lt;/min-pool-size&gt;
          &lt;max-statements&gt;0&lt;/max-statements&gt;
      &lt;/data-source&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and use it as follows:</p>
  
  <pre><code>@Deployment
  public static Archive&lt;?&gt; createDeployment() {
      WebArchive retValue = ShrinkWrap.create(WebArchive.class)
              .addClasses(MyManagedBean.class, SaveController.class, DefaultSaveController.class)
              .setWebXML("web.xml")
              .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
      Stream.of(Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().as(JavaArchive.class)).forEach(archive -&gt; retValue.addAsLibrary(archive));
      return retValue;
  }
  </code></pre>
  
  <p>which would avoid redundancies. However the data source isn't available, e.g GlassFish fails due to <code>Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/project1__pm</code>.</p>
  
  <p>A MCVE is at <a href="https://github.com/krichter722/arquillian-data-source-in-web-xml" rel="nofollow noreferrer">https://github.com/krichter722/arquillian-data-source-in-web-xml</a>.</p>
  
  <p>Arquillian seems to create a data source which might be usable, but I'd like to test the exact type of my production environment since those tests are very close to integration already.</p>