I have been working on a Java (Java 8) web application in Eclipse, using maven for one year. I created this webapp and use Maven v 3.5 since the beginning of my project. I usually deploy my web application on a tomcat 8.5 server ('Run as => run on server').
I have always managed my dependencies with my pom.xml, preventing with doing weird things using hte build path configuration menu from Eclipse.
The issue started yesterday : I add a dependency from other java/maven project I have madeand installed simply before, and add this lines on my pom.xml :
<dependency>
<groupId>tlnPdf</groupId>
<artifactId>tlnPdf</artifactId>
<version>1.0</version>
</dependency>
As my eclipse does sometimes when I add a new dependancy from other project, I had an issue when deploying the webapp, some message (sorry but I can't remember it) about the pom.properties from my other project. In this case, and as I always did, I just have to close my webapp project, launch a mvn eclipse:clean
from a command prompt and then reopen my project; and the issue disappear.
Eclipse doesn't show issue on the classes that import classes from the new dependancy included.
Also I have a listener on a class at the starting of my webapp, declared on my web.xml :
<listener>
<listener-class>com.package.InitTomcat</listener-class>
</listener>
This listener is funcional and I have not modified it lastly.
But yesterday, a new issue appear; when I wanted to deploy my webapp on my server, I had a lot of warning like this :
org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [...] to the cache because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
. And then, an error telling me that the InitTomcat class does not exist :
java.lang.ClassNotFoundException: com.package.InitTomcat
So, firstly I thought that the cache warning was causing the issue. I did what this this stackoverflow post explain, and the warnings disappeared; but not the error.
Outside from eclipse, in a command prompt, I try to compile my project and getting my app.war
file using mvn clean install
. The compilation did not show any error, and the war is correct. I deployed manually my war on tomcat and no issue appeared.
Thus, I look on the two deployed directory (one from eclipse, the other manually by my app.war) and I saw something curious on the tree of repository deployed :
On the good deployed webapp (from app.war), I have something like that:
|*some directories and files
|*META-INF
|*WEB-INF
|*classes
|com (etc...)
|*lib
|web.xml
And in the deployed webapp from eclipse :
*some directories and files
*META-INF
*WEB-INF
|*classes
|*.settings (why the hell does this directory are here ?)
|*bin
|*.settings
|*src
|*target
|*classes
|*com ect... (my .class files are here !!)
|*generated-sources
|*m2e-wtp
|*maven-archiver
|*maven-status
|*myapp (this directory have the same content as the "good web app deployed")
|*test-classes
|*WebContent
|*temp
|*webContent
|pom.xml
|.project
|*src
|*target
|*temp
|*WebContent
|*...
|*lib
|web.xml
The "good" webapp as a size of 275Mb, the other is 865Mb
I suspect that the issue occur when eclipse deploy my web-app and which explain that it could not find the InitTomcat class since it seems to be at the wrong place. But I have no idea why it decided to do this now.
I tries to delete the project from eclipse, cleaning eclipse, etc... but no result. I have tried with 3 different versions of tomcat : 8.5.14, 8.2.23 and 9.0.2, always with the same behaviour
As I was depressed, I download the last version of eclipse, and import my webapp project into it with maven; but it has the same result.
Finally, my question is simple : does anyone has an idea of what it is happening, and how to solve it ? Thanks in advance !