有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

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

我的浏览器中有404试图运行此教程: http://www.vogella.com/articles/REST/article.html

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

我在这里看到的解决方案只是告诉我清理项目、重新启动Eclipse等等。。。但在我的情况下,没有人帮我。我使用的是Tomcat6,动态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

还有还有没有班级文件夹


共 (3) 个答案

  1. # 1 楼答案

    Vogel的例子是使用Jersey 1.5。如果您使用的是Jersey 2.0&;Servlet 2。十、 web中的某些属性。需要更改xml文件。web应用程序属性应该反映您正在使用的Servlet版本。此外,ServletContainer现在位于组织中。玻璃鱼。运动衫servlet包。因此,servlet类属性应指定如下:

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

    例如,对于Servlet2.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>
    

    这些信息可以在第4章“部署RESTful Web服务”的Jersey 2.0 User Guide中找到

    此外,我发现我需要将url模式设置为:

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

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

  2. # 2 楼答案

    我也有同样的问题;然而,我被困了一天。这是因为最有可能的罐子版本。我放了一个罐子,可能是第一个捡到的。在类路径中,它当然是错误的版本,或者可能是用不同版本的Java编译的。我以前见过这个。因此,我从头开始关注罐子和版本号,只安装需要的东西,它就像一个冠军一样工作

  3. # 3 楼答案

    尝试以下步骤(希望您使用的是Eclipse),看看它是否有助于解决这个问题

    1. 导航::“右键单击(项目名称)>;属性>;源”选项卡,并确保选择“project/WebContent/WEB-INF/classes”作为默认输出文件夹

    2. 导航“窗口(菜单)>;显示视图>;其他>;常规>;导航器”,然后转到“项目/WebContent/WEB-INF/”并检查“类”文件夹是否存在

    3. 如果没有,则导航“窗口(菜单)>;显示视图>;其他>;常规>;标记”,查看其是否显示任何生成路径错误。如果是这样,纠正错误,你应该是好的