使用嵌入式tomcat服务器时发出警告

时间:2016-06-11 14:25:29

标签: java servlets java-ee web.xml embedded-tomcat-8

我使用嵌入式tomcat(v_ 8.0.33 )来运行我的java应用程序。它在控制台中抛出以下错误:

INFO: Starting Servlet Engine: Apache Tomcat/8.0.33
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/servlet-name'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/servlet-class'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param/param-name'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param/param-value'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param/param-name'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param/param-value'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/init-param'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet/load-on-startup'.
g.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app/servlet-mapping'.
Jun 11, 2016 2:53:02 PM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'web-app'.
Jun 11, 2016 2:53:02 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Jun 11, 2016 2:53:04 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.
Jun 11, 2016 2:53:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]

我认为它映射到正确的web.xml文件,但不知何故无法解析它的标签,无法弄清楚原因。是由于这个tomcat的版本(某些东西可能已被弃用,我正在使用)?

下面的

是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

  <servlet>
    <servlet-name>REST Servlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>ResourceLoader</param-value>
    </init-param>
    <init-param>
      <param-name>jersey.config.server.provider.packages</param-name>
      <param-value>sran.api.ifscLookup.resources</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>REST Servlet</servlet-name>
    <url-pattern>/Api/*</url-pattern>

  </servlet-mapping>

</web-app>

1 个答案:

答案 0 :(得分:1)

如果有人在这一点上发现,可能是将来的任何时候,解决方法是避免使用web.xml部署描述符,因为webapp-runner中的XML解析逻辑存在问题。

而是在包含tomcat实例的 Main 类中使用 - &gt;

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.core.Application;



public class ResourceLoader extends Application{

    @Override
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<Class<?>>();

        // register root resource
        classes.add(classWhereYouDefinedUrlEndpoint.class);
        return classes;
    }

<强> ResourceLoader.java

#import <UIKit/UIKit.h>

这可能会节省您的时间:)