问:
Tomcat error 404 "did not find a matching property"
I have an error when I deploy my java application in Tom Cat. When I run as choosing the server, it give me "HTTP Status 404" with these warnings:

nov 30, 2016 2:07:22 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FoodDrinkDispener' did not find a matching property.
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server version:        Apache Tomcat/8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server built:          Mar 18 2016 20:31:49 UTC
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server number:         8.0.33.0
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: OS Name:               Windows 8.1
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: OS Version:            6.3
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Architecture:          amd64
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Java Home:             C:\Program Files\Java\jdk1.8.0_51\jre
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: JVM Version:           1.8.0_51-b16
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: JVM Vendor:            Oracle Corporation
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: CATALINA_BASE:         C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: CATALINA_HOME:         C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dcatalina.base=C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dcatalina.home=C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dwtp.deploy=C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5\wtpwebapps
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Djava.endorsed.dirs=C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33\endorsed
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dfile.encoding=Cp1252
nov 30, 2016 2:07:22 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAZIONI: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_51\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_51/bin/server;C:/Program Files/Java/jre1.8.0_51/bin;C:/Program Files/Java/jre1.8.0_51/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\MATLAB\R2014a\runtime\win64;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files\MATLAB\R2014a\polyspace\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Python27\;C:\Program Files\nodejs\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files (x86)\Brackets\command;C:\Ruby23-x64\bin;C:\Users\Giacomo B\AppData\Roaming\npm;C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\eclipse;;.
nov 30, 2016 2:07:22 AM org.apache.coyote.AbstractProtocol init
INFORMAZIONI: Initializing ProtocolHandler ["http-nio-8080"]
nov 30, 2016 2:07:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAZIONI: Using a shared selector for servlet write/read
nov 30, 2016 2:07:22 AM org.apache.coyote.AbstractProtocol init
INFORMAZIONI: Initializing ProtocolHandler ["ajp-nio-8009"]
nov 30, 2016 2:07:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAZIONI: Using a shared selector for servlet write/read
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.Catalina load
INFORMAZIONI: Initialization processed in 474 ms
nov 30, 2016 2:07:22 AM org.apache.catalina.core.StandardService startInternal
INFORMAZIONI: Starting service Catalina
nov 30, 2016 2:07:22 AM org.apache.catalina.core.StandardEngine startInternal
INFORMAZIONI: Starting Servlet Engine: Apache Tomcat/8.0.33
nov 30, 2016 2:07:23 AM org.apache.jasper.servlet.TldScanner scanJars
INFORMAZIONI: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFORMAZIONI: Scanning for root resource and provider classes in the packages:
  it.jack.fdd.controller
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFORMAZIONI: Root resource classes found:
  class it.jack.fdd.controller.CountryController
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFORMAZIONI: No provider classes found.
nov 30, 2016 2:07:23 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFORMAZIONI: Initiating Jersey application, version 'Jersey: 1.18.3 12/01/2014 08:23 AM'
nov 30, 2016 2:07:24 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-nio-8080"]
nov 30, 2016 2:07:24 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-nio-8009"]
nov 30, 2016 2:07:24 AM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 2000 ms```
</div>
</div>
</p>

<p>in particular I think that my problem is <code>AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FoodDrinkDispener' did not find a matching property.
</code>
In fact I searched on internet and I found several possible solutions, such as:</p>

<blockquote>
  <p>Remove the project from the server from the Server View. Right click on server -> add and remove, Then run the project under the same server.
  Or if warning still remains then
  Go to server view
  Double click on your tomcat server. It will open the server configuration.
  Under server options check ‘Publish module contents to separate XML files’ checkbox.
  Restart your server. This time your page will come without any issues.
  Read more http://www.java2blog.com/2016/03/restful-web-services-jaxrs-crud-example.html</p>
</blockquote>

<p>But this does not solve the problem. I spent several hours to search to fix it, but nothing.
This is my pom.xml:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><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>
  <groupId>it.jack.fdd</groupId>
  <artifactId>FoodDrinkDispener</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>FoodDrinkDispener Maven Webapp</name>
  <url>http://maven.apache.org</url>
   <properties>
        <jersey.version>1.18.3</jersey.version>
    </properties>
 <dependencies>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.5.Final</version>
   </dependency>
   <!-- Hibernate uses slf4j for logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.0.5</version>
        </dependency>

  <dependency>
   <groupId>com.sun.jersey</groupId>
   <artifactId>jersey-servlet</artifactId>
   <version>${jersey.version}</version>
  </dependency>
  <dependency>
   <groupId>com.sun.jersey</groupId>
   <artifactId>jersey-json</artifactId>
   <version>${jersey.version}</version>
  </dependency>

  <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.2</version>
  </dependency>
 </dependencies>
 <build>
  <finalName>FoodDrinkDispener</finalName>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
     <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
   </plugin>
  </plugins>
 </build>

</project></code>```

This is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 version="3.0">
 <display-name>Archetype Created Web Application</display-name>
 <servlet>
  <servlet-name>jersey-serlvet</servlet-name>
  <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
   <param-name>com.sun.jersey.config.property.packages</param-name>
   <param-value>it.jack.fdd.controller</param-value>
  </init-param>
  <init-param>
   <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
   <param-value>true</param-value>
  </init-param>

  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>jersey-serlvet</servlet-name>
  <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
</web-app>  ```
</div>
</div>
</p>

<p>And this is my server configurations: (server.xml)</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 --><Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->

    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine defaultHost="localhost" name="Catalina">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>

     <!--   <Context docBase="JAXRSJsonCRUDExample" path="/JAXRSJsonExample" reloadable="true" source="org.eclipse.jst.jee.server:JAXRSJsonCRUDExample"/><Context docBase="helloworld" path="/helloworld" reloadable="true" source="org.eclipse.jst.jee.server:helloworld"/>   -->

     <!--   <Context docBase="FoodDrinkDispener" path="/JAXRSJsonExample" reloadable="true" source="org.eclipse.jst.jee.server:FoodDrinkDispener"/>  -->
 <!--     <Context docBase="FoodDrinkDispener" path="/FoodDrinkDispener" reloadable="true" source="org.eclipse.jst.jee.server:FoodDrinkDispener"/>  -->
     <Context docBase="FoodDrinkDispener" path="/FoodDrinkDispener" reloadable="true" source="org.eclipse.jst.jee.server:FoodDrinkDispener"/></Host>
          </Engine>
  </Service>
</Server></code>```

I whish that someone can help me to fix this error.

答: The problem is with the html file, try to change your html file name to index.html so the server will understand it.

Body:
I have an error when I deploy my java application in Tom Cat. When I run as choosing the server, it give me "HTTP Status 404" with these warnings:

nov 30, 2016 2:07:22 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FoodDrinkDispener' did not find a matching property.
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server version:        Apache Tomcat/8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server built:          Mar 18 2016 20:31:49 UTC
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Server number:         8.0.33.0
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: OS Name:               Windows 8.1
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: OS Version:            6.3
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Architecture:          amd64
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Java Home:             C:\Program Files\Java\jdk1.8.0_51\jre
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: JVM Version:           1.8.0_51-b16
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: JVM Vendor:            Oracle Corporation
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: CATALINA_BASE:         C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: CATALINA_HOME:         C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dcatalina.base=C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dcatalina.home=C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dwtp.deploy=C:\Users\Giacomo B\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp5\wtpwebapps
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Djava.endorsed.dirs=C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\apache-tomcat-8.0.33\endorsed
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMAZIONI: Command line argument: -Dfile.encoding=Cp1252
nov 30, 2016 2:07:22 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAZIONI: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_51\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_51/bin/server;C:/Program Files/Java/jre1.8.0_51/bin;C:/Program Files/Java/jre1.8.0_51/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\MATLAB\R2014a\runtime\win64;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files\MATLAB\R2014a\polyspace\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Python27\;C:\Program Files\nodejs\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files (x86)\Brackets\command;C:\Ruby23-x64\bin;C:\Users\Giacomo B\AppData\Roaming\npm;C:\Users\Giacomo B\Desktop\Appunti su ingegneria\Computer Engineering\2015-2016\Ingegneria del sw\eclipse;;.
nov 30, 2016 2:07:22 AM org.apache.coyote.AbstractProtocol init
INFORMAZIONI: Initializing ProtocolHandler ["http-nio-8080"]
nov 30, 2016 2:07:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAZIONI: Using a shared selector for servlet write/read
nov 30, 2016 2:07:22 AM org.apache.coyote.AbstractProtocol init
INFORMAZIONI: Initializing ProtocolHandler ["ajp-nio-8009"]
nov 30, 2016 2:07:22 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAZIONI: Using a shared selector for servlet write/read
nov 30, 2016 2:07:22 AM org.apache.catalina.startup.Catalina load
INFORMAZIONI: Initialization processed in 474 ms
nov 30, 2016 2:07:22 AM org.apache.catalina.core.StandardService startInternal
INFORMAZIONI: Starting service Catalina
nov 30, 2016 2:07:22 AM org.apache.catalina.core.StandardEngine startInternal
INFORMAZIONI: Starting Servlet Engine: Apache Tomcat/8.0.33
nov 30, 2016 2:07:23 AM org.apache.jasper.servlet.TldScanner scanJars
INFORMAZIONI: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFORMAZIONI: Scanning for root resource and provider classes in the packages:
  it.jack.fdd.controller
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFORMAZIONI: Root resource classes found:
  class it.jack.fdd.controller.CountryController
nov 30, 2016 2:07:23 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFORMAZIONI: No provider classes found.
nov 30, 2016 2:07:23 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFORMAZIONI: Initiating Jersey application, version 'Jersey: 1.18.3 12/01/2014 08:23 AM'
nov 30, 2016 2:07:24 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-nio-8080"]
nov 30, 2016 2:07:24 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-nio-8009"]
nov 30, 2016 2:07:24 AM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 2000 ms

in particular I think that my problem is AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FoodDrinkDispener' did not find a matching property.

In fact I searched on internet and I found several possible solutions, such as:

Remove the project from the server from the Server View. Right click on server -> add and remove, Then run the project under the same server.
  Or if warning still remains then
  Go to server view
  Double click on your tomcat server. It will open the server configuration.
  Under server options check ‘Publish module contents to separate XML files’ checkbox.
  Restart your server. This time your page will come without any issues.
  Read more http://www.java2blog.com/2016/03/restful-web-services-jaxrs-crud-example.html

But this does not solve the problem. I spent several hours to search to fix it, but nothing.
This is my pom.xml:

<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>
  <groupId>it.jack.fdd</groupId>
  <artifactId>FoodDrinkDispener</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>FoodDrinkDispener Maven Webapp</name>
  <url>http://maven.apache.org</url>
   <properties>
        <jersey.version>1.18.3</jersey.version>
    </properties>
 <dependencies>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.5.Final</version>
   </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.0.5</version>
        </dependency>

  <dependency>
   <groupId>com.sun.jersey</groupId>
   <artifactId>jersey-servlet</artifactId>
   <version>${jersey.version}</version>
  </dependency>
  <dependency>
   <groupId>com.sun.jersey</groupId>
   <artifactId>jersey-json</artifactId>
   <version>${jersey.version}</version>
  </dependency>

  <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.2</version>
  </dependency>
 </dependencies>
 <build>
  <finalName>FoodDrinkDispener</finalName>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
     <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
   </plugin>
  </plugins>
 </build>

</project>

This is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 version="3.0">
 <display-name>Archetype Created Web Application</display-name>
 <servlet>
  <servlet-name>jersey-serlvet</servlet-name>
  <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
   <param-name>com.sun.jersey.config.property.packages</param-name>
   <param-value>it.jack.fdd.controller</param-value>
  </init-param>
  <init-param>
   <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
   <param-value>true</param-value>
  </init-param>

  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>jersey-serlvet</servlet-name>
  <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
</web-app>

And this is my server configurations: (server.xml)

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>

  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

  <GlobalNamingResources>

    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <Service name="Catalina">

    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

    <Engine defaultHost="localhost" name="Catalina">

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>

     <Context docBase="FoodDrinkDispener" path="/FoodDrinkDispener" reloadable="true" source="org.eclipse.jst.jee.server:FoodDrinkDispener"/></Host>
          </Engine>
  </Service>
</Server>

I whish that someone can help me to fix this error.


来源: stackexchange

问:
SQL code to calculate purchase invoice descrepencies
I am looking to extract records with purchase invoice discrepancies from Purchase Invoice Line [PIL], Purchase Invoice header [PIH] and Purchase line [PL], and purchase header [PH] tables.

Do I really need to take any columns from PL AND PH at all or is it sufficient if I make use of only PIH AND PIL tables? And how to cross verify the result set at the end?

Thanks

答:
To identify discrepancies you need to compare your purchase orders with your invoices.  There's no way to compare an invoice with its purchase order without reading its purchase order.  So yes you need to read from PL and PH.

Having worked on professional systems which do exactly this task I can say it tends to be more complicated.  Usually the user will set acceptable limits on which discrepancies need to be flagged.

For example some companies will pay an invoice and never flag a discrepancy as long as the invoice total does not exceed the PO total.  In those cases you don't need to look at the line  PO / Invoice line level, just the header level.

ContentLicense: CC BY-SA 3.0


问:
Checking class of all columns in data.frame
Why apply doesn't work?

Look at this:

```<code>apply(diamonds, 2, class)["carat"]
#      carat
# "character"

class(diamonds$carat)
# [1] "numeric"
</code>```

:O

答:
You are looking for lapply(diamonds, class)

Also apply still worked , but the result is not right, it will return all type to character. look into the link

apply works on arrays/matrices, not data.frames.
when you using it in data.frame  it will convert to matrix.

Body:
Why apply doesn't work?

Look at this:

apply(diamonds, 2, class)["carat"]
#      carat
# "character"

class(diamonds$carat)
# [1] "numeric"

:O


问:
C-like structures in Python
Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:</p>

```<code>class MyStruct():
    def __init__(self, field1, field2, field3):
        self.field1 = field1
        self.field2 = field2
        self.field3 = field3
</code>```

答:
I think Python structure dictionary is suitable for this requirement.

d = dict{}
d[field1] = field1
d[field2] = field2
d[field2] = field3
```

OwnerDisplayName: wesc

Title: C-like structures in Python

Body:
Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:

class MyStruct():
    def __init__(self, field1, field2, field3):
        self.field1 = field1
        self.field2 = field2
        self.field3 = field3


问:
Layout view is in top left corner in emulator
Constraint layout is not well placed. It always views on top left corner, but in design view it shows in the whole display. I want to display the app in full screen mode.

This is a screenshot of what's happening:

答: Try to change width of RelativeLayout to match_parent and set layout_gravity to bottom


问:
if there is any close button is available in android?
"x" button is available or not in android,if no instead of that what button is used?</p>

答: Please read Multitasking the Android Way - I had a close menu in my Apps and I removed them after reading the article. As others pointed out: you should not have a close button or close menu in Android. </p>

ContentLicense: CC BY-SA 2.5


问:
Why am I getting this error “ValueError: Wrong number of items passed 2, placement implies 4” even the code is fine?
I am using this code and it gives me this error, ValueError: Wrong number of items passed 2, placement implies 4. It is supposed to print the mean, median and mode in a csv file by using the data from the other csv file. When I use this code it prints mean and median to a specified csv file but it does not print the mode. This is the code I am using(below).

```<code>import pandas as pd
df = pd.read_csv('one_hello.csv', names=['teacher', 'student',\
         's.grade', 't.average','t.median','t.mode'])

df['Star Rating'] = df['Star Rating'].astype(int) #convert to integer.

df['t.mean'] = df.groupby('teacher')['s.grade'].transform('mean')
df['t.median'] = df.groupby('teacher')['s.grade'].transform('median')
df['t.mode'] = df.groupby('teacher')['s.grade'].transform(lambda group: group.mode())
df.to_csv('two_hello.csv') #write to file
</code>```

File 'test_one' looks like this:

```<code>teacher         student         student grade
Jon             marin           99
Jon             Rob             81
Jon             marly           90
Jon             Ticy            90
Bon             lue             76
Bon             martin          76
Bon             marie           56
Ton             Seri            43
Ton             Loku            99
</code>```

I want the file "test_two" to look like this:

```<code>teacher         student         s.grade    t.avg    t.median    t.mode
Jon             marin           99          90         90           90
Jon             Rob             81          90          90          90
Jon             marly           90          90          90          90
Jon             Ticy            90          90          90          90
Bon             lue             76          69.3        76          76
Bon             martin          76          69.3        76          76
Bon             marie           56          69.3        76          76
Ton             Seri            43          69.3        71          43
Ton             Loku            99          69.3        71          99
</code>```

But, it only prints 'mean' and 'median' on the other file and gives me error like this.

```<code>`Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/groupby.py", line 3049, in transform
    s = klass(res, indexer)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/series.py", line 250, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 4117, in __init__
    fastpath=True)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 2719, in make_block
    return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 115, in __init__
    len(self.mgr_locs)))
ValueError: Wrong number of items passed 2, placement implies 4`
</code>```

答:
Assuming the one_hello.csv is test_one and Star Rating is s.grade this should work. I only changed the column name mapping in read_csv() to match the source file:

```<code>import io
import pandas as pd

source = io.StringIO("""
Jon, marin, 99
Jon, Rob, 81
Jon, marly, 90
Jon, Ticy, 90
Bon, lue, 76
Bon, martin, 76
Bon, marie, 56
Ton, Seri, 43
Ton, Loku, 99
""")

df = pd.read_csv(source, names=['teacher', 'student', 's.grade'], dtype={'s.grade': int})
df['t.mean'] = df.groupby('teacher')['s.grade'].transform('mean')
df['t.median'] = df.groupby('teacher')['s.grade'].transform('median')
df['t.mode'] = df.groupby('teacher')['s.grade'].transform(lambda group: group.mode())
df.to_csv('out.csv')
print(df)
</code>```

Output:

```<code>  teacher  student  s.grade     t.mean  t.median  t.mode
0     Jon    marin       99  90.000000        90      90
1     Jon      Rob       81  90.000000        90      90
2     Jon    marly       90  90.000000        90      90
3     Jon     Ticy       90  90.000000        90      90
4     Bon      lue       76  69.333333        76      76
5     Bon   martin       76  69.333333        76      76
6     Bon    marie       56  69.333333        76      76
7     Ton     Seri       43  71.000000        71      43
8     Ton     Loku       99  71.000000        71      99
</code>```

Body:
I am using this code and it gives me this error, ValueError: Wrong number of items passed 2, placement implies 4. It is supposed to print the mean, median and mode in a csv file by using the data from the other csv file. When I use this code it prints mean and median to a specified csv file but it does not print the mode. This is the code I am using(below).

import pandas as pd
df = pd.read_csv('one_hello.csv', names=['teacher', 'student',\
         's.grade', 't.average','t.median','t.mode'])

df['Star Rating'] = df['Star Rating'].astype(int) #convert to integer.

df['t.mean'] = df.groupby('teacher')['s.grade'].transform('mean')
df['t.median'] = df.groupby('teacher')['s.grade'].transform('median')
df['t.mode'] = df.groupby('teacher')['s.grade'].transform(lambda group: group.mode())
df.to_csv('two_hello.csv') #write to file

File 'test_one' looks like this:

teacher         student         student grade
Jon             marin           99
Jon             Rob             81
Jon             marly           90
Jon             Ticy            90
Bon             lue             76
Bon             martin          76
Bon             marie           56
Ton             Seri            43
Ton             Loku            99

I want the file "test_two" to look like this:

teacher         student         s.grade    t.avg    t.median    t.mode
Jon             marin           99          90         90           90
Jon             Rob             81          90          90          90
Jon             marly           90          90          90          90
Jon             Ticy            90          90          90          90
Bon             lue             76          69.3        76          76
Bon             martin          76          69.3        76          76
Bon             marie           56          69.3        76          76
Ton             Seri            43          69.3        71          43
Ton             Loku            99          69.3        71          99

But, it only prints 'mean' and 'median' on the other file and gives me error like this.

`Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/groupby.py", line 3049, in transform
    s = klass(res, indexer)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/series.py", line 250, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 4117, in __init__
    fastpath=True)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 2719, in make_block
    return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 115, in __init__
    len(self.mgr_locs)))
ValueError: Wrong number of items passed 2, placement implies 4`

Body:
Assuming the one_hello.csv is test_one and Star Rating is s.grade this should work. I only changed the column name mapping in read_csv() to match the source file:

import io
import pandas as pd

source = io.StringIO("""
Jon, marin, 99
Jon, Rob, 81
Jon, marly, 90
Jon, Ticy, 90
Bon, lue, 76
Bon, martin, 76
Bon, marie, 56
Ton, Seri, 43
Ton, Loku, 99
""")

df = pd.read_csv(source, names=['teacher', 'student', 's.grade'], dtype={'s.grade': int})
df['t.mean'] = df.groupby('teacher')['s.grade'].transform('mean')
df['t.median'] = df.groupby('teacher')['s.grade'].transform('median')
df['t.mode'] = df.groupby('teacher')['s.grade'].transform(lambda group: group.mode())
df.to_csv('out.csv')
print(df)

Output:

  teacher  student  s.grade     t.mean  t.median  t.mode
0     Jon    marin       99  90.000000        90      90
1     Jon      Rob       81  90.000000        90      90
2     Jon    marly       90  90.000000        90      90
3     Jon     Ticy       90  90.000000        90      90
4     Bon      lue       76  69.333333        76      76
5     Bon   martin       76  69.333333        76      76
6     Bon    marie       56  69.333333        76      76
7     Ton     Seri       43  71.000000        71      43
8     Ton     Loku       99  71.000000        71      99


问:
Align SpriteNode with surface on collision SpriteKit Swift3
Im trying to align a SKSpriteNode to match the "hit surface" of a PhysicsBody on collision.

What I'm doing is to shoot the SpriteNode at a Cube. I have setup the collision and the node attachment (fixed joint).
Everything works but I need to find a way to rotate the spriteNode to match the hit surface as you can see below:

Note that the Cube can rotate etc so we don't always have a fixed rotation value on the Cube.

Any Ideas how to solve this?

Thanks in advance
/Magnus

答:
Here is most of the answer that I think will work. I will update it later.

Basically, the goal is to place two sticky nodes to the magnet and to the cube respectively at the contacted point.

Then, you match the magnet's zRotation to the cube's rotation, and then align the magnet to the cube based on the position of the two sticky nodes.

I haven't done the rotation matching or sticky alignment, but everything else is here if you want to finish it until I get to later:

```<code>// Props:
class GameScene: SKScene, SKPhysicsContactDelegate {

  struct Category {
    static let
    border = UInt32(2),
    cube = UInt32(4),
    magnet = UInt32(8)
  }

  let names = (border: "border", cube: "cube", magnet: "magnet", stickyPoint: "stickyPoint")

  var flag_hitThisSimulation = false
}

// Setup:
extension GameScene {

  private func setupNodes() {
    border: do {
      let pb = SKPhysicsBody(edgeLoopFrom: frame)
      pb.categoryBitMask = Category.border
      physicsBody = pb
    }
    cube: do {
      let cubeNode = SKSpriteNode(color: .blue, size: CGSize(width: 150, height: 150))
      let pb = SKPhysicsBody(rectangleOf: cubeNode.size)
      pb.affectedByGravity = false
      pb.isDynamic = false
      pb.categoryBitMask = Category.cube
      pb.contactTestBitMask = Category.magnet
      cubeNode.physicsBody = pb
      cubeNode.position.y += 200
      cubeNode.name = names.cube
      cubeNode.run(.repeatForever(.rotate(byAngle: 3.14, duration: 3)))
      addChild(cubeNode)
    }
    magnet: do {
      let magnetNode = SKSpriteNode(color: .green, size: CGSize(width: 50, height: 12))
      let pb = SKPhysicsBody(rectangleOf: magnetNode.size)
      pb.categoryBitMask = Category.magnet
      pb.affectedByGravity = false
      magnetNode.physicsBody = pb
      magnetNode.name = names.magnet
      addChild(magnetNode)
    }
  }

  override func didMove(to view: SKView) {

    removeAllChildren()
    physicsWorld.contactDelegate = self
    setupNodes()

  }
}

// Physics:
extension GameScene {

  private func assignNodeOfName(_ name: String, contact: SKPhysicsContact) -> SKNode? {
    guard let nodeA = contact.bodyA.node, let nodeB = contact.bodyB.node else { fatalError("how are there no nodes?") }
    if      nodeA.name == name { return nodeA }
    else if nodeB.name == name { return nodeB }
    else                       { return nil   }
  }

  private func addNodeToPoint(_ point: CGPoint, parent: SKNode) {
    let node = SKSpriteNode(color: .orange, size: CGSize(width: 5, height: 5))
    node.position = point
    node.name = names.stickyPoint
    parent.addChild(node)
  }

  func alignMagnetToCube() {

  }

  func didBegin(_ contact: SKPhysicsContact) {
    defer { flag_hitThisSimulation = true }
    if flag_hitThisSimulation { return }

    let contactedNodes = contact.bodyA.categoryBitMask + contact.bodyB.categoryBitMask

    switch contactedNodes {

    case Category.magnet + Category.cube:
      // Place the two sticky nodes:
      let cube   = assignNodeOfName(names.cube,   contact: contact)!
      let magnet = assignNodeOfName(names.magnet, contact: contact)!

      let cubePoint   = convert(contact.contactPoint, to: cube)
      let magnetPoint = convert(contact.contactPoint, to: magnet)

      addNodeToPoint(cubePoint,   parent: cube)
      addNodeToPoint(magnetPoint, parent: magnet)

      // Set the magnet's zRotation to the cube's zRotation, then align the two stickyNodes:
      // fluidity.SLEEPY(for: now)
      // finish.later()

    default: ()
    }
  }
}

// Game loop:
extension GameScene {

  // Change to touchesBegan for iOS:
  override func mouseDown(with event: NSEvent) {

    let magnet = childNode(withName: names.magnet) as! SKSpriteNode

    // Start simulation:
    magnet.removeAllActions()
    magnet.physicsBody!.applyImpulse(CGVector(dx: 0, dy: 25))

    // End simulation:
    magnet.run(.wait(forDuration: 2)) {
      print("resetting simulation! \(event.timestamp)")
      magnet.physicsBody!.velocity = CGVector.zero
      magnet.zRotation = 0 // FIXME: This isn't working..
      magnet.position = CGPoint.zero
      self.flag_hitThisSimulation = false

      // Remove sticky nodes:
      for node in self.children {
        for childNode in node.children {
          if childNode.name == self.names.stickyPoint { childNode.removeFromParent() }
        }
      }
    }
  }
}
</code>```

Body:
Here is most of the answer that I think will work. I will update it later.

Basically, the goal is to place two sticky nodes to the magnet and to the cube respectively at the contacted point.

Then, you match the magnet's zRotation to the cube's rotation, and then align the magnet to the cube based on the position of the two sticky nodes.

I haven't done the rotation matching or sticky alignment, but everything else is here if you want to finish it until I get to later:

// Props:
class GameScene: SKScene, SKPhysicsContactDelegate {

  struct Category {
    static let
    border = UInt32(2),
    cube = UInt32(4),
    magnet = UInt32(8)
  }

  let names = (border: "border", cube: "cube", magnet: "magnet", stickyPoint: "stickyPoint")

  var flag_hitThisSimulation = false
}

// Setup:
extension GameScene {

  private func setupNodes() {
    border: do {
      let pb = SKPhysicsBody(edgeLoopFrom: frame)
      pb.categoryBitMask = Category.border
      physicsBody = pb
    }
    cube: do {
      let cubeNode = SKSpriteNode(color: .blue, size: CGSize(width: 150, height: 150))
      let pb = SKPhysicsBody(rectangleOf: cubeNode.size)
      pb.affectedByGravity = false
      pb.isDynamic = false
      pb.categoryBitMask = Category.cube
      pb.contactTestBitMask = Category.magnet
      cubeNode.physicsBody = pb
      cubeNode.position.y += 200
      cubeNode.name = names.cube
      cubeNode.run(.repeatForever(.rotate(byAngle: 3.14, duration: 3)))
      addChild(cubeNode)
    }
    magnet: do {
      let magnetNode = SKSpriteNode(color: .green, size: CGSize(width: 50, height: 12))
      let pb = SKPhysicsBody(rectangleOf: magnetNode.size)
      pb.categoryBitMask = Category.magnet
      pb.affectedByGravity = false
      magnetNode.physicsBody = pb
      magnetNode.name = names.magnet
      addChild(magnetNode)
    }
  }

  override func didMove(to view: SKView) {

    removeAllChildren()
    physicsWorld.contactDelegate = self
    setupNodes()

  }
}

// Physics:
extension GameScene {

  private func assignNodeOfName(_ name: String, contact: SKPhysicsContact) -> SKNode? {
    guard let nodeA = contact.bodyA.node, let nodeB = contact.bodyB.node else { fatalError("how are there no nodes?") }
    if      nodeA.name == name { return nodeA }
    else if nodeB.name == name { return nodeB }
    else                       { return nil   }
  }

  private func addNodeToPoint(_ point: CGPoint, parent: SKNode) {
    let node = SKSpriteNode(color: .orange, size: CGSize(width: 5, height: 5))
    node.position = point
    node.name = names.stickyPoint
    parent.addChild(node)
  }

  func alignMagnetToCube() {

  }

  func didBegin(_ contact: SKPhysicsContact) {
    defer { flag_hitThisSimulation = true }
    if flag_hitThisSimulation { return }

    let contactedNodes = contact.bodyA.categoryBitMask + contact.bodyB.categoryBitMask

    switch contactedNodes {

    case Category.magnet + Category.cube:
      // Place the two sticky nodes:
      let cube   = assignNodeOfName(names.cube,   contact: contact)!
      let magnet = assignNodeOfName(names.magnet, contact: contact)!

      let cubePoint   = convert(contact.contactPoint, to: cube)
      let magnetPoint = convert(contact.contactPoint, to: magnet)

      addNodeToPoint(cubePoint,   parent: cube)
      addNodeToPoint(magnetPoint, parent: magnet)

      // Set the magnet's zRotation to the cube's zRotation, then align the two stickyNodes:
      // fluidity.SLEEPY(for: now)
      // finish.later()

    default: ()
    }
  }
}

// Game loop:
extension GameScene {

  // Change to touchesBegan for iOS:
  override func mouseDown(with event: NSEvent) {

    let magnet = childNode(withName: names.magnet) as! SKSpriteNode

    // Start simulation:
    magnet.removeAllActions()
    magnet.physicsBody!.applyImpulse(CGVector(dx: 0, dy: 25))

    // End simulation:
    magnet.run(.wait(forDuration: 2)) {
      print("resetting simulation! \(event.timestamp)")
      magnet.physicsBody!.velocity = CGVector.zero
      magnet.zRotation = 0 // FIXME: This isn't working..
      magnet.position = CGPoint.zero
      self.flag_hitThisSimulation = false

      // Remove sticky nodes:
      for node in self.children {
        for childNode in node.children {
          if childNode.name == self.names.stickyPoint { childNode.removeFromParent() }
        }
      }
    }
  }
}


问:
Empty soup.findAll
Beautiful Soup won't work as expected on this page. I need to get the table.

```<code>    page2="http://www.moneycontrol.com/stocks/marketinfo/marketcap/bse/banks-private-sector.html"
    soup2 = BeautifulSoup(page2.content,"lxml")
    for tablerow in soup2.findAll('td',class_="brdrgtgry"):
        print(tablerow.text)
</code>```

Regards,
babsdoc

答:
Don't know what the rest of your code is doing, but the snippet that you've posted won't work. You would need to actually retrieve the page first.

so, adding

```<code>import requests
</code>```

and

```<code>soup2 = BeautifulSoup(requests.get(page2).content, "lxml")
</code>```

to your snippet allows me to yield

```<code>HDFC Bank

Add to Watchlist
Add to Portfolio

1,665.35
0.40
1,715.60
1,193.45
427,147.14
ICICI Bank
</code>```

etc.

Title: Empty soup.findAll

Body:
Beautiful Soup won't work as expected on this page. I need to get the table.

    page2="http://www.moneycontrol.com/stocks/marketinfo/marketcap/bse/banks-private-sector.html"
    soup2 = BeautifulSoup(page2.content,"lxml")
    for tablerow in soup2.findAll('td',class_="brdrgtgry"):
        print(tablerow.text)

Regards,
babsdoc

Body:
Don't know what the rest of your code is doing, but the snippet that you've posted won't work. You would need to actually retrieve the page first.

so, adding

import requests

and

soup2 = BeautifulSoup(requests.get(page2).content, "lxml")

to your snippet allows me to yield

HDFC Bank

Add to Watchlist
Add to Portfolio

1,665.35
0.40
1,715.60
1,193.45
427,147.14
ICICI Bank

etc.


问:
MySQL simple select statement, create auto increament if row value different then previous one
I have the following query so far:

```<code>SET @cnt = 0;
SELECT (
  @cnt := @cnt +1
) AS rowNumber, brand
FROM  `cars`
</code>```

which outputs me the following:

```<code>rowNumber | brand
1         | fiat
2         | fiat
3         | fiat
4         | bmw
5         | bmw
6         | mercedes
7         | mercedes
8         | tesla
9         | tesla
</code>```

however I want to achieve:

```<code>rowNumber | brand
1         | fiat
1         | fiat
1         | fiat
2         | bmw
2         | bmw
3         | mercedes
3         | mercedes
4         | tesla
4         | tesla
</code>```

how can I achieve this?

答:
You can do this using another variables:</p>

```<code>select (@rn := if(@b = brand, @rn,
                  if(@b := brand, @rn + 1, @rn + 1)
                 )
       ) as rowNumber, brand
from `cars` c cross join
     (select @b := '', @rn := 0) params
order by brand;
</code>```

Body:
I have the following query so far:

SET @cnt = 0;
SELECT (
  @cnt := @cnt +1
) AS rowNumber, brand
FROM  `cars`

which outputs me the following:

rowNumber | brand
1         | fiat
2         | fiat
3         | fiat
4         | bmw
5         | bmw
6         | mercedes
7         | mercedes
8         | tesla
9         | tesla

however I want to achieve:

rowNumber | brand
1         | fiat
1         | fiat
1         | fiat
2         | bmw
2         | bmw
3         | mercedes
3         | mercedes
4         | tesla
4         | tesla

how can I achieve this?

Body:
You can do this using another variables:

select (@rn := if(@b = brand, @rn,
                  if(@b := brand, @rn + 1, @rn + 1)
                 )
       ) as rowNumber, brand
from `cars` c cross join
     (select @b := '', @rn := 0) params
order by brand;


问:
How to scale aws ec2 cluster based on java application memory
I have a java application which is deployed on aws ec2 cluster. I have auto scaling configured based on cpu usage but the problem is application is not CPU intensive but is IO intensive, CPU usage is 20% on an average, so when traffic increases it is not able to send all the messages in real time causing buffering. This is causing delay in arrival of messages in downstream systems.

How can i auto scale my cluster based on incoming traffic and heap usage of deployed application?

答:
You can create a bash script, running with cron, that collect the Java heap memory usage and incoming connections, and then sends the to cloudwatch custom metrics.

How to collect to memory and disk stats from AWS ec2 instances

Examples in Perl

And then Alert and Auto scale based on those custom metrics


问:
autodoc directive works locally but not on readthedocs
My repo is located on github here: https://github.com/AshleySetter/optoanalysis

And the docs are in https://github.com/AshleySetter/optoanalysis/tree/master/optoanalysis/docs

ReadTheDocs doesn't fail but the produced documentation (hosted here: https://optoanalysis.readthedocs.io/en/latest/) doesn't display the doc strings that should be produced by the ..autodoc:: command.

However it runs fine locally and displays the documentation when I open the build/html/index.html file.

On ReadTheDocs it looks like:

Whereas the locally built html file looks like so:

Why might this be?

答:
You have modules written in Cython and compiled to C. I think ReadTheDocs doesn't support C extensions. You have to protect you imports to be generated at ReadTheDocs.

Something like this:

```<code>import os
if 'READTHEDOCS' not in os.environ:
    import cython_generated_ext
</code>```

Body:
You have modules written in Cython and compiled to C. I think ReadTheDocs doesn't support C extensions. You have to protect you imports to be generated at ReadTheDocs.

Something like this:

import os
if 'READTHEDOCS' not in os.environ:
    import cython_generated_ext


问:
How to search locations by given a name in iPhone SDK?
I want to search by a name (String) and then get at least 10 matching locations with their longitude and latitude.

Let's say I type 'Jaipur' in my search bar, i need to request some map service and get 10 locations that start with 'Jaipur'.

It seems we cannot do this with Map Kit.

Could someone point me few little tips to get started. It seems Yahoo Maps return JSON with one value. Any API that I could use easily with JSON parsing and example request would be really helpful.

Thanks and Kind Regards,

答:
You can access the Google Api

http://maps.google.com/maps/geo?q=yourSearchName&output=xml

This will give details about that searchname provided. You can parse the xml and get latitude and longitude from that details.

The output can be in json and csv also.

Reference for Google Map API


问:
Receiving 'Expected a component class, got [objectObject]' error in react-native ios app
I cannot workout why this error is appearing (I actually don't even know what it means!)  Normally the red screen errors point to a file location but this doesn't although it points to the use of 'new' so I assume the issue is this file, as it was working up to this point:

```<code>import React, { Component } from 'react';
import { Text, View, StyleSheet, ListView } from 'react-native';
import { connect } from 'react-redux';
import PeopleItem from './PeopleItem';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    width: 353,
    flexWrap: 'wrap',
    paddingTop: 20,
    paddingLeft: 20,
  },
});

class PeopleList extends Component {
  componentWillMount() {
    const ds = new ListView.DataSource({
      rowHasChanged: (r1, r2) => r1 !== r2,
    });
    this.dataSource = ds.cloneWithRows(this.props.people);
  }
  render() {
    return (
      <View style={styles.container}>
        <ListView
          enableEmptySections={true}
          dataSource={this.dataSource}
          renderRow={(rowData) =>
            <PeopleItem people={rowData} />
          }
        />
      </View>
    );
  }
}

const mapStateToProps = state => {
  return { people: state.people };
};

export default connect(mapStateToProps)(PeopleList);
</code>```

答: Apologies, I didn't capitilize a  element in the file being called - that just cost me about 3hrs.</p>

Body:
I cannot workout why this error is appearing (I actually don't even know what it means!)  Normally the red screen errors point to a file location but this doesn't although it points to the use of 'new' so I assume the issue is this file, as it was working up to this point:

import React, { Component } from 'react';
import { Text, View, StyleSheet, ListView } from 'react-native';
import { connect } from 'react-redux';
import PeopleItem from './PeopleItem';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    width: 353,
    flexWrap: 'wrap',
    paddingTop: 20,
    paddingLeft: 20,
  },
});

class PeopleList extends Component {
  componentWillMount() {
    const ds = new ListView.DataSource({
      rowHasChanged: (r1, r2) => r1 !== r2,
    });
    this.dataSource = ds.cloneWithRows(this.props.people);
  }
  render() {
    return (
      <View style={styles.container}>
        <ListView
          enableEmptySections={true}
          dataSource={this.dataSource}
          renderRow={(rowData) =>
            <PeopleItem people={rowData} />
          }
        />
      </View>
    );
  }
}

const mapStateToProps = state => {
  return { people: state.people };
};

export default connect(mapStateToProps)(PeopleList);


问:
Residual plots for multiple imputation using mice package in R
With the mice package, how do we check for the residuals of the pooled analysis?

```<code>library(mice)
imp <- mice(nhanes, seed = 23109)
fit <- with(imp, lm(chl ~ age + bmi))
pool(fit)
summary(pool(fit))
</code>```

fit contains the analysis for each imputed dataset and pool(fit) the pooled results. Is there a command to check the residuals as for a standard lm object, something like plot(pool(fit))?

答:
I ran into the same problem and I resolved it with a quite exhaustive solution. I saved the residuals and fitted values for each separate imputed dataset. This works okay if you have only a limited amount of datasets, but will become more complicated if you have more datasets (I had 75, so my script became terrible long).
I will explain my solution based on an example with 5 imputed datasets: </p>

```<code> # Computing and saving the mean residual per individual over 5 imputed datasets
 RS1 <-residuals(model1$ana[[1]])+residuals(model1$ana[[2]])+residuals(model1$ana[[3]])+residuals(model1$ana[[4]])+residuals(model1$ana[[5]])
 RSmodel1 <- RS1 / 5
 # Computing and saving the mean predicted value per individual over 5 imputed datasets
 PS1 <-predict(model1$ana[[1]])+predict(model1$ana[[2]])+predict(model1$ana[[3]])+predict(model1$ana[[4]])+predict(model1$ana[[5]])
 PSmodel1 <- PS1 / 5
 # Creating the residual plot
 plot(RSmodel1, PSmodel1)
</code>```

<p>I hope this will help you!
I am very aware that my solution is quite inconvenient, but it will do the job :) </p>

Body:
With the mice package, how do we check for the residuals of the pooled analysis?

library(mice)
imp <- mice(nhanes, seed = 23109)
fit <- with(imp, lm(chl ~ age + bmi))
pool(fit)
summary(pool(fit))

fit contains the analysis for each imputed dataset and pool(fit) the pooled results. Is there a command to check the residuals as for a standard lm object, something like plot(pool(fit))?

Body:
I ran into the same problem and I resolved it with a quite exhaustive solution. I saved the residuals and fitted values for each separate imputed dataset. This works okay if you have only a limited amount of datasets, but will become more complicated if you have more datasets (I had 75, so my script became terrible long).
I will explain my solution based on an example with 5 imputed datasets:

 # Computing and saving the mean residual per individual over 5 imputed datasets
 RS1 <-residuals(model1$ana[[1]])+residuals(model1$ana[[2]])+residuals(model1$ana[[3]])+residuals(model1$ana[[4]])+residuals(model1$ana[[5]])
 RSmodel1 <- RS1 / 5
 # Computing and saving the mean predicted value per individual over 5 imputed datasets
 PS1 <-predict(model1$ana[[1]])+predict(model1$ana[[2]])+predict(model1$ana[[3]])+predict(model1$ana[[4]])+predict(model1$ana[[5]])
 PSmodel1 <- PS1 / 5
 # Creating the residual plot
 plot(RSmodel1, PSmodel1)

I hope this will help you!
I am very aware that my solution is quite inconvenient, but it will do the job :)


问:
Scope variables in typescript
I'm working with Angular 2 (Typescript) on Ionic 2 App. I have one class NewFavoriteSitePage with private property siteForm and I can use this property in class methods but when I am inside one google maps method this variable is undefined. What are the scope of variable or How do I define the variable to access from both sides?

```<code>declare var google;
......
export class NewFavoriteSitePage {
  .....
  private siteForm: FormGroup;

  loadMap(){
  //I can access to siteForm here!
  .....
      google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(this.siteForm); //Here this.siteForm is undefined
      });
  }
</code>```

答:
the reason why google maps is not defined there, is because it is the callback of a function, which makes 'this' not equal to the page anymore, putting it in a variable will fix the issue.

```<code>  private siteForm: FormGroup;

  loadMap(){
  var siteformFromPage=this.siteForm; //this should work
        google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(siteformFromPage);
      });
  }
</code>```

EDIT: if you want the latest value, you could also try is this way:

```<code>  private siteForm: FormGroup;

  loadMap(){
       var that=this; //cache that value of the page.

        google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(that.siteformFromPage);
      });
  }
</code>```

Title: Scope variables in typescript

Body:
I'm working with Angular 2 (Typescript) on Ionic 2 App. I have one class NewFavoriteSitePage with private property siteForm and I can use this property in class methods but when I am inside one google maps method this variable is undefined. What are the scope of variable or How do I define the variable to access from both sides?

declare var google;
......
export class NewFavoriteSitePage {
  .....
  private siteForm: FormGroup;

  loadMap(){
  //I can access to siteForm here!
  .....
      google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(this.siteForm); //Here this.siteForm is undefined
      });
  }

Body:
the reason why google maps is not defined there, is because it is the callback of a function, which makes 'this' not equal to the page anymore, putting it in a variable will fix the issue.

  private siteForm: FormGroup;

  loadMap(){
  var siteformFromPage=this.siteForm; //this should work
        google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(siteformFromPage);
      });
  }

EDIT: if you want the latest value, you could also try is this way:

  private siteForm: FormGroup;

  loadMap(){
       var that=this; //cache that value of the page.

        google.maps.event.addListener(marker, 'dragend', function(marker, siteForm){
        let newlatLng = marker.latLng;
        console.log(that.siteformFromPage);
      });
  }


问:
Deploy application with accord.video.ffmpeg c#
I'm using accord.video.ffmpeg 3.4.0, downloaded via nuget,  to save a video with videorecorder class. If I compile (x86) my solution the application is running smoothly in visual studio, instead if I publish the app (same architecture ) when I try to run the setup.exe it installs the program but suddenly crashes. The problem is in the constructor of a class when I do new videorecorder(). It is like If during the deployment process not all the libraries needed are included.
Anyonw knows which libraries are missing?
Thank,
Alex</p>

答:
Probably you are not including the FFMPEG .dll files together with the .exe of your application when you are distributing it.

If you have installed the framework through NuGet, the package should have installed a .targets in your .csproj files that copies those .dlls to your project's output folder on every build.

Those .dll files are currently (as of Accord.NET 3.6.0) called:

avcodec-57.dll

avdevice-57.dll

avfilter-6.dll

avformat-57.dll

avutil-55.dll

postproc-54.dll

swresample-2.dll

swscale-4.dll

And can be found either in your output directory if it was automatically copied, or in the directory packages\Accord.Video.FFMPEG.x.x.x inside your solution folder.