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

10

40

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

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 :

<?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.

Bullock answered 31/8, 2014 at 18:40 Comment(1)
StackOverflow does not allow me to input more words. I have to put my solution here for those who have the same issue as me to refer to. paste.openstack.org/show/798815Delay
T
32

Seems like you have an outdated web application referenced in your Tomcat embeded server (You are using Tomcat As within Eclipse right?).

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

Thoroughwort answered 1/9, 2014 at 9:11 Comment(4)
Yes I'm running Tomcat in Eclipse and thank you, that worked.Bullock
@tmarwen: Thanks, worked for me too. But not clear, why this happened. Would you be able to explain that as well?Offwhite
It worked for me once but then getting failed now :(Offwhite
Sorry Deepti but this should be rather an internal eclipse error and I can't explain in more details without knowing which action lead to that error.Thoroughwort
M
3

A maven update did the trick for me.

Right click on your maven project:

  • Maven > Update Project...
  • Select All
  • Check "Force Update of Snapshots/Releases"
  • Click Ok

Now, right click on your server:

  • Clean...
Mediocre answered 2/5, 2017 at 16:22 Comment(0)
I
3

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.

Ipoh answered 5/5, 2020 at 0:12 Comment(1)
I had to delete the artifacts and work dir. Once I did that permissions were cleared and everything started working. Seems like the files with incorrect permissions were created when tomcat was running under a different user.Aplacental
C
1

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

Conceptualism answered 4/10, 2016 at 18:13 Comment(0)
V
1

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:

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

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

Vociferate answered 4/3, 2019 at 4:43 Comment(0)
E
1

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 valid was 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").

Endometriosis answered 6/5, 2020 at 10:53 Comment(0)
R
1

I had a similar issue with one of the projects. I tried all the solutions to this question. None worked for me. I then double-clicked the Tomcat server to see the actual config. In there, under the tab "Modules", there is a list of projects currently associated with the Tomcat server. I could see that the "trouble-causing project" was listed there. I clicked on that and hit remove.

Then everything started to work just fine.

Modules tab image

Rosenbaum answered 7/7, 2021 at 4:50 Comment(0)
G
0

In my case with Tomcat 9 and using Eclipse under Windows, I somehow removed the application from the webapp directory under the Tomcat true server and could no longer start the standalone Tomcat server service. Got the same root cause text as the initial posted question. My solution was to copy the Eclipse version of the application (from the workspace's .metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps tree) to the C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps directory. Note that I am not using Maven in my workspace, and it was just a standard Java Web project.

Giant answered 11/5, 2021 at 23:20 Comment(0)
E
0

For me, the cause was another: In .metadata.plugins\org.eclipse.wst.server.core\servers.xml the "server" element had no "list" element. I added the "list" element:

  <server auto-publish-setting="1" auto-publish-time="1" configuration-id="/Servers/Tomcat v9.0 Server 9091 ASM-config" deployDir="wtpwebapps" hostname="localhost" id="Tomcat v9.0 Server 9091 ASM" jrebel.old-auto-publish-setting="2" name="Tomcat v9.0 Server 9091 ASM" runtime-id="Apache Tomcat v9.0" server-type="org.eclipse.jst.server.tomcat.90" server-type-id="org.eclipse.jst.server.tomcat.90" start-timeout="9000" stop-timeout="30" testEnvironment="true" timestamp="4">
<list key="modules" value0="adsuite-market::org.eclipse.jst.j2ee.server:adsuite-market::jst.web::2.4"/>

and restarted Eclipse. Then it worked as normal again.

Engrossment answered 25/10, 2022 at 8:36 Comment(0)
C
0

I was receiving this error in a gradle application with multiple sub-projects.

My mistake was trying to start the application from the project root directory rather than the api subproject.

I am using intellij and had to change the "Gradle project:" in the run configuration from `project-root' to 'project-root:api'

Caesarism answered 18/4, 2024 at 16:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.