ClassNotFoundException when trying to add configuration to a CompositeConfiguration using commons-configuration2 - java

I'm using org.apache.commons:commons-configuration2 to load and merge configuration from different sources:
val root = CompositeConfiguration()
root.addConfiguration(SystemConfiguration())
val configurations = Configurations()
root.addConfiguration(configurations.properties("defaults.properties"))
My problem is that whenever I run this code I get an exception:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/beanutils/BeanIntrospector at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:264) at
com.sun.proxy.$Proxy0.(Unknown Source) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739) at
org.apache.commons.configuration2.builder.fluent.Parameters.createParametersProxy(Parameters.java:294) at
org.apache.commons.configuration2.builder.fluent.Parameters.fileBased(Parameters.java:185)
at
org.apache.commons.configuration2.builder.fluent.Configurations.fileParams(Configurations.java:602)
at
org.apache.commons.configuration2.builder.fluent.Configurations.fileParams(Configurations.java:638)
at
org.apache.commons.configuration2.builder.fluent.Configurations.fileBasedBuilder(Configurations.java:164)
at
org.apache.commons.configuration2.builder.fluent.Configurations.propertiesBuilder(Configurations.java:264)
at
org.apache.commons.configuration2.builder.fluent.Configurations.properties(Configurations.java:318)
at io.sspinc.datahub.sparkapp.MainKt.main(main.kt:18) Caused by:
java.lang.ClassNotFoundException:
org.apache.commons.beanutils.BeanIntrospector at
java.net.URLClassLoader.findClass(URLClassLoader.java:381) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
It says that org.apache.commons.beanutils.BeanIntrospector is not found. If I add commons-beanutils:commons-beanutils:1.9.3 to the classpath the problem is solved but the main problem is that I'm using Apache Spark 2.3.0 in a managed environment (Databricks) and it comes with commons-beanutils:1.7.0 so I can't do anything about the beanutils version.
How can I solve this problem?

You may want to try using commons-configuration:commons-configuration:1.10 if you only want the composite configuration feature form commons-configuration. It works like this:
val root = CompositeConfiguration()
root.addConfiguration(SystemConfiguration())
root.addConfiguration(PropertiesConfiguration("defaults.properties"))
Configurations 2 won't work with 1.7.0 bean utils according to their documentation.

Related

"new XSSFWorkbook" not working in IntelliJ

I am currently trying to set up an existing JAVA project in IntelliJ IDEA.
The project just won't run past the below posted code snippet on my machine.
try {
this.wb = new XSSFWorkbook (inputStream);
out.print_c("42");
}
I already updated all my dependencies (my Setup is posted at the end of the post), checked the Excel file for any kind of protection (it has none), but I still get the following error messages:
org.apache.poi.ooxml.POIXMLException: org/apache/poi/POIXMLTypeLoader
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:66)
at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:648)
at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:286)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:307)
at excel_manager.ExcelFileReader.readExcelSheet(ExcelFileReader.java:80)
at excel_manager.BBB.readBBB(BBBReader.java:52)
at BBB.BBBPlanManager.(BBBPlanManager.java:31)
at main.AAAAProjectManager.main(AAAAProjectManager.java:76)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63)
... 8 more
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/POIXMLTypeLoader
at org.openxmlformats.schemas.spreadsheetml.x2006.main.CalcChainDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.CalculationChain.readFrom(CalculationChain.java:56)
at org.apache.poi.xssf.model.CalculationChain.(CalculationChain.java:51)
... 14 more
Setup:
IntelliJ IDEA Community Edition 2019.2 x64
jdk1.8.0_221
Dependencies
I hope anyone has an idea what could be the problem here.
Thank you in advance.
Dennis

Intellij keeps throwing ClassNotFoundExcpetion

In my program I have several modules placed in different folders and all of them are dependent on a "core" module.
I have already setup a configuration for Intellij to run the program, but every time I try to run I receive a ClassNotFound Excpetion. I'm not sure if this is due to my core module having a similar packages i.e. com.adpetlabs.flappybird
Could the problem be related to the packages or something else? I really need help in resolving this
Stacktrace:
Exception in thread "main" java.lang.ClassNotFoundException: com.adeptlabs.flappybird.desktop.DesktopLauncher
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

java.lang.NoClassDefFoundError: org/apache/spark/sql/SchemaRDD

I am getting a NoClassDefFound error when trying to run Spark. I cannot figure out the reason behind this. Please help.
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/spark/sql/SchemaRDD
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:659)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.sql.SchemaRDD
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
NoClassDefFoundError means Java couldn't find the Class it was looking for. That normally means:
You defined wrongly the classpath.
Java is finding and using the wrong version of the jar (probably because of Maven dependency hell).
Solution for 1 is to check the classpath: make sure you are including the jar that defines org.apache.spark.sql.SchemaRDD.
Solution for 2 is to check if you have a Maven dependency that depends (transitively) on an older version of the resource that defines that class.

NoClassDefFoundError when using java impl of leveldb

for those who've managed to use this java implementation of leveldb https://github.com/dain/leveldb/
I'm getting the following stacktrace when I try to execute the code in the readme:
NoClassDefFoundError occurs when runing the following line:
DB db = factory.open(new File("example"), options);
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at org.iq80.leveldb.impl.DbImpl.(DbImpl.java:95)
at org.iq80.leveldb.impl.Iq80DBFactory.open(Iq80DBFactory.java:59)
at com.test.LevelDBDain.main(LevelDBDain.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Lists
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
I confirmed that new File("example") returns a non-null value; same as the variable options
I import two jars built from the source into my library:
1.leveldb-api.jar
2.leveldb.jar
I've tried this with releases 0.6, 0.7 and 0.8-SNAPSHOT and always get the same error.
Could it be something I'm doing wrong ...or missing?
com.google.common.collect.util from guava is a dependency of the leveldb library but for some reason adding it explicitly as a dependency for my java project solved the problem.

java.lang.ClassNotFoundException: com.jme3.system.JmeDesktopSystem JME3

When I try to simulate my little project, I decided to use jme3 library and browsed the jar file through Configure-> JDK Profiles-> Add Archieve-> JME3-core.jar and ran the project sample code. The code was written in a website and I got the exception as:
Mar 25, 2014 10:53:44 AM com.jme3.system.JmeSystem checkDelegate
SEVERE: No JmeSystemDelegate specified, cannot instantiate default JmeDesktopSystem:
{0}
java.lang.ClassNotFoundException: com.jme3.system.JmeDesktopSystem
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.jme3.system.JmeSystem.checkDelegate(JmeSystem.java:125)
at com.jme3.system.JmeSystem.showSettingsDialog(JmeSystem.java:96)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:129)
at Main.main(Main.java:12)
Exception in thread "main" java.lang.NullPointerException
at com.jme3.system.JmeSystem.showSettingsDialog(JmeSystem.java:97)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:129)
at Main.main(Main.java:12)
Process completed.
Is the problem about the native libraries kind of issue which is also need to be dealt with J3D libraries? I mean, do I need to follow some instructions about installing and importing JME3 libraries? If so, can anyone tell me the instructions or where to download the correct .jar file?
find a similar discussion here ..this might be relevant ...
more on the same http://hub.jmonkeyengine.org/forum/topic/latest-jme3-sdk-update-trashed-13-of-my-installations/

Categories