gpt4 book ai didi

java - JAX-RS REST 在 WildFly 工作,但不在 Tomcat 工作

转载 作者:行者123 更新时间:2023-11-28 22:46:41 27 4
gpt4 key购买 nike

我开发了简单的 REST API - https://github.com/pavelpetrcz/MandaysFigu - 我的问题是在本地主机上,WildFly 16 服务器的应用程序运行正常。但是我在 Tomcat 8.5 上收到错误 404。

这是我在本地主机上的 Tomcat 上运行应用程序时的控制台:

Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.5.41
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: May 4 2019 09:17:16 UTC
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.5.41.0
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 10
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.0
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jdk1.8.0_211\jre
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_211-b12
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Osobni\tomcat8_5
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Osobni\tomcat8_5
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Osobni\tomcat8_5
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Osobni\tomcat8_5
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Osobni\tomcat8_5\wtpwebapps
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Osobni\tomcat8_5\endorsed
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1250
Zář 09, 2019 12:37:57 ODP. 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\jdk1.8.0_211\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_211/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_211/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_211/bin/../jre/lib/amd64;C:\Osobni\oracleDbXe\dbhomeXE\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Git\cmd;C:\Users\pavel\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\pavel\AppData\Local\Programs\Python\Python37-32\;C:\Users\pavel\AppData\Local\Microsoft\WindowsApps;C:\Program Files\heroku\bin;C:\Users\pavel\AppData\Local\atom\bin;C:\Osobni\software\eclipse-jee-2019-03-R-win32-x86_64\eclipse;;.]
Zář 09, 2019 12:37:57 ODP. org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Zář 09, 2019 12:37:57 ODP. org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Zář 09, 2019 12:37:57 ODP. org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Zář 09, 2019 12:37:57 ODP. org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 723 ms
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Zář 09, 2019 12:37:57 ODP. org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.41
Zář 09, 2019 12:37:59 ODP. 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.
Zář 09, 2019 12:37:59 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Osobni\tomcat8_5\webapps\docs]
Zář 09, 2019 12:37:59 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Osobni\tomcat8_5\webapps\docs] has finished in [19] ms
Zář 09, 2019 12:37:59 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Osobni\tomcat8_5\webapps\examples]
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('StockTicker', 'async.Stockticker@6837a549')
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Osobni\tomcat8_5\webapps\examples] has finished in [995] ms
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Osobni\tomcat8_5\webapps\host-manager]
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Osobni\tomcat8_5\webapps\host-manager] has finished in [28] ms
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Osobni\tomcat8_5\webapps\manager]
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Osobni\tomcat8_5\webapps\manager] has finished in [26] ms
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Osobni\tomcat8_5\webapps\ROOT]
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Osobni\tomcat8_5\webapps\ROOT] has finished in [21] ms
Zář 09, 2019 12:38:00 ODP. org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Zář 09, 2019 12:38:00 ODP. org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Zář 09, 2019 12:38:00 ODP. org.apache.catalina.startup.Catalina start
INFO: Server startup in 3064 ms


我的同事帮助了我并向我解释说我必须在最初缺少的 JAX RS 的某些实现中添加我的 POM 文件依赖项。所以我补充说:

<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>2.29</version>
<scope>provided</scope>
</dependency>

之后它仍然在 WildFly 上工作,但在 Tomcat 上不工作。我想我也许应该添加一些其他 JEE 标准的其他实现。

我希望,我可以在 Tomcat 8.5 和 WildFly 上运行我的应用程序,并可以在 Heroku 上发布该应用程序。

谁能帮我弄清楚下一步该做什么?

最佳答案

Tomcat 是 java 网络服务器(Servlet/JSP 容器)。不是具有 WildFly、WAS Liberty、Glassfish 等所有完整功能的 JEE 服务器,...

依赖项 org.glassfish.jersey.bundles:jaxrs-ri 标记为已提供。这意味着 maven 假定依赖项已经在您的运行时环境中,并且不会添加到包中。这在包含 JAX-RS 实现的 WildFly 中是正确的,但 Tomcat 遗漏了它并且需要作为依赖项添加,删除提供的范围使用默认范围并添加到包中,但这可能会与 WildFly 实现发生冲突(检查它)。

其他选项是将 Tomcat 中的依赖项添加为认可库中的服务器库,以便随时可用。

关于java - JAX-RS REST 在 WildFly 工作,但不在 Tomcat 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57852368/

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