Page 1 of 1

ClassNotFoundException on maven Dependency

Posted: Tue May 23, 2023 11:23 pm
by aujunior
Hello!

I added the "com.google.code.gson" dependency to use in my java code in a framework.

But when the method is called I am getting "ClassNotFoundException" error.

Is it necessary to do some configuration in the POM for the dependency to be recognized?

Error:
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at ro.sync.basic.classloader.LateDelegationClassLoader.loadClass(LateDelegationClassLoader.java:192)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Re: ClassNotFoundException on maven Dependency

Posted: Wed May 24, 2023 10:05 am
by cristi_talau
Hello,
Adding the dependency in Maven makes it available to your code at compile time.
To have it available also at runtime, you need to configure the classpath of your framework in the Document Type Configuration dialog box: https://www.oxygenxml.com/doc/versions/ ... ialog.html .
Best,
Cristian

Re: ClassNotFoundException on maven Dependency

Posted: Wed May 24, 2023 5:11 pm
by aujunior
I had already made this association.

The part of the codes that use the Oxygen libraries is working.

But the external dependency is not being loaded.
image.png

Re: ClassNotFoundException on maven Dependency

Posted: Thu May 25, 2023 11:37 am
by cristi_talau
Hello,
As far as I can see you have only the JAR with the classes you wrote and a resources folder. You should also include JARs that are Maven dependencies, such as the gson library.

Best,
Cristian

Re: ClassNotFoundException on maven Dependency

Posted: Fri May 26, 2023 4:33 pm
by aujunior
Thanks a lot Cristian!

I put the ".jar" inside the LIB folder and pointed it in the Classpath.