【问题标题】:no global web.xml found未找到全局 web.xml
【发布时间】:2023-03-27 14:12:01
【问题描述】:

我尝试为我的应用程序使用嵌入的 tomcat 8,但出现此错误:

2017 年 11 月 21 日上午 11:37:18 org.apache.catalina.core.StandardContext 设置路径

警告:上下文路径必须是空字符串或 以“/”开头,不要以“/”结尾。路径 [/] 不满足 这些标准并已更改为 [] 配置应用程序 基于: C:\Users\hzammel\Downloads\boualiali-gestion_stock_mvc-086417808484\boualiali-gestion_stock_mvc-086417808484.\src\main\webapp 2017 年 11 月 21 日上午 11:37:19 org.apache.coyote.AbstractProtocol 初始化

信息:初始化 ProtocolHandler [“http-nio-8080”] 11 月 21 日, 2017 上午 11:37:19 org.apache.tomcat.util.net.NioSelectorPool 获取共享选择器

信息:对 servlet 使用共享选择器 写/读 2017 年 11 月 21 日上午 11:37:19 org.apache.catalina.core.StandardService startInternal

信息: 启动服务 Tomcat 2017 年 11 月 21 日 11:37:19 AM org.apache.catalina.core.StandardEngine startInternal

信息: 启动 Servlet 引擎:Apache Tomcat/8.0.36 2017 年 11 月 21 日上午 11:37:19 org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment

信息:未找到全局 web.xml 2017 年 11 月 21 日上午 11:37:21 org.apache.catalina.core.ApplicationContext 日志信息:没有 Spring 在类路径上检测到 WebApplicationInitializer 类型 2017 年 11 月 21 日 上午 11:37:21 org.apache.jasper.servlet.TldScanner scanJars

信息: 至少对一个 JAR 进行了 TLD 扫描,但未包含 TLD。使能够 调试此记录器的日志记录以获得完整的 JAR 列表 扫描但未在其中找到 TLD。期间跳过不需要的 JAR 扫描可以提高启动时间和 JSP 编译时间。 11月21日, 2017 年 11:37:22 AM org.apache.catalina.core.ApplicationContext 日志

信息:初始化 Spring 根 WebApplicationContext

这是我的主课:

 public static void main(String[] args) throws LifecycleException,
         InterruptedException, ServletException {

             String docBase = "src/main/webapp/";

              Tomcat tomcat = new Tomcat();
              String webPort = System.getenv("PORT");
                    if(webPort == null || webPort.isEmpty()) {
                        webPort = "8080";
                    }
                    tomcat.setPort(Integer.valueOf(webPort));
                    
                    StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(docBase).getAbsolutePath());
                    System.out.println("configuring app with basedir: " + new File("./" + docBase).getAbsolutePath());

                   
                    File additionWebInfClasses = new File("target/classes");
                    WebResourceRoot resources = new StandardRoot(ctx);
                    resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
                    ctx.setResources(resources);
                     

                    
            /*        
             tomcat.addWebapp("", new File(docBase).getAbsolutePath());
               System.out.println("configuring app with basedir: " + new File("./" + docBase).getAbsolutePath());
*/
              tomcat.start();
              tomcat.getServer().await();

我的文件夹##:

src

---------主要

    ---------- webapp

                      ----------WEB-INF

                                ----------web.xml

有什么帮助吗??

【问题讨论】:

  • 您的堆栈跟踪在这种格式下不可读
  • 这是错误:2017 年 11 月 21 日上午 11:37:19 org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment INFORMATION: No global web.xml found

标签: java spring tomcat


【解决方案1】:

信息:未找到全局 web.xml

这里没有错误,这里的日志记录级别是INFO,Not ERROR。应用程序应该可以正常运行。检查您在浏览器中输入的 URL 是否与项目中包含/配置的 URL 相符。

【讨论】:

    【解决方案2】:

    我们在 war 文件中添加一些 (xml-) 依赖项 (jar) 后收到此消息,例如。 G。 xml-apis-*.jar 等,“启动 Servlet 引擎”之后花了 15 多分钟。删除这些(不需要的)依赖可以避免这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-25
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多