4

After many days searching from a similar problem and its solution on the internet, I now please request your help.

First of all I'm working with :

Java 8 (openjdk), Maven 3, Tomcat 8.5 and I use Eclipse-2019-09 as my IDE.

For this project I'm build a war with maven, adding the ressource to a tomcat server and start it.

Now the problem is whenever I try to launch my tomcat server I get this error :

Caused by: java.lang.ClassNotFoundException: org.codehaus.stax2.ri.Stax2EventFactoryImpl
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Edit : to be more precise, this error append when a bean is getting created. The bean name is "sessionFactory" and its class is : org.springframework.orm.hibernate5.LocalSessionFactoryBean

I firstly thought that Eclipse wasn't resolving the stax2 dependency but when I looked in the classpath the dependency was there. (As you can see on the picture bellow)

dependency in Eclipse pom.xml view

So I thought maybe the jar may not contain the required class but still, when opening the jar in the navigator the class is there.

opened jar in the navigator

The last thing I had to check was to see if the jar file was contained in the war file that is built after compiling the project and still, the class is there.

class exists in War file

So, What have I tried :

  • Maven>Update Projects, Clean/Rebuild project, Maven clean/install and compile the project, clean the tomcat work directory, republish etc.

  • Unistall/Reinstall Eclipse, deleting every hidden folders.

  • Delete the project, clone it to a fresh new workspace.

  • Changed the version of stax2 in my pom.xml

  • Checked if the jar missing is in the deployed war

  • Deleted my .m2/repository

  • Loaded the stax2-api as the first dependency in my pom.xml

The strange thing is that whenever I clone the project on a co worker computer, he can compile/start the server without any exceptions.

I'm a bit lost I must admit, spent a lot a time searching on forums an answer but everything I tried resultd as a failure.

Well, thank you for reading me, if someone has any idea, let me know.

northwolf
  • 51
  • 4
  • Did you check the lib directory in the deployed and exploded webapp war within your eclipse tomcat to see if the jar file is present you expect? It should be {Your_Workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/{Your_App} – camtastic Sep 24 '19 at 01:37
  • Since it's working on your colleague's machine, the project appears to have the correct dependencies. Try deleting your ".m2/repository" and then run your maven goal again. – Prasanna Sep 24 '19 at 06:21
  • @churd I did and the jar is actually just there, really strange. – northwolf Sep 24 '19 at 12:55
  • @northwolf it could be the jar is corrupt. Make sure the class that isn't found is actually in the jar. Also the previous suggestion to delete your .m2/repository would fix corrupt jars if that is the case – camtastic Sep 24 '19 at 12:57
  • @churd the class is in the jar, right now I'm trying Prasanna's suggestion, be right back – northwolf Sep 24 '19 at 12:59
  • @Prasanna Hey, tried your suggestion but still the same issue.. – northwolf Sep 24 '19 at 14:08
  • well load this lib 1st then load the rest of the lib, i had same issues for some other lib. – stacktome Sep 24 '19 at 16:24
  • @stacktome Hey there, I'll try that, be right back – northwolf Sep 25 '19 at 08:33
  • @Stacktome loaded the lib as my first dependency in maven and did not work – northwolf Sep 25 '19 at 09:12

0 Answers0