1

I have taken my "old" (created some months ago, when worked fine) JSF & maven application and started to do some refactoring and restructuralisation.

But, when I did some, the application completely stopped to work (in Eclipse, but I am afraid it will be similar in the plain Tomcat).

The log

When I add my application to Tomcat instance and start the server, the eclipse shows me dialog with message "Server Tomcat 8 (evic2 emulator) failed to start.". In the log can be seeing following exception (complete log here: http://pastebin.com/YEX60a9c) (the first exception causes server to throw three more, omited, see complete log if needed):

 .... 
 SEVERE: A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hg6web]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hg6web]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
 Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@747befb5]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4928)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5058)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
 Caused by: java.lang.IllegalArgumentException: The main resource set specified [**MYAPP**/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/hg6web] is not valid
    at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:723)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:684)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more

 Dub 28, 2016 2:06:01 DOP. org.apache.catalina.core.ContainerBase startInternal
 SEVERE: A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
 Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

 ....

Root of the problem

The server cannot start because of problem with my app's component. The problem of my app - looks like - is given by this exception:

Caused by: java.lang.IllegalArgumentException: The main resource set specified [**MYAPP**/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/hg6web] is not valid

This mean that there is something wrong with my app, but unfortunately not specified what.

What I tried

After lots of googling, I did not find the solution, so I have been trying these (in various combinations):

  • Clean tomcat
  • Clean Tomcat working directory
  • Add and remove
  • clean (Project -> Clean...)
  • rebuild using maven (mvn clean install)
  • reopen project
  • delete and import project again
  • delete "the problematic" folder **MYAPP**/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/
  • delete and recreate project using maven (mvn eclipse:clean eclipse:eclipse)
  • create new server and use instead the old one

None of these helped. The "best" what I got was that the server started, with no error, but the application still have not been deployed properly, because the browser shows me always 404 page.

My idea

I thing the problem is not really in my application (again, before refactoring it worked well), but in the Eclipse/Tomcat environment.

My environment

I am running:

  • Debian Linux, amd64
  • Oracle java 1.8.0_60
  • Eclipse Mars.1 Release (4.5.1)
  • Apache Maven 3.0.5
  • Apache Tomcat 8.0.30

My app

Here is my app's pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>hg6web</artifactId>
    <packaging>war</packaging>

    <!-- the parent project is just simple pom project -->
    <parent>
        <groupId>cz.martlin</groupId>
        <artifactId>homeguard6local</artifactId>
        <version>0.1.0</version>
    </parent>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <!-- JSF stuff -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>

    <!-- other dependencies went here -->

    </dependencies>
    <build>
        <plugins>


            <!-- http://kosalads.blogspot.cz/2014/03/maven-deploy-war-in-tomcat-7.html -->
            <!-- Tomcat plugin -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/${project.build.name}</path>
                    <update>true</update>
                    <url>http://localhost:8080/manager/text</url>
                    <username>***username***</username>
                    <password>***password***</password>
                </configuration>
            </plugin>
        </plugins>
    </build>    
</project>

and web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <display-name>hg6web</display-name>
    <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>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>resources.application</param-value>
    </context-param>

    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

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

</web-app>

The project facets (https://www.dropbox.com/s/5kvz87ooc1ftzpb/hg6web-facets.png?dl=0) of my app are

  • Dynamic Web Module 3.1
  • Java 1.8
  • JavaScript 1.0
  • JavaServerFaces 2.2

Note that the Eclipse displays following tuple of errors in Problems panel:

  • Cannot change version of project facet Dynamic Web Module to 2.5.
  • One or more constraints have not been satisfied.

But, I see this errors always regardless of the application works or not.

The question(s)

Have someone met this problem? Could someone suggest me anything else to try? Or is there anything wrong in my project's settings?

Thanks

Praveen Kumar K S
  • 3,024
  • 1
  • 24
  • 31
martlin
  • 158
  • 2
  • 10
  • @Martin, Appreciate your efforts on different methodologies you tried, 1) Can you please try with **Cargo-maven2-plugin** for your WAR Deployment, as it is best suited for Tomcat 8+ server deployments.. 2) If you have not imported as a Maven Project, Please do so! Let know the results, if it works will update an answer. – Praveen Kumar K S Apr 28 '16 at 03:56
  • Your web.xml declares Servlet 2.5 instead of 3.1 and your pom.xml tells that Maven should include Servlet 3.0.1 library in WAR deployment. Both are outright wrong. Tomcat 8 is a Servlet 3.1 container (which already provides Servlet 3.1 library out the box all by itself). Fix your web.xml to match Servlet 3.1 and fix pom.xml to tell Maven that Servlet 3.1 library is already `provided` by target runtime. At least, that should likely fix your Eclipse *Problems* panel but unlikely the root exception. Give it a try anyway so we can exclude a badly configured project from being the cause. – BalusC Apr 28 '16 at 07:28
  • Thank you, @BalusC, it works! – martlin Apr 28 '16 at 13:28

1 Answers1

0

The notice by @BalusC solved the problem.

I have been using Servlet version 3.0 (3.0.1) (using maven dependency), but web.xml have been configured for 2.5 and Tomcat 8 works with 3.1.

So, I changed version of javax.servlet-api to 3.1.0, updated web.xml to servlet's version (see this post) and it works.

martlin
  • 158
  • 2
  • 10
  • You need to make absolutely sure the dependency is marked as "already provided by target runtime" by `provided`. – BalusC Apr 29 '16 at 07:56