0

I have a "jar-a" which has AutoValue generated class files. When I add that jar as external library to another maven project, those autovalue generated classes are not appearing and when I run my project I get java.lang.NoClassDefFoundError. Is this autovalue related issue or generic issue. Would appreciate any fix or workaround.

Note: I have tried adding jar-a manually to the external libraries in Intellij and also tried adding it as a local dependency in the pom.xml as shown below but getting same error.

 <dependency>
  <groupId>jar-a</groupId>
  <artifactId>jar-a</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}/src/lib/jar-a.jar</systemPath>
</dependency>

Edit:

This jar was developed in my local machine and not available in any repository. It is also present in my m2 repository. I have tried below maven install file and now I could see most all the dependent packages that was used in "jar-a" but still getting java.lang.NoSuchFieldError for one of the class.

mvn install:install-file \
>     -Dfile=path/jar-a.jar \
>     -DgroupId=com.abc \
>     -DartifactId=abc \
>     -Dversion=1.0-SNAPSHOT \
>     -Dpackaging=jar \
>     -DpomFile=path/pom.xml

I am investigating further but meanwhile want to get confirmation on the approach I followed above.

  • Is that jar available in your m2 repository or is it a jar at maven central? Is it generated by a project at your local computer? Lots of questions exist. Can you be more specific? – Onur Baştürk Sep 18 '20 at 21:24
  • @OnurBaştürk, Thanks for the response. I have updated the details in the `edit` section of my post. – Praveen Viswanathan Sep 19 '20 at 01:32
  • Ok thanks for the edit. Then now you're not getting NoClassDefFoundError but NoSuchFieldError? There may a problem with the version of your jar-a. Just open your up-to-date jar-a project and check if that specific field is available. Then give jar-a project a mvn clean install command. Finally just include the last installed version in your other project and clean install it too. Don't give it a scope or path etc. Just groupId, artifactId and version. It's worth to try! – Onur Baştürk Sep 19 '20 at 06:24

0 Answers0