问:
java.lang.NoClassDefFoundError: Lorg/infinispan/manager/EmbeddedCacheManager
Please help. I am trying to do a simple cache mechanism using Jboss 8.1.0 cache functionality. This is how I had implemented the project structure:

The pomn file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>21</version>
        <relativePath />
    </parent>

    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-web-7.0</artifactId>
    <version>1.1.0.Final</version>
    <packaging>pom</packaging>

    <name>JBoss Java EE 7 Web Profile APIs</name>
    <description>JBoss Java EE 7 Web Profile APIs</description>

    <url>http://jboss.org/infinispan</url>
    <licenses>
        <license>
            <name>GNU Lesser General Public License</name>
            <url>http://www.gnu.org/copyleft/lesser.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <!-- Explicitly declaring the source encoding eliminates the following
            message: -->
        <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
            resources, i.e. build is platform dependent! -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <version.jboss.javaee.web>2.0.0.Final</version.jboss.javaee.web>
        <infinispan.version>6.0.2.Final</infinispan.version>
    </properties>

    <scm>
        <connection>scm:git:git@github.com:jboss/jboss-javaee-specs.git</connection>
        <developerConnection>scm:git:git@github.com:jboss/jboss-javaee-specs.git</developerConnection>
        <url>https://github.com/jboss/jboss-javaee-specs</url>
        <tag>jboss-javaee-7.0-1.1.0.Final</tag>
    </scm>

    <issueManagement>
        <system>jira</system>
        <url>http://jira.jboss.com/jira/browse/JBEE</url>
    </issueManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-7.0</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- External JavaEE spec APIs (not part of the JBoss JavaEE Specs project) -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
        </dependency>

        <!-- JBoss JavaEE API Specs Projects -->
        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.el</groupId>
            <artifactId>jboss-el-api_3.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.interceptor</groupId>
            <artifactId>jboss-interceptors-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.json</groupId>
            <artifactId>jboss-json-api_1.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.resource</groupId>
            <artifactId>jboss-connector-api_1.7_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet.jsp</groupId>
            <artifactId>jboss-jsp-api_2.3_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.websocket</groupId>
            <artifactId>jboss-websocket-api_1.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.xml.bind</groupId>
            <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
        </dependency>

        <!-- JBoss JavaEE API Specs Projects -->
        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.el</groupId>
            <artifactId>jboss-el-api_3.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.interceptor</groupId>
            <artifactId>jboss-interceptors-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.json</groupId>
            <artifactId>jboss-json-api_1.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.resource</groupId>
            <artifactId>jboss-connector-api_1.7_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet.jsp</groupId>
            <artifactId>jboss-jsp-api_2.3_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.websocket</groupId>
            <artifactId>jboss-websocket-api_1.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.xml.bind</groupId>
            <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
        </dependency>

    </dependencies>

    <build>
        <!-- Set the name of the war, used as the context root when the app is
            deployed -->
        <finalName>infinispan-jboss-as7</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifestEntries>
                            <Dependencies>org.infinispan export</Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <!-- JBoss AS plugin to deploy war -->
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.1.1.Final</version>
            </plugin>

            <!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
                processors -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Dependencies>org.infinispan export</Dependencies>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>

</project>
</code>```

And a picture with the rest of the dependencies, sorry for adding them like this (bad practice). I had those on my local drive.

The project facets:

The standalone.xml file:

```<code>           <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
        <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="local-query">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="jboss-as7-quickstart" default-cache="my_local_cache">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="my_local_cache">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
    </subsystem>
</code>```

The java code for the server:

```<code>import java.io.IOException;

import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.infinispan.Cache;
import org.infinispan.manager.EmbeddedCacheManager;

import javax.enterprise.context.ApplicationScoped;

@WebServlet("/TestCache")
public class TestCache extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Produces
    @ApplicationScoped
    @Resource(lookup = "java:jboss/infinispan/container/jboss-as7-quickstart")
    private static EmbeddedCacheManager container;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Cache<String, Object> localCache = container.getCache();
    }

}
</code>```

And the log with the error:

```<code>11:05:18,748 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
11:05:19,170 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
11:05:19,309 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.1.0.CR2 "Kenny" starting
11:05:21,368 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found infinispan-cdi.war in deployment directory. To trigger deployment create a file called infinispan-cdi.war.dodeploy
11:05:21,405 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
11:05:21,446 INFO  [org.xnio] (MSC service thread 1-1) XNIO version 3.2.2.Final
11:05:21,462 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.2.2.Final
11:05:21,528 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
11:05:21,531 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
11:05:21,540 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
11:05:21,542 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
11:05:21,545 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
11:05:21,548 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
11:05:21,554 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Beta1
11:05:21,558 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-13) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.5.Final)
11:05:21,645 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.0.10.Final starting
11:05:21,645 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
11:05:21,648 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-15) JBAS017502: Undertow 1.0.10.Final starting
11:05:21,653 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010417: Started Driver service with driver-name = h2
11:05:21,775 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
11:05:21,775 INFO  [org.jboss.as.naming] (MSC service thread 1-14) JBAS011802: Starting Naming Service
11:05:22,036 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
11:05:22,039 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-15) JBAS010417: Started Driver service with driver-name = ojdbc6
11:05:22,354 INFO  [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.3.Final
11:05:22,380 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path E:/Ditech/MORE/PPN
11:05:22,410 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path E:\Ditech\MORE\Server\JBoss\JBoss/docs
11:05:22,427 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-11) JBAS017525: Started server default-server.
11:05:22,464 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
11:05:22,635 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
11:05:22,873 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-9) JBAS015012: Started FileSystemDeploymentService for directory E:\Ditech\MORE\Server\JBoss\JBoss\standalone\deployments
11:05:22,877 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "infinispan-cdi.war" (runtime-name: "infinispan-cdi.war")
11:05:22,893 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-16) JBAS010400: Bound data source [java:jboss/jdbc/PpnDS]
11:05:22,894 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/jdbc/PUDS]
11:05:22,895 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
11:05:23,600 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
11:05:24,777 INFO  [org.jboss.weld.deployer] (MSC service thread 1-15) JBAS016002: Processing weld deployment infinispan-cdi.war
11:05:24,912 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-15) HV000001: Hibernate Validator 5.1.0.Final
11:05:25,204 INFO  [org.jboss.weld.deployer] (MSC service thread 1-12) JBAS016005: Starting Services for CDI deployment: infinispan-cdi.war
11:05:25,272 INFO  [org.jboss.weld.Version] (MSC service thread 1-12) WELD-000900: 2.1.2 (Final)
11:05:25,337 INFO  [org.jboss.weld.deployer] (MSC service thread 1-11) JBAS016008: Starting weld service for deployment infinispan-cdi.war
11:05:25,788 WARN  [org.jboss.weld.Event] (MSC service thread 1-14) WELD-000411: Observer method [BackedAnnotatedMethod] org.infinispan.cdi.util.defaultbean.DefaultBeanExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
11:05:27,678 INFO  [org.infinispan.cdi.util.defaultbean.DefaultBeanExtension] (MSC service thread 1-14) Preventing install of default bean Producer Method [Configuration] with qualifiers [@Synthetic @Any] declared as [[UnbackedAnnotatedMethod] @Produces @DefaultBeanInformation @ConfigureCache @Synthetic @DefaultBean public org.infinispan.cdi.DefaultEmbeddedCacheConfigurationProducer.getDefaultEmbeddedCacheConfiguration(@OverrideDefault Instance<Configuration>)]
11:05:28,319 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Initializing Mojarra 2.2.6-jbossorg-4 20140501-1134 for context '/infinispan-cdi'
11:05:29,683 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017534: Registered web context: /infinispan-cdi
11:05:29,783 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "infinispan-cdi.war" (runtime-name : "infinispan-cdi.war")
11:05:29,930 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management
11:05:29,932 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990
11:05:29,933 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.CR2 "Kenny" started in 11766ms - Started 307 of 374 services (115 services are lazy, passive or on-demand)
11:05:39,866 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found CacheTest6.war in deployment directory. To trigger deployment create a file called CacheTest6.war.dodeploy
11:05:39,888 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "CacheTest6.war" (runtime-name: "CacheTest6.war")
11:05:39,966 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC000001: Failed to start service jboss.deployment.unit."CacheTest6.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."CacheTest6.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "CacheTest6.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class test.TestCache with ClassLoader ModuleClassLoader for Module "deployment.CacheTest6.war:main" from Service Module Loader
    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    ... 5 more
Caused by: java.lang.NoClassDefFoundError: Lorg/infinispan/manager/EmbeddedCacheManager;
    at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.8.0_131]
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583) [rt.jar:1.8.0_131]
    at java.lang.Class.getDeclaredFields(Class.java:1916) [rt.jar:1.8.0_131]
    at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:68) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    ... 10 more
Caused by: java.lang.ClassNotFoundException: org.infinispan.manager.EmbeddedCacheManager from [Module "deployment.CacheTest6.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
    ... 15 more

11:05:39,988 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "CacheTest6.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CacheTest6.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CacheTest6.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"CacheTest6.war\"
    Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class test.TestCache with ClassLoader ModuleClassLoader for Module \"deployment.CacheTest6.war:main\" from Service Module Loader
    Caused by: java.lang.NoClassDefFoundError: Lorg/infinispan/manager/EmbeddedCacheManager;
    Caused by: java.lang.ClassNotFoundException: org.infinispan.manager.EmbeddedCacheManager from [Module \"deployment.CacheTest6.war:main\" from Service Module Loader]"}}
11:05:40,103 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "CacheTest6.war" (runtime-name : "CacheTest6.war")
11:05:40,120 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."CacheTest6.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."CacheTest6.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "CacheTest6.war"
</code>```

答:
Finally, I had figured it out after one day and a half. This is the new implementation that works for me:

The pomn file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>infinispan-simple-tutorials-jcache</artifactId>
    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>21</version>
        <relativePath />
    </parent>
    <name>Infinispan Simple Tutorials: JCache</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>-Djava.net.preferIPv4Stack=true</argument>
                        <argument>-Djava.util.logging.config.file=src/main/resources/logging.properties</argument>
                        <argument>-classpath</argument>
                        <classpath />
                        <argument>org.infinispan.tutorial.simple.jcache.InfinispanJCache</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

I had added the jar files that exists in Jboss folder, (Gest search for them) for me this path is

[jboss-folder]\standalone\tmp\vfs\deployment\deployment1d3f5df834f24586\

and from here you must have a reference to almost all the jar files the folders. Here is my example of what I had imported in the project:

Please don't forget to add a reference to poi jar to don't get violated resource access errors.

Now for some reason, I was getting that error because the war file didn't had the jar files inside it. So I had to copy manually all the jars that are added to the project in the lib folder of the war file.

And finally the java part:

```<code>import java.io.IOException;
import java.util.Date;

import javax.annotation.Resource;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.AccessedExpiryPolicy;
import javax.cache.expiry.Duration;
import javax.enterprise.inject.Produces;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.infinispan.manager.CacheContainer;
import org.infinispan.manager.EmbeddedCacheManager;

@WebServlet("/TestCache")
public class TestCache extends HttpServlet {
    private static final long serialVersionUID = 1L;

/*  @Resource(lookup = "java:jboss/infinispan/container/jboss-as7-quickstart")
    private EmbeddedCacheManager container;*/

    @Resource(lookup = "java:jboss/infinispan/container/myCache")
    private CacheContainer container;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/*      CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
        MutableConfiguration<String, Date> config = new MutableConfiguration<String, Date>();

        config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES)).setStatisticsEnabled(true);
        cacheManager.createCache("simpleCache",config);
        javax.cache.Cache<String, Long> localCache= cacheManager.getCache("simpleCache");*/

        System.out.println(container.toString());
    }
}
</code>```

And to don't forghet the jboss standalone.xml file:

```<code>  <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
        <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="local-query">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="jboss-as7-quickstart" default-cache="my_local_cache">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="my_local_cache">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="myCache" default-cache="cachedb">
            <local-cache name="cachedb"/>
        </cache-container>
    </subsystem>
</code>```

Result:

P.S. Thanks "AKSW" for the implication in this problem.

Body:
Please help. I am trying to do a simple cache mechanism using Jboss 8.1.0 cache functionality. This is how I had implemented the project structure:

The pomn file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>21</version>
        <relativePath />
    </parent>

    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-web-7.0</artifactId>
    <version>1.1.0.Final</version>
    <packaging>pom</packaging>

    <name>JBoss Java EE 7 Web Profile APIs</name>
    <description>JBoss Java EE 7 Web Profile APIs</description>

    <url>http://jboss.org/infinispan</url>
    <licenses>
        <license>
            <name>GNU Lesser General Public License</name>
            <url>http://www.gnu.org/copyleft/lesser.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <version.jboss.javaee.web>2.0.0.Final</version.jboss.javaee.web>
        <infinispan.version>6.0.2.Final</infinispan.version>
    </properties>

    <scm>
        <connection>scm:git:git@github.com:jboss/jboss-javaee-specs.git</connection>
        <developerConnection>scm:git:git@github.com:jboss/jboss-javaee-specs.git</developerConnection>
        <url>https://github.com/jboss/jboss-javaee-specs</url>
        <tag>jboss-javaee-7.0-1.1.0.Final</tag>
    </scm>

    <issueManagement>
        <system>jira</system>
        <url>http://jira.jboss.com/jira/browse/JBEE</url>
    </issueManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-7.0</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.el</groupId>
            <artifactId>jboss-el-api_3.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.interceptor</groupId>
            <artifactId>jboss-interceptors-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.json</groupId>
            <artifactId>jboss-json-api_1.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.resource</groupId>
            <artifactId>jboss-connector-api_1.7_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet.jsp</groupId>
            <artifactId>jboss-jsp-api_2.3_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.websocket</groupId>
            <artifactId>jboss-websocket-api_1.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.xml.bind</groupId>
            <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.el</groupId>
            <artifactId>jboss-el-api_3.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.interceptor</groupId>
            <artifactId>jboss-interceptors-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.json</groupId>
            <artifactId>jboss-json-api_1.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.resource</groupId>
            <artifactId>jboss-connector-api_1.7_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet.jsp</groupId>
            <artifactId>jboss-jsp-api_2.3_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.websocket</groupId>
            <artifactId>jboss-websocket-api_1.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.xml.bind</groupId>
            <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
        </dependency>

    </dependencies>

    <build>

        <finalName>infinispan-jboss-as7</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>

                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifestEntries>
                            <Dependencies>org.infinispan export</Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.1.1.Final</version>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Dependencies>org.infinispan export</Dependencies>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>

</project>

And a picture with the rest of the dependencies, sorry for adding them like this (bad practice). I had those on my local drive.

The project facets:

The standalone.xml file:

           <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
        <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="local-query">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="jboss-as7-quickstart" default-cache="my_local_cache">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="my_local_cache">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
    </subsystem>

The java code for the server:

import java.io.IOException;

import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.infinispan.Cache;
import org.infinispan.manager.EmbeddedCacheManager;

import javax.enterprise.context.ApplicationScoped;

@WebServlet("/TestCache")
public class TestCache extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Produces
    @ApplicationScoped
    @Resource(lookup = "java:jboss/infinispan/container/jboss-as7-quickstart")
    private static EmbeddedCacheManager container;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Cache<String, Object> localCache = container.getCache();
    }

}

And the log with the error:

11:05:18,748 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
11:05:19,170 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
11:05:19,309 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.1.0.CR2 "Kenny" starting
11:05:21,368 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found infinispan-cdi.war in deployment directory. To trigger deployment create a file called infinispan-cdi.war.dodeploy
11:05:21,405 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
11:05:21,446 INFO  [org.xnio] (MSC service thread 1-1) XNIO version 3.2.2.Final
11:05:21,462 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.2.2.Final
11:05:21,528 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
11:05:21,531 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
11:05:21,540 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
11:05:21,542 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
11:05:21,545 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
11:05:21,548 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
11:05:21,554 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Beta1
11:05:21,558 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-13) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.5.Final)
11:05:21,645 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.0.10.Final starting
11:05:21,645 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
11:05:21,648 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-15) JBAS017502: Undertow 1.0.10.Final starting
11:05:21,653 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010417: Started Driver service with driver-name = h2
11:05:21,775 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
11:05:21,775 INFO  [org.jboss.as.naming] (MSC service thread 1-14) JBAS011802: Starting Naming Service
11:05:22,036 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
11:05:22,039 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-15) JBAS010417: Started Driver service with driver-name = ojdbc6
11:05:22,354 INFO  [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.3.Final
11:05:22,380 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path E:/Ditech/MORE/PPN
11:05:22,410 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path E:\Ditech\MORE\Server\JBoss\JBoss/docs
11:05:22,427 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-11) JBAS017525: Started server default-server.
11:05:22,464 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
11:05:22,635 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
11:05:22,873 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-9) JBAS015012: Started FileSystemDeploymentService for directory E:\Ditech\MORE\Server\JBoss\JBoss\standalone\deployments
11:05:22,877 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "infinispan-cdi.war" (runtime-name: "infinispan-cdi.war")
11:05:22,893 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-16) JBAS010400: Bound data source [java:jboss/jdbc/PpnDS]
11:05:22,894 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/jdbc/PUDS]
11:05:22,895 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
11:05:23,600 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
11:05:24,777 INFO  [org.jboss.weld.deployer] (MSC service thread 1-15) JBAS016002: Processing weld deployment infinispan-cdi.war
11:05:24,912 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-15) HV000001: Hibernate Validator 5.1.0.Final
11:05:25,204 INFO  [org.jboss.weld.deployer] (MSC service thread 1-12) JBAS016005: Starting Services for CDI deployment: infinispan-cdi.war
11:05:25,272 INFO  [org.jboss.weld.Version] (MSC service thread 1-12) WELD-000900: 2.1.2 (Final)
11:05:25,337 INFO  [org.jboss.weld.deployer] (MSC service thread 1-11) JBAS016008: Starting weld service for deployment infinispan-cdi.war
11:05:25,788 WARN  [org.jboss.weld.Event] (MSC service thread 1-14) WELD-000411: Observer method [BackedAnnotatedMethod] org.infinispan.cdi.util.defaultbean.DefaultBeanExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
11:05:27,678 INFO  [org.infinispan.cdi.util.defaultbean.DefaultBeanExtension] (MSC service thread 1-14) Preventing install of default bean Producer Method [Configuration] with qualifiers [@Synthetic @Any] declared as [[UnbackedAnnotatedMethod] @Produces @DefaultBeanInformation @ConfigureCache @Synthetic @DefaultBean public org.infinispan.cdi.DefaultEmbeddedCacheConfigurationProducer.getDefaultEmbeddedCacheConfiguration(@OverrideDefault Instance<Configuration>)]
11:05:28,319 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Initializing Mojarra 2.2.6-jbossorg-4 20140501-1134 for context '/infinispan-cdi'
11:05:29,683 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017534: Registered web context: /infinispan-cdi
11:05:29,783 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "infinispan-cdi.war" (runtime-name : "infinispan-cdi.war")
11:05:29,930 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management
11:05:29,932 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990
11:05:29,933 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.CR2 "Kenny" started in 11766ms - Started 307 of 374 services (115 services are lazy, passive or on-demand)
11:05:39,866 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found CacheTest6.war in deployment directory. To trigger deployment create a file called CacheTest6.war.dodeploy
11:05:39,888 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "CacheTest6.war" (runtime-name: "CacheTest6.war")
11:05:39,966 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC000001: Failed to start service jboss.deployment.unit."CacheTest6.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."CacheTest6.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "CacheTest6.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class test.TestCache with ClassLoader ModuleClassLoader for Module "deployment.CacheTest6.war:main" from Service Module Loader
    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    ... 5 more
Caused by: java.lang.NoClassDefFoundError: Lorg/infinispan/manager/EmbeddedCacheManager;
    at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.8.0_131]
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583) [rt.jar:1.8.0_131]
    at java.lang.Class.getDeclaredFields(Class.java:1916) [rt.jar:1.8.0_131]
    at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:68) [wildfly-server-8.1.0.CR2.jar:8.1.0.CR2]
    ... 10 more
Caused by: java.lang.ClassNotFoundException: org.infinispan.manager.EmbeddedCacheManager from [Module "deployment.CacheTest6.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
    ... 15 more

11:05:39,988 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "CacheTest6.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CacheTest6.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CacheTest6.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"CacheTest6.war\"
    Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class test.TestCache with ClassLoader ModuleClassLoader for Module \"deployment.CacheTest6.war:main\" from Service Module Loader
    Caused by: java.lang.NoClassDefFoundError: Lorg/infinispan/manager/EmbeddedCacheManager;
    Caused by: java.lang.ClassNotFoundException: org.infinispan.manager.EmbeddedCacheManager from [Module \"deployment.CacheTest6.war:main\" from Service Module Loader]"}}
11:05:40,103 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "CacheTest6.war" (runtime-name : "CacheTest6.war")
11:05:40,120 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."CacheTest6.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."CacheTest6.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "CacheTest6.war"

Body:
Finally, I had figured it out after one day and a half. This is the new implementation that works for me:

The pomn file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>infinispan-simple-tutorials-jcache</artifactId>
    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>21</version>
        <relativePath />
    </parent>
    <name>Infinispan Simple Tutorials: JCache</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>-Djava.net.preferIPv4Stack=true</argument>
                        <argument>-Djava.util.logging.config.file=src/main/resources/logging.properties</argument>
                        <argument>-classpath</argument>
                        <classpath />
                        <argument>org.infinispan.tutorial.simple.jcache.InfinispanJCache</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I had added the jar files that exists in Jboss folder, (Gest search for them) for me this path is

[jboss-folder]\standalone\tmp\vfs\deployment\deployment1d3f5df834f24586\

and from here you must have a reference to almost all the jar files the folders. Here is my example of what I had imported in the project:

Please don't forget to add a reference to poi jar to don't get violated resource access errors.

Now for some reason, I was getting that error because the war file didn't had the jar files inside it. So I had to copy manually all the jars that are added to the project in the lib folder of the war file.

And finally the java part:

import java.io.IOException;
import java.util.Date;

import javax.annotation.Resource;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.AccessedExpiryPolicy;
import javax.cache.expiry.Duration;
import javax.enterprise.inject.Produces;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.infinispan.manager.CacheContainer;
import org.infinispan.manager.EmbeddedCacheManager;

@WebServlet("/TestCache")
public class TestCache extends HttpServlet {
    private static final long serialVersionUID = 1L;

/*  @Resource(lookup = "java:jboss/infinispan/container/jboss-as7-quickstart")
    private EmbeddedCacheManager container;*/

    @Resource(lookup = "java:jboss/infinispan/container/myCache")
    private CacheContainer container;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/*      CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
        MutableConfiguration<String, Date> config = new MutableConfiguration<String, Date>();

        config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES)).setStatisticsEnabled(true);
        cacheManager.createCache("simpleCache",config);
        javax.cache.Cache<String, Long> localCache= cacheManager.getCache("simpleCache");*/

        System.out.println(container.toString());
    }
}

And to don't forghet the jboss standalone.xml file:

  <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
        <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
            <local-cache name="passivation" batching="true">
                <file-store passivation="true" purge="false"/>
            </local-cache>
            <local-cache name="persistent" batching="true">
                <file-store passivation="false" purge="false"/>
            </local-cache>
        </cache-container>
        <cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="local-query">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="jboss-as7-quickstart" default-cache="my_local_cache">
            <local-cache name="entity">
                <transaction mode="NON_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="my_local_cache">
                <transaction mode="NONE"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="100000"/>
            </local-cache>
            <local-cache name="timestamps">
                <transaction mode="NONE"/>
                <eviction strategy="NONE"/>
            </local-cache>
        </cache-container>
        <cache-container name="myCache" default-cache="cachedb">
            <local-cache name="cachedb"/>
        </cache-container>
    </subsystem>

Result:

P.S. Thanks "AKSW" for the implication in this problem.


来源: stackexchange

问:
Align multiple plots with unequal labels
I have a series of line plots, made with ggplot2.

I want to arrange them in one plot, and I can do this with plot_grid from the cowplot package. However, because the labels (Universität vs. SP) are unequal in length, the plots are not aligned properly. What I want is that the grid area is perfectly aligned along all plots. Any idea how I can achieve this?

This is my code:

```<code>cowplot::plot_grid(plot_party, plot_educ, plot_sex, labels=c("A", "B", "C"), ncol = 1, nrow = 3)
</code>```

答:
in the cowplot::plot_grid() function you can specify the align parameter which controlls the alignment as follows:

default ("none" )

horizontally ("h")

vertically ("v")

align in both directions ("hv")

So you need to run:

```<code>cowplot::plot_grid(plot_party, plot_educ, plot_sex,
                   labels = c("A", "B", "C"),
                   ncol = 1, nrow = 3,
                   align = "v")
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a series of line plots, made with ggplot2.

I want to arrange them in one plot, and I can do this with plot_grid from the cowplot package. However, because the labels (Universität vs. SP) are unequal in length, the plots are not aligned properly. What I want is that the grid area is perfectly aligned along all plots. Any idea how I can achieve this?

This is my code:

cowplot::plot_grid(plot_party, plot_educ, plot_sex, labels=c("A", "B", "C"), ncol = 1, nrow = 3)

Body:
in the cowplot::plot_grid() function you can specify the align parameter which controlls the alignment as follows:

default ("none" )

horizontally ("h")

vertically ("v")

align in both directions ("hv")

So you need to run:

cowplot::plot_grid(plot_party, plot_educ, plot_sex,
                   labels = c("A", "B", "C"),
                   ncol = 1, nrow = 3,
                   align = "v")


问:
Increment Version number when checking in to TFS
I have a folder in TFS which has SQL Scripts.  At the moment I am manually adding a comment and updating a version number inside the comment every time i make a change and check it back it.  This works however was hoping there might be a better way. Is there a way to automate this in TFS?

I have read the following article
Version control project files

do i have to go through such a process for simple .sql files? Are there any other simple ways.

答:
There are a few ways you can do this:

Create an automated build in TFS and write a custom build step / PowerShell script to parse the appropriate SQL scripts, read the version, increment it, and store the new version by either checking in the updated file or a local store

Use a database project (part of SQL Server Data Tools) which will output a DACPAC.  Inside the database project, you can set the version as specified here.  This stores the version in the project file.  If you update your TFS build number to be digits only, you can then update the project file to set that value to match the build using a custom build task.  For example, if your build number was yyyy.m.d.R where R is the number of times that build was run today (TFS manages that - it's the revision variable).  Or, you could set the the <DacVersion> tag to something like 2.1.0.0 and your build replaces the last digit with yyyymmddr.

I'd recommend using a database project.  It's pretty easy to create a new database project off an existing database.


问:
Alamofire 4 Swift 3 GET request with parameters
I'm building a network stack using Alamofire 4 and Swift 3. Following the Alamofire guidelines I've created a router for the endpoints of the services. I'm currently using the free API of OpenWeatherMap but I'm finding problems in order to create a get request.
That's the url needed: http://api.openweathermap.org/data/2.5/weather?q=Rome&APPID=MY_API_KEY. Pasted on a browser, and using a real API Key it works and gives me back my nice json full of info about the weather in the given location.
On my App I can insert the parameters as Dictionary but I cannot find a way to append the api key at the end of the url.

That's my enum router:

```<code>enum OWARouter: URLRequestConvertible {
      case byCityName(parameters: Parameters)

// MARK: Url
    static let baseURLString = "http://api.openweathermap.org"
    static let apiKey = "MY_APY_KEY"
    static let pathApiKey = "&APPID=\(apiKey)"
    var method: HTTPMethod {
        switch self {
        case .byCityName:
            return .get
        }
    }

    var path: String {
        switch self {
        case .byCityName:
            return "/data/2.5/weather"
        }
    }

// MARK: URLRequestConvertible
    func asURLRequest() throws -> URLRequest {
        let url = try OWARouter.baseURLString.asURL()
        var urlRequest = URLRequest(url: url.appendingPathComponent(path))
        switch self {
        case .byCityName(let parameters):
            urlRequest = try URLEncoding.default.encode(urlRequest, with: parameters)
            print((urlRequest.url)!)

        }

        urlRequest.httpMethod = method.rawValue
        return urlRequest
     }
    }
</code>```

When I log my (urlRequest.url)! I have this: http://api.openweathermap.org/data/2.5/weather?q=Rome but I cannot find a way to add the apiKey.
What am I doing wrong?

I've also made an ugly test adding this code after the print:

```<code>        var urlRequest2 = URLRequest(url: (urlRequest.url)!.appendingPathComponent(OWARouter.pathApiKey))
        print("URL2: \(urlRequest2)")
</code>```

And the log is URL2: http://api.openweathermap.org/data/2.5/weather/&APPID=My_API_KEY?q=Rome
How come the api key is in the middle?

If you need this is the simple request code:

```<code>   Alamofire.request(OWARouter.byCityName(parameters: ["q":"Rome"])).responseJSON { response in

           print(response.request)
           print(response.response)
           print(response.data)
           print(response.result)

           debugPrint(response)

           if let JSON = response.result.value {
                   print("json: \(JSON)")
           }
        }
</code>```

Another question...
If I use as parameters ["q":"Rome, IT"], my output url is: http://api.openweathermap.org/data/2.5/weather?q=Rome%2CIT

How to keep the comma?

Thank you!

答:
import UIKit
import Alamofire
class APIWRAPPER: NSObject {</p>

```<code>static let instance = APIWRAPPER()

func LoginAPI(Uname : String , Password : String)  {

let requestString =
"http://************php/v1/sign-in"
let params = ["user_name": Uname,
              "password": Password]

Alamofire.request(requestString,method: .get, parameters: params, encoding: JSONEncoding.prettyPrinted, headers: [:]).responseJSON { (response:DataResponse<Any>) in

switch(response.result) {
case .success(_):
if response.result.value != nil

{
print("response : \(response.result.value!)")
}
else
{
print("Error")
}
break
case .failure(_):
print("Failure : \(response.result.error!)")
break
}
}
}
}
</code>```

Body:
I'm building a network stack using Alamofire 4 and Swift 3. Following the Alamofire guidelines I've created a router for the endpoints of the services. I'm currently using the free API of OpenWeatherMap but I'm finding problems in order to create a get request.
That's the url needed: http://api.openweathermap.org/data/2.5/weather?q=Rome&APPID=MY_API_KEY. Pasted on a browser, and using a real API Key it works and gives me back my nice json full of info about the weather in the given location.
On my App I can insert the parameters as Dictionary but I cannot find a way to append the api key at the end of the url.

That's my enum router:

enum OWARouter: URLRequestConvertible {
      case byCityName(parameters: Parameters)

// MARK: Url
    static let baseURLString = "http://api.openweathermap.org"
    static let apiKey = "MY_APY_KEY"
    static let pathApiKey = "&APPID=\(apiKey)"
    var method: HTTPMethod {
        switch self {
        case .byCityName:
            return .get
        }
    }

    var path: String {
        switch self {
        case .byCityName:
            return "/data/2.5/weather"
        }
    }

// MARK: URLRequestConvertible
    func asURLRequest() throws -> URLRequest {
        let url = try OWARouter.baseURLString.asURL()
        var urlRequest = URLRequest(url: url.appendingPathComponent(path))
        switch self {
        case .byCityName(let parameters):
            urlRequest = try URLEncoding.default.encode(urlRequest, with: parameters)
            print((urlRequest.url)!)

        }

        urlRequest.httpMethod = method.rawValue
        return urlRequest
     }
    }

When I log my (urlRequest.url)! I have this: http://api.openweathermap.org/data/2.5/weather?q=Rome but I cannot find a way to add the apiKey.
What am I doing wrong?

I've also made an ugly test adding this code after the print:

        var urlRequest2 = URLRequest(url: (urlRequest.url)!.appendingPathComponent(OWARouter.pathApiKey))
        print("URL2: \(urlRequest2)")

And the log is URL2: http://api.openweathermap.org/data/2.5/weather/&APPID=My_API_KEY?q=Rome
How come the api key is in the middle?

If you need this is the simple request code:

   Alamofire.request(OWARouter.byCityName(parameters: ["q":"Rome"])).responseJSON { response in

           print(response.request)
           print(response.response)
           print(response.data)
           print(response.result)

           debugPrint(response)

           if let JSON = response.result.value {
                   print("json: \(JSON)")
           }
        }

Another question...
If I use as parameters ["q":"Rome, IT"], my output url is: http://api.openweathermap.org/data/2.5/weather?q=Rome%2CIT

How to keep the comma?

Thank you!

Body:
import UIKit
import Alamofire
class APIWRAPPER: NSObject {

static let instance = APIWRAPPER()

func LoginAPI(Uname : String , Password : String)  {

let requestString =
"http://************php/v1/sign-in"
let params = ["user_name": Uname,
              "password": Password]

Alamofire.request(requestString,method: .get, parameters: params, encoding: JSONEncoding.prettyPrinted, headers: [:]).responseJSON { (response:DataResponse<Any>) in

switch(response.result) {
case .success(_):
if response.result.value != nil

{
print("response : \(response.result.value!)")
}
else
{
print("Error")
}
break
case .failure(_):
print("Failure : \(response.result.error!)")
break
}
}
}
}

ContentLicense: CC BY-SA 4.0


问:
A special switch statement in C
I am reading CSAPP, the chapter about setjmp and longjmp, and encounter the following code snippets:

```<code>int rc;
switch(setjmp(buf));
if (rc == 0)
    foo();
else if (rc == 1)
    printf("sth.");
else if (rc == 2)
    printf("sth. other");
...
</code>```

The switch statement really confused me, could someone explain this usage of switch statement in C for me?

PS: This is actually an error of CSAPP(the second edition), and the author fixes this by using normal switch-case statement in the third edition. Thanks for all.

答:
It's someone being cute: the documentation of the C-standard library function setjmp reveals that the function can only be used in a small number of places; the controlling expression of a switch being one of them.

switch(setjmp(buf)); doesn't actually do anything other than call the function setjmp(buf). The body of the switch is the empty statement ;

Note that the considerably less obtuse

```<code>setjmp(buf);
</code>```

is also valid. Perhaps the author uses the switch obfuscation to signal that they are doing something out of the ordinary.

Reference: http://en.cppreference.com/w/cpp/utility/program/setjmp

Title: A special switch statement in C

Body:
I am reading CSAPP, the chapter about setjmp and longjmp, and encounter the following code snippets:

int rc;
switch(setjmp(buf));
if (rc == 0)
    foo();
else if (rc == 1)
    printf("sth.");
else if (rc == 2)
    printf("sth. other");
...

The switch statement really confused me, could someone explain this usage of switch statement in C for me?

PS: This is actually an error of CSAPP(the second edition), and the author fixes this by using normal switch-case statement in the third edition. Thanks for all.

Body:
It's someone being cute: the documentation of the C-standard library function setjmp reveals that the function can only be used in a small number of places; the controlling expression of a switch being one of them.

switch(setjmp(buf)); doesn't actually do anything other than call the function setjmp(buf). The body of the switch is the empty statement ;

Note that the considerably less obtuse

setjmp(buf);

is also valid. Perhaps the author uses the switch obfuscation to signal that they are doing something out of the ordinary.

Reference: http://en.cppreference.com/w/cpp/utility/program/setjmp


问:
How to Dict.get a case insensitive key?
I'd like to grab the Total-Records key of a response.headers HTTP response.

Problem is that in some browser it is as returned by the server Total-Records but in some other, it is in lower case.

I'd like to get the value of the Total-Records header regardless of its case.
How would you do that?

答:
I think the least costly way - in general - is simply to do the two look ups and see what you get. For example,

```<code>case (Dict.get "Total-Records" response.headers, Dict.get "total-Records" response.headers) of
    (Just s, _) ->
         s
    (_, Just s) ->
         s
    _ ->
         <handle error case>
</code>```

Alternatively you could replace the above with if then else.

Title: How to Dict.get a case insensitive key?

Body:
I think the least costly way - in general - is simply to do the two look ups and see what you get. For example,

case (Dict.get "Total-Records" response.headers, Dict.get "total-Records" response.headers) of
    (Just s, _) ->
         s
    (_, Just s) ->
         s
    _ ->
         <handle error case>

Alternatively you could replace the above with if then else.


问:
Key Error: Session ID with latest version of GeckoDriver, FF, and Selenium
I recently upgraded the various pieces of our selenium suite, and when I updated the GeckoDriver to the latest version (0.16.1) I started encountering the following error during set up:

```<code>KeyError: 'sessionId'
</code>```

I know this issue has been brought up here before, but I've checked the other threads and made sure I've followed the correct process.  It seems the universal suggestion is to make sure everything is updated correctly.

I'm using robot framework with a modified version of their Selenium2Library to write and run the tests.

robot version is 3.0.2

selenium version is 3.4.3

FF version is 53.0.3

I have also tried altering my proxy settings following the guidance in the thread here(I am on a mac OS X El Capitan):

Why doesn't Selenium's response have a sessionId?

All of this is to no avail.  The only thing I can do to get my tests back to a semi-functional state on firefox is to downgrade the geckodriver.  I'd like to avoid that if possible, since this newest version has some bug fixes helpful to me.

Any guidance on what I should try next?

答:
I've resolved this using the nuclear option -- I did a full uninstall of the three main dependencies in the original question and reinstalled through pip.

Latest versions seem to be in good shape.  For some reason this resolved the underlying keyError.  It does not appear that upgrading the Selenium2Library had any effect.

Body:
I recently upgraded the various pieces of our selenium suite, and when I updated the GeckoDriver to the latest version (0.16.1) I started encountering the following error during set up:

KeyError: 'sessionId'

I know this issue has been brought up here before, but I've checked the other threads and made sure I've followed the correct process.  It seems the universal suggestion is to make sure everything is updated correctly.

I'm using robot framework with a modified version of their Selenium2Library to write and run the tests.

robot version is 3.0.2

selenium version is 3.4.3

FF version is 53.0.3

I have also tried altering my proxy settings following the guidance in the thread here(I am on a mac OS X El Capitan):

Why doesn't Selenium's response have a sessionId?

All of this is to no avail.  The only thing I can do to get my tests back to a semi-functional state on firefox is to downgrade the geckodriver.  I'd like to avoid that if possible, since this newest version has some bug fixes helpful to me.

Any guidance on what I should try next?


问:
Swift 3: how can I detect the touch event on UIScrollView?
I used the below function to detect the touch event on scroll view.

```<code>override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
</code>```

But this can't detect any touch event.
How can I detect touch event on scroll view?

答:
Set up a tap recognizer on your scrollView:

In your viewDidLoad add the following:

```<code>let scrollViewTap = UITapGestureRecognizer(target: self, action: #selector(scrollViewTapped))
scrollView.addGestureRecognizer(scrollViewTap)
</code>```

Declare this function which will be called when the scrollView is tapped:

```<code>func scrollViewTapped() {
    print("scrollViewTapped")
}
</code>```

Body:
I used the below function to detect the touch event on scroll view.

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

But this can't detect any touch event.
How can I detect touch event on scroll view?

Body:
Set up a tap recognizer on your scrollView:

In your viewDidLoad add the following:

let scrollViewTap = UITapGestureRecognizer(target: self, action: #selector(scrollViewTapped))
scrollView.addGestureRecognizer(scrollViewTap)

Declare this function which will be called when the scrollView is tapped:

func scrollViewTapped() {
    print("scrollViewTapped")
}


问:
asp:RequiredFieldValidator with the contents being a table row
I've got the following code, which to my eye looks fine, can anyone suggest why it doesn't work?

```<code><tr>
  <td>
    <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />
  </td>
  <td>
  </td>
</tr>

<asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5" Display="Dynamic" runat="server">
  <tr>
    <td colspan="2">
      <span class="error">You need a purchaser email</span>
    </td>
  </tr>
</asp:RequiredFieldValidator>
</code>```

The problem is that the validator renders fine, but refuses to disappear when the email is correctly filled in as it should.

Thanks!

答:
I was testing the following code snippet and it does work in IE8 for me (I didn't change anything):

```<code><%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
     <table>
        <tr>
            <td>
                <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />
            </td>
            <td>
            </td>
        </tr>
        <asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5"
            Display="Dynamic" runat="server">
                <tr>
                   <td colspan="2">
                     <span class="error">You need a purchaser email</span>
                   </td>
                 </tr>
        </asp:RequiredFieldValidator>
    </table>
    <asp:Button Text="OK" runat="server" />
</asp:Content>
</code>```

However IE6, FF, Chrome are all failing but I think you could resolve that by replacing the fancy 'table' markup with divs, like so:

```<code><%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div>
        <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />
    </div>
    <asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5"
        Display="Dynamic" runat="server">
            <div>
                <span class="error">You need a purchaser email</span>
            </div>
    </asp:RequiredFieldValidator>
    <asp:Button Text="OK" runat="server" />
</asp:Content>
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I've got the following code, which to my eye looks fine, can anyone suggest why it doesn't work?

    <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />

<asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5" Display="Dynamic" runat="server">

      You need a purchaser email

</asp:RequiredFieldValidator>

The problem is that the validator renders fine, but refuses to disappear when the email is correctly filled in as it should.

Thanks!

Body:
I was testing the following code snippet and it does work in IE8 for me (I didn't change anything):

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
     <table>
        <tr>
            <td>
                <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />
            </td>
            <td>
            </td>
        </tr>
        <asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5"
            Display="Dynamic" runat="server">
                <tr>
                   <td colspan="2">
                     <span class="error">You need a purchaser email</span>
                   </td>
                 </tr>
        </asp:RequiredFieldValidator>
    </table>
    <asp:Button Text="OK" runat="server" />
</asp:Content>

However IE6, FF, Chrome are all failing but I think you could resolve that by replacing the fancy 'table' markup with divs, like so:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div>
        <asp:TextBox ID="PurchaserEmailTextBox" runat="server" CssClass="type-text" />
    </div>
    <asp:RequiredFieldValidator ControlToValidate="PurchaserEmailTextBox" ID="RequiredFieldValidator5"
        Display="Dynamic" runat="server">
            <div>
                <span class="error">You need a purchaser email</span>
            </div>
    </asp:RequiredFieldValidator>
    <asp:Button Text="OK" runat="server" />
</asp:Content>


问:
Promise chain not executing in expected order - nodejs
I have a chain of 4 promises, and 1 function at the end. The final function is executing before the previous promises in the chain have resolved.

Can someone explain to me why this might be happening?

Here is the promise chain:

updateGdax(db)
  .then(updateBitstamp(db))
  .then(updateBitfinex(db))
  .then(updatePoloniex(db))
  .then(coinMarketData.updateCoinMarketData(db))
  .then(addRates(db)); //this function is executing after the first promise in the chain.```

I would like each function to execute after the one listed before it, so addRates(db) should be executed last.

I can post the code from the promise functions if needed for further analyses, but I really just want to understand WHY this would happen, as my understanding is that functions in a promise chain won't execute unless the previous promise in the chain has resolved.

答:
Try below approach,

```<code>updateGdax(db)
  .then(function(){
    return updateBitstamp(db)
  }).then(function (){
    return updateBitfinex(db);
  }).then(function() {
    return updatePoloniex(db);
  }).then(function(){
    return coinMarketData.updateCoinMarketData(db)
  }).then(function(){
    return addRates(db);
  }).catch(function(err){
    console.log(err);
  });
</code>```

Hope this will work. If any of the function is returning any value and if you want to use it in subsequent function the pass that value in following function() used inside then. Refer : https://strongloop.com/strongblog/promises-in-node-js-an-alternative-to-callbacks/

Body:
I have a chain of 4 promises, and 1 function at the end. The final function is executing before the previous promises in the chain have resolved.

Can someone explain to me why this might be happening?

Here is the promise chain:

updateGdax(db)
  .then(updateBitstamp(db))
  .then(updateBitfinex(db))
  .then(updatePoloniex(db))
  .then(coinMarketData.updateCoinMarketData(db))
  .then(addRates(db)); //this function is executing after the first promise in the chain.

I would like each function to execute after the one listed before it, so addRates(db) should be executed last.

I can post the code from the promise functions if needed for further analyses, but I really just want to understand WHY this would happen, as my understanding is that functions in a promise chain won't execute unless the previous promise in the chain has resolved.

Body:
Try below approach,

updateGdax(db)
  .then(function(){
    return updateBitstamp(db)
  }).then(function (){
    return updateBitfinex(db);
  }).then(function() {
    return updatePoloniex(db);
  }).then(function(){
    return coinMarketData.updateCoinMarketData(db)
  }).then(function(){
    return addRates(db);
  }).catch(function(err){
    console.log(err);
  });

Hope this will work. If any of the function is returning any value and if you want to use it in subsequent function the pass that value in following function() used inside then. Refer : https://strongloop.com/strongblog/promises-in-node-js-an-alternative-to-callbacks/


问:
Storing configuration and secrets
I'm planning to wrap our application (which consists of multiple microservices) into a chart.

Right now, for each microservice, we store secrets and configuration values hardcoded directly in our deployment.yaml files, in ...containers[].env. All of our yaml files are stored in git repo.

I have noticed that some popular charts use ConfigMap (1, 2) and Secret (1, 2) Kubernetes objects to store config values and secrets respectively.

What are some advantages, be it ergonomics and/or security gains, of using ConfigMap and Secret objects?

I could already make templates out of all yaml files we have, making all hardcoded values configurable and thus resolvable during helm's template compilation time.

However, since Kubernetes provides specialized objects to store configuration & secrets, I want to justify adding configmap.yaml and secrets.yaml template files, as well adding references to them from existing deployment.yaml files.

答:
Configmaps are very generic configuration files. They can consist of a list of key value pairs but they can also be generic files. For example you can store a nginx configuration file nginx.conf in a configmap and load it in the proper location for the nginx daemon to read it.

Secrets are supposed to be used for storing sensitive data, unfortunately right now secrets are not encrypted, they are just based64 encoded. So while this helps you remove hardcoded non-encrypted values from your manifests, it does not help with encryption at all. This should get better in v1.7

You can set environment variables in your deployment manifest to point to specific values in secrets or configmaps. Both are also easily generated with kubectl for example:

kubectl create secret generic foobar --from-literal=password=foobar

kubectl create configmap foobar --from-file=foobar.conf

Helm charts best practice is to use both, see mariadb chart.

Personally, when I need to load a file in a Pod I use a configmap, and when I deal with a sensitive env variable I use a secret, keeping in mind that it is not encrypted.

Title: Storing configuration and secrets


问:
botocore.exceptions.ProfileNotFound when code run on AWS elastic beanstalk, but locally it's OK
I am trying to run a python application on an Elastic Beanstalk which need to have permissions for the SQS and Dynamo DB.

I have created a profile under ~/.aws/config file like this:

```<code>[profile yolo]
aws_access_key_id = some-key
aws_secret_access_key = some-secret
region = some-region
</code>```

and also started the elastic beanstalk like:

```<code>eb init --profile yolo
</code>```

but when I check the logs online it states:

```<code>botocore.exceptions.ProfileNotFound: The config profile (yolo) could not be found
</code>```

How do I get the boto3 to know this profile on elastic beanstalk environment?

Thanks.

答: You will also get this error if AWS_DEFAULT_PROFILE environment variable is set, but no config file is present.</p>

Body:
I am trying to run a python application on an Elastic Beanstalk which need to have permissions for the SQS and Dynamo DB.

I have created a profile under ~/.aws/config file like this:

[profile yolo]
aws_access_key_id = some-key
aws_secret_access_key = some-secret
region = some-region

and also started the elastic beanstalk like:

eb init --profile yolo

but when I check the logs online it states:

botocore.exceptions.ProfileNotFound: The config profile (yolo) could not be found

How do I get the boto3 to know this profile on elastic beanstalk environment?

Thanks.


问:
Docker - Change the owner of a file for a container in Windows
I have the following simple Docker file:

```<code>FROM php:5.6-apache

RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 777 /var/www/html

VOLUME /var/www/html

CMD ["apache2-foreground"]
</code>```

I run it using docker-compose with the following docker-compose.yml file:

```<code>version: '2'
services:
  foo:
    image: image_name
    volumes:
      - "./:/var/www/html"
    ports:
      - "8080:80"
    restart: always
</code>```

I then connected to the container like so:

```<code>docker exec -it container_name_foo_1 bash
</code>```

When I run ls -l on the /var/www/html directory I get something like this:

```<code>total 0
drwxrwxrwx 1 1000 staff 0 Aug  6 20:38 hi
</code>```

However when I try to change the owner of this file like so:

```<code>chown www-data:www-data hi
</code>```

and the run ls -l again; the owner has not changed!

I believe this may be a Windows only problem.

I mentioned a similar issue here: Change the owner of a file in a running Docker container with an attached volume in Windows, which is still unanswered. (This question is slightly different as this question deals with DockerFile rather than an already running Docker container).

From reading other Stack Overflow answers, I was told to change the permissions before mounting the volume in the Docker file (which I did), but did not work.

答:
Have you tried this?</p>

```<code>docker exec -u root -it container_name_foo_1 chown other:user -R /path
</code>```

Body:
I have the following simple Docker file:

FROM php:5.6-apache

RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 777 /var/www/html

VOLUME /var/www/html

CMD ["apache2-foreground"]

I run it using docker-compose with the following docker-compose.yml file:

version: '2'
services:
  foo:
    image: image_name
    volumes:
      - "./:/var/www/html"
    ports:
      - "8080:80"
    restart: always

I then connected to the container like so:

docker exec -it container_name_foo_1 bash

When I run ls -l on the /var/www/html directory I get something like this:

total 0
drwxrwxrwx 1 1000 staff 0 Aug  6 20:38 hi

However when I try to change the owner of this file like so:

chown www-data:www-data hi

and the run ls -l again; the owner has not changed!

I believe this may be a Windows only problem.

I mentioned a similar issue here: Change the owner of a file in a running Docker container with an attached volume in Windows, which is still unanswered. (This question is slightly different as this question deals with DockerFile rather than an already running Docker container).

From reading other Stack Overflow answers, I was told to change the permissions before mounting the volume in the Docker file (which I did), but did not work.

Body:
Have you tried this?

docker exec -u root -it container_name_foo_1 chown other:user -R /path