Eclispe Tomcat显示一个网址,并显示另一个网址错误

时间:2017-04-11 21:52:08

标签: java eclipse maven tomcat

我得到了一个安静的应用程序,由于某种原因 - 我无法使用Java类从新包中执行方法导致Tomcat显示404错误。我的老班没有错误。

以下是旧类(ManageService)和新类(NewsFeedService)

的比较截图

enter image description here

这些是网址:

工作一次: http://localhost:8180/ChatRestNoSQLMaven/rest/MessageService/getDialog/8bea7f62-8bff-486c-a2bf-a2f989d0c9a8/c95aaad7-7ceb-408d-86a1-15089c399430

失败的一个:

http://localhost:8180/ChatRestNoSQLMaven/rest/NewsFeedService/hello

  

HTTP状态404 - 未找到

     

输入状态报告

     

消息未找到

     

说明请求的资源不可用。

我让Maven干净并安装命令,卸载/安装Eclipse Tomcat服务器,制作Project - >全部构建,但没有结果。 可能是什么原因?

Tomcat服务器启动日志:

Apr 11, 2017 8:37:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ChatRestNoSQLMaven' did not find a matching property.
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.5.9
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Dec 5 2016 20:18:12 UTC
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.5.9.0
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jre1.8.0_112
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_112-b15
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         D:\akworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 8.5
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=D:\akworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.5
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=D:\akworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.5\endorsed
Apr 11, 2017 8:37:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Apr 11, 2017 8:37:09 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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\jre1.8.0_112\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_112/bin/server;C:/Program Files/Java/jre1.8.0_112/bin;C:/Program Files/Java/jre1.8.0_112/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;D:\akworkspace\EccentexQAver2\apache-ant-1.10.0\bin;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\PuTTY\;C:\Program Files\TortoiseGit\bin;C:\Users\akise\AppData\Local\Microsoft\WindowsApps;;C:\WINDOWS\System32;;.
Apr 11, 2017 8:37:10 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8180"]
Apr 11, 2017 8:37:10 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 11, 2017 8:37:10 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Apr 11, 2017 8:37:10 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 11, 2017 8:37:10 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2294 ms
Apr 11, 2017 8:37:10 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 11, 2017 8:37:10 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.9
Apr 11, 2017 8:37:27 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
Apr 11, 2017 8:37:29 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler [http-nio-8180]
Apr 11, 2017 8:37:29 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler [ajp-nio-8009]
Apr 11, 2017 8:37:29 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 18433 ms

的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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>REST Chat</display-name>
   <servlet>
      <servlet-name>Jersey RESTful Application</servlet-name>
      <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
         <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>rest.account,rest.message,rest.friends</param-value>
         </init-param>
         <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
         </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
   <servlet-mapping>
   <servlet-name>Jersey RESTful Application</servlet-name>
      <url-pattern>/rest/*</url-pattern>
   </servlet-mapping>  
</web-app>

3 个答案:

答案 0 :(得分:1)

     <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>rest.account,rest.message,rest.friends</param-value>
     </init-param>

您的param-value文字内容还应列出rest.newsfeed包。

答案 1 :(得分:1)

您可以修改<param-value>以查找您在rest包中定义的所有类,这意味着您可以重新设置:

<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>rest.account,rest.message,rest.friends</param-value>
</init-param>

为此:

<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>rest</param-value>
</init-param>

使用此配置,您可以避免将每个新包添加到<param-value>

答案 2 :(得分:0)

请在eclipse服务器配置和server.xml文件中检查您的端口。请检查端口号是否相同