2016-11-30 62 views
0

我在Tom Cat中部署我的Java應用程序時出現錯誤。當我作爲選擇的服務器上運行,它給我「HTTP狀態404」這些警告:Tomcat錯誤404「找不到匹配的屬性」

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

特別是我認爲我的問題是AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FoodDrinkDispener' did not find a matching property. 其實我搜索互聯網上,我發現了幾種可能的解決方案,例如:

從服務器視圖中刪除項目。右鍵單擊服務器 - >添加和刪除,然後在同一臺服務器下運行該項目。 或者如果警告仍然存在,則 轉到服務器視圖 雙擊您的tomcat服務器。它將打開服務器配置。 在服務器選項下勾選'發佈模塊內容以分離XML文件'複選框。 重新啓動您的服務器。這一次您的網頁將沒有任何問題。 閱讀全文http://www.java2blog.com/2016/03/restful-web-services-jaxrs-crud-example.html

但是這並不能解決問題。我花了幾個小時尋找修復它,但沒有。 這是我的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> 
 
    \t \t <groupId>org.hibernate</groupId> 
 
    \t \t <artifactId>hibernate-core</artifactId> 
 
    \t \t <version>4.3.5.Final</version> 
 
    \t </dependency> 
 
    \t <!-- Hibernate uses slf4j for logging --> 
 
     <dependency> 
 
      <groupId>org.slf4j</groupId> 
 
      <artifactId>slf4j-simple</artifactId> 
 
      <version>1.7.5</version> 
 
     </dependency> 
 
     <dependency> 
 
     \t <groupId>mysql</groupId> 
 
     \t <artifactId>mysql-connector-java</artifactId> 
 
     \t <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>

這是我的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>

這是我的服務器配置:(服務器.xml)

<?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 &quot;%r&quot; %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"/> --> 
 
    \t \t <Context docBase="FoodDrinkDispener" path="/FoodDrinkDispener" reloadable="true" source="org.eclipse.jst.jee.server:FoodDrinkDispener"/></Host> 
 
      </Engine> 
 
    </Service> 
 
</Server>

我嘩嘩有人可以幫我解決這個錯誤。

+0

你不需要編輯你的'server.xml' - 將它重置爲原來的。你用過maven來建立你的'target'嗎? –

+0

您的意思是: - > Maven - >更新項目? –

+0

沒有'Run-> Maven Build' –

回答

-1

問題在於html文件,請嘗試將您的html文件名更改爲index.html,以便服務器能夠理解它。