ClassNotFoundException on maven Dependency

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

ClassNotFoundException on maven Dependency

Post 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)
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: ClassNotFoundException on maven Dependency

Post 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
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: ClassNotFoundException on maven Dependency

Post 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
image.png (9.73 KiB) Viewed 985 times
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: ClassNotFoundException on maven Dependency

Post 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
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: ClassNotFoundException on maven Dependency

Post by aujunior »

Thanks a lot Cristian!

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