2

I'm working for a maven web application and I'm struggling with this error and I can't find any solution:

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@5b0abc94]
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:909)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
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:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@5b0abc94]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4783)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4918)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
... 21 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: error in opening zip file
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:143)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
... 33 more

It comes from running a index.jsp page that imports multiple other classes:

<%@page import="java.util.ArrayList" %>
<%@page import="java.util.List" %>
<%@page import= "java.net.URL" %>
<%@ page import="models.Chapter" %>
<%@ page import="models.User" %>
<%@ page import="models.Student" %>
<%@ page import="models.Teacher" %>
<%@ page import="models.Enrolment" %>
<%@ page import="dao.UserDAO" %>
<%@ page import="dao.StudentDAO" %>
<%@ page import="dao.TeacherDAO" %>
<%@ page import="dao.ChapterDAO" %>
<%@ page import="dao.Chapter2DAO" %>
<%@ page import="dao.EnrolmentDAO" %>
<%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%>

From what I found so far, it says that some JAR files could be corrupt so I just deleted them from my lib file. After that I got an error like Java error: Only a type can be imported. XYZ resolves to a package that I also couldn't solve and just sent me back to add all jars in the lib folder in WEB-INF. I tried deleting my repository then maven install again, didn't work. I checked the versions of my jars and everything, I tried lots of things but nothing seem to work so far. Here is my pom.xml for reference:

 <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <java.version>1.8</java.version>
  </properties>



  <dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.3.1.Final</version>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.13</version>
</dependency>

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>


<dependency>
  <groupId>javax.transaction</groupId>
  <artifactId>jta</artifactId>
  <version>1.1</version>
  </dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>

Here is my project structure in Eclipse:

mystructure

Do you have any idea how I can deal with this issue? I really don't see where problem is.

Bacteria
  • 8,406
  • 10
  • 50
  • 67
Paul Buciuman
  • 325
  • 3
  • 10
  • 19
  • why you put jars in your lib folder? – Bacteria May 31 '19 at 17:37
  • this was quite a common suggestion that I got while trying to solve previous issues. If I take them out I got the other error I mentioned and the solution was to add jars. It's like a loop that I don't know how to get out of – Paul Buciuman May 31 '19 at 17:40

1 Answers1

1

If you look into the following exception stacktrace which says,

Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: error in opening zip file

It means, the war file is not proper from a deployment view point. Besides, you have to create war packaging in maven. Apart from that, you have to use maven war plugin. You have to make a complete web project in eclipse also. I will suggest to go through the following tutorials to get an idea.

https://crunchify.com/how-to-create-a-war-file-from-eclipse-using-maven-plugin-apache-maven-war-plugin-usage/

Sambit
  • 7,625
  • 7
  • 34
  • 65
  • I just created a new project using the tutorial you provided. I want to make sure all my classes and dependencies are placed in the right way so I have these questions now: do I put my packages inside the java resources/src folder? Also, should I add the jars inside the lib folder in WEB-INF? Should I user a classes folder as well under WEB-INF? – Paul Buciuman May 31 '19 at 18:09
  • If you are using IDE like eclipse, you can create packages by right click and select to create a package. – Sambit May 31 '19 at 18:10
  • I never worked with war files so I have a dummy question: do I still work with jar files in the same way? adding dependencies in pom.xml? – Paul Buciuman May 31 '19 at 18:28
  • 1
    You have to deploy the war file for web application. Check this link. https://stackoverflow.com/questions/5871053/difference-between-jar-and-war-in-java – Sambit May 31 '19 at 18:30
  • is there a way this error can be solved without using war files? – Paul Buciuman Jun 01 '19 at 00:47