I have a java application ‘JA’ and a Java project containing a servlet project ‘JS’. From JS I need to use classes present in JA. So, I referenced JA in JS by
right click project -> deployment assembly -> add -> project
and have referenced JA.
Now I am able to import the class files in the JS. But when i am trying to instantiate JA in JS then it is showing NoClassDefFoundError for every class in .jar files used in JA. This error is getting removed by adding the .jar files in JS.
My question is, do we need to add all the .jar files in JS, or are there other methods. Am I missing the method of referencing project.
You need to configure the exported libs from JA project.
This can be done by right click on JA project -> Java Build Path, select tab Order and Export. On this tab you will see all libraries you have referenced on JA. Select the ones you want to export together with JA, click Ok and this is it.