gpt4 book ai didi

java - Tomcat:严重:加载 WebappClassLoader 时出错

转载 作者:行者123 更新时间:2023-11-28 22:13:39 29 4
gpt4 key购买 nike

请不要标记为重复,因为其他解决方案还没有帮助!

我在尝试运行本教程时在浏览器中收到 404: http://www.vogella.com/articles/REST/article.html

实际上我什至没有看到 WebContent/WEB-INF/classes 文件夹。为什么没有生成?

我只在 SO 上看到解决方案,告诉我清理项目、重启 Eclipse 等等……但对我的情况没有帮助。我使用的是 Tomcat 6,动态 Web 模块版本 2.5。

May 13, 2013 8:17:01 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
May 13, 2013 8:17:01 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:de.vogella.jersey.first' did not find a matching property.
May 13, 2013 8:17:02 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 13, 2013 8:17:02 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 524 ms
May 13, 2013 8:17:02 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 13, 2013 8:17:02 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
May 13, 2013 8:17:02 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
de.vogella.jersey.first
May 13, 2013 8:17:02 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class de.vogella.jersey.first.Hello
May 13, 2013 8:17:02 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
May 13, 2013 8:17:02 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM'
May 13, 2013 8:17:03 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 13, 2013 8:17:03 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 13, 2013 8:17:03 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15 config=null
May 13, 2013 8:17:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1145 ms

而且仍然没有classes文件夹!!!

最佳答案

Vogel 的示例使用的是 Jersey 1.5。如果您使用的是 Jersey 2.0 和 Servlet 2.X,则需要更改 web.xml 文件中的某些属性。 Web 应用程序属性应反射(reflect)您正在使用的 Servlet 版本。此外,ServletContainer 现在位于 org.glassfish.jersey.servlet 包中。所以 servlet-class 属性应该指定如下:

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> 

例如,对于 Servlet 2.5,web.xml 文件应如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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_2_5.xsd">
<display-name>de.vogella.jersey.first</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>de.vogella.jersey.first</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/hello</url-pattern>
</servlet-mapping>
</web-app>

此信息可以在 Jersey 2.0 User Guide 中找到,第 4 章,部署 RESTful Web 服务。

此外,我发现我需要将 url-pattern 设置为:

    <url-pattern>/rest/hello</url-pattern>

为了让它正常工作,所以我仍然需要调查这个问题。

关于java - Tomcat:严重:加载 WebappClassLoader 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16528119/

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