2016-06-11 9 views
2

내 Java 응용 프로그램을 실행하기 위해 포함 된 tomcat (v_ 8.0.33)을 사용하고 있습니다. 콘솔에서 다음과 같은 오류를 던지고있다 :임베디드 톰캣 서버를 사용할 때 경고가 표시됩니다.

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 파일 만 어떻게 든 태그 구문 분석 할 수 없습니다를 해결하기 위해 생각하는 이유를 알아낼 수하지 말자. 이 바람둥이의 버전 때문입니까 (뭔가 사용되지 않을 수 있으며 사용하고 있습니까)? 아래

내 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

누군가가이 시점에서 공격하면 미래에 언제 해결 방법은 XML 파싱 로직에 문제가 있기 때문에 web.xml 전개 디스크립터를 사용하지 않도록하는 것입니다 수 있음 webapp-runner에서.

대신 사용 - 당신의 홈페이지 클래스 포함 바람둥이 경우에>을 :

Tomcat.addServlet(context, "yourServletName", resourceConfig()); 
context.addServletMapping("/yourApi/*", "yourServletName"); 



private ServletContainer resourceConfig() { 
     return new ServletContainer(new ResourceConfig(
       new ResourceLoader().getClasses())); 
    } 

ResourceLoader.java

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; 
    } 

을이 시간을 절약 할 수 :)