eclipse java.lang.IllegalArgumentException: 指定的主要资源集 [...] 无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25595104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:23:59  来源:igfitidea点击:

java.lang.IllegalArgumentException: The main resource set specified [...] is not valid

eclipsetomcatservlets

提问by Lexx

I'm having trouble starting my Tomcat server, it used to work, but I did something wrong and now it throws me this exception:

我在启动 Tomcat 服务器时遇到问题,它曾经可以工作,但是我做错了,现在它抛出了这个异常:

Caused by: java.lang.IllegalArgumentException: The main resource set specified [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\workspace\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT] is not valid
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:643)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more

And this is my web.xml :

这是我的 web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
        version="3.1">

        <display-name>J2EE Application Example</display-name>

        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>

        <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.xhtml</param-value>
        </context-param>

        <context-param>
                <param-name>facelets.DEVELOPMENT</param-name>
                <param-value>true</param-value>
        </context-param>

        <context-param>
                <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
                <param-value>1</param-value>
        </context-param>

        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        <servlet>
                <servlet-name>Resources Servlet</servlet-name>
                <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
                <load-on-startup>0</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Resources Servlet</servlet-name>
                <url-pattern>/resources/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value></param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <url-pattern>/app/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>

        <filter>
                <filter-name>charEncodingFilter</filter-name>
                <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
        </filter>

        <filter-mapping>
            <filter-name>charEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

</web-app>

I looked at different solutions over the forums, but nothing worked. Final option will be uninstalling tomcat and fresh installation, cause I read that might work. Thanks for the help in advance.

我在论坛上查看了不同的解决方案,但没有任何效果。最终选项将是卸载 tomcat 和全新安装,因为我读到这可能有效。我在这里先向您的帮助表示感谢。

采纳答案by tmarwen

Seems like you have an outdated web application referenced in your Tomcat embeded server (You are using Tomcat Aswithin Eclipseright?).

似乎您的 Tomcat 嵌入式服务器中引用了一个过时的 Web 应用程序(您在Eclipse中使用Tomcat是吗?)。

First checkout the deployed application within you server, and check the artifact name j2eeapplication-0.0.1-SNAPSHOTand version. You may need to remove it and clean your working directory the redeploy it and you should be safe.

首先检查服务器中部署的应用程序,并检查工件名称j2eeapplication-0.0.1-SNAPSHOT和版本。您可能需要删除它并清理您的工作目录,然后重新部署它,您应该是安全的。

回答by Mircea Vutcovici

I had this error when I was starting an application that was designed for Tomcat 8 using Tomcat 7.

当我使用 Tomcat 7 启动一个专为 Tomcat 8 设计的应用程序时,我遇到了这个错误。

回答by Dan Lee

Just in case this might help anyone who come later, I managed to start my tomcat8 server after close and reopen the front project in:

以防万一这可能对以后来的人有所帮助,我设法在关闭后启动了我的 tomcat8 服务器并在以下位置重新打开前端项目:

The main resource set specified [project-to-be-reopened]

指定的主要资源集【project-to-be-reopened】

In my case, it's maven dependency that's causing me this issue, updating maven-dependency will also help.

就我而言,是 maven 依赖导致了这个问题,更新 maven-dependency 也会有所帮助。

回答by Nathan Crause

For me, this was caused by a file permission issue. We use a different deployment strategy where I work (not something I can change) which means the webapp exists in a completely different directory to the normal Tomcat directory structure. The above exception occurred when the Tomcat runtime didn't have permission to access that directory.

对我来说,这是由文件权限问题引起的。我们在我工作的地方使用不同的部署策略(不是我可以改变的),这意味着 webapp 存在于与普通 Tomcat 目录结构完全不同的目录中。当 Tomcat 运行时没有访问该目录的权限时,就会发生上述异常。

回答by michaeak

I had a similar issue. Just if someone else runs into this problem:

我有一个类似的问题。如果其他人遇到这个问题:

For me it was caused because I had an old project deployed, then closed that project. For several weeks, everything was fine, until I used the "Clean..." command of eclipse on that tomcat server. From that point on the famous The main resource set specified [...path to deployment location of this project...] is not validwas raised every time I tried to start Tomcat. What solved this problem for me was just removing that old project from tomcat (Right click on that entry under Tomcat Server and choose "Remove").

对我来说,这是因为我部署了一个旧项目,然后关闭了该项目。几个星期以来,一切都很好,直到我在那个 tomcat 服务器上使用了 eclipse 的“Clean...”命令。从那时起,The main resource set specified [...path to deployment location of this project...] is not valid我每次尝试启动 Tomcat 时都会提出著名的问题。对我来说解决这个问题的只是从 tomcat 中删除那个旧项目(右键单击 Tomcat 服务器下的那个条目并选择“删除”)。

回答by user1330025

A maven update did the trick for me.

Maven 更新对我有用。

Right click on your maven project:

右键单击您的 Maven 项目:

  • Maven > Update Project...
  • Select All
  • Check "Force Update of Snapshots/Releases"
  • Click Ok
  • Maven > 更新项目...
  • 全选
  • 勾选“强制更新快照/发布”
  • 单击确定

Now, right click on your server:

现在,右键单击您的服务器:

  • Clean...
  • 干净的...