gpt4 book ai didi

java - tomcat 为我的 webapp 返回 404

转载 作者:行者123 更新时间:2023-11-28 23:57:24 25 4
gpt4 key购买 nike

<分区>

我有一个部署到 Tomcat 8.5 的 Jersey 2 应用程序。当我导航到应用程序 URL 时,我收到 HTTP 404。请帮忙。我已经看到多个关于相同的问题,但我无法弄清楚我的设置有什么问题。日志中也没有错误。

我的应用:


package com.mydomain;

import javax.json.Json;
import javax.json.JsonObject;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/")
public class MyClass {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response defaultEntry() {
JsonObject result = (Json.createObjectBuilder()
.add("test", "OK")
.build());

return Response.status(200).entity(result).build();
}
}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>
<servlet-name>myapp</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.mydomain.MyClass</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>myapp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

应用程序部署到 ${CATALINA_HOME}/webapps。该应用程序有一个名为 myapp 的目录。我使用的 URL 是 localhost:8080/myapp

请帮忙。

编辑:

我附上日志的内容:

catalina.out:


05-Sep-2016 14:09:44.698 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.4
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 6 2016 08:43:30 UTC
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.4.0
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Mac OS X
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.10.5
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86_64
05-Sep-2016 14:09:44.699 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/Home/jre
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_71-b15
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /Users/ksushenko/projects/apache-tomcat-8.5.4
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /Users/ksushenko/projects/apache-tomcat-8.5.4
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/ksushenko/projects/apache-tomcat-8.5.4/conf/logging.properties
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
05-Sep-2016 14:09:44.700 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/ksushenko/projects/apache-tomcat-8.5.4
05-Sep-2016 14:09:44.701 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Users/ksushenko/projects/apache-tomcat-8.5.4
05-Sep-2016 14:09:44.701 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Users/ksushenko/projects/apache-tomcat-8.5.4/temp
05-Sep-2016 14:09:44.701 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/ksushenko/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
05-Sep-2016 14:09:44.784 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Sep-2016 14:09:44.803 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Sep-2016 14:09:44.805 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
05-Sep-2016 14:09:44.806 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Sep-2016 14:09:44.806 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 346 ms
05-Sep-2016 14:09:44.822 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
05-Sep-2016 14:09:44.822 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.4
05-Sep-2016 14:09:44.837 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/myapp.war
05-Sep-2016 14:09:45.310 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars 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.
05-Sep-2016 14:09:45.790 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/myapp.war has finished in 952 ms
05-Sep-2016 14:09:45.790 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/docs
05-Sep-2016 14:09:45.799 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/docs has finished in 9 ms
05-Sep-2016 14:09:45.799 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/examples
05-Sep-2016 14:09:45.924 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/examples has finished in 125 ms
05-Sep-2016 14:09:45.924 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/host-manager
05-Sep-2016 14:09:45.937 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/host-manager has finished in 13 ms
05-Sep-2016 14:09:45.937 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/manager
05-Sep-2016 14:09:45.996 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/manager has finished in 59 ms
05-Sep-2016 14:09:45.996 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/ROOT
05-Sep-2016 14:09:46.004 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/ksushenko/projects/apache-tomcat-8.5.4/webapps/ROOT has finished in 8 ms
05-Sep-2016 14:09:46.005 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
05-Sep-2016 14:09:46.009 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
05-Sep-2016 14:09:46.009 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1203 ms

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com