I'm trying to access dynamoDB from my Lambda function.
The function has the correct IAM role, and was created using the AWS plugin for Eclipse.
When the code gets to this line:
dynamoDB = new DynamoDB(new AmazonDynamoDBClient(
new EnvironmentVariableCredentialsProvider()));
I get the following runtime exception:
Input: com.xr4p.Request#13a57a3borg/apache/commons/logging/LogFactory: java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.amazonaws.AmazonWebServiceClient.<clinit>(AmazonWebServiceClient.java:56)
at com.xr4p.Dana.handleRequest(Dana.java:30)
at com.xr4p.Dana.handleRequest(Dana.java:1)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
I have tried to create the function from scratch,the project from scratch and nothing... The same error keeps popping whenever these lines are added.
What am I missing here?
Thanks
The problem was in Eclipse's project configuration:
Once the "AWS SDK for Java" was added to the "java build path" -> "libraries" it worked ok.
Related
I have one app which I want to dockerize. But first, I need to run it via console(cmd or bash). When I run it from Eclipse everything is okay, but when I run it from bash(java -jar project-18.5.0-SNAPSHOT.jar) I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.hp.spacecat.util.PropertyUtil.<clinit>(PropertyUtil.java:35)
at com.hp.spacecat.SpaceCat.main(SpaceCat.java:76)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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)
... 2 more
I have that jar in m2 and he has this LogFactory class. Mvn clean install is success. But for some reason I can't run it via console. I don't know is there some way to get that classpath from Eclipse or there is another way to solve this.
Similar questions about this logging exception didn't help me.
I am not particularly well experienced with Java at all and try to get a jar file running on my Ubuntu machine (https://sites.google.com/site/communitydetectionslpa/home).
However once I run the jar file with the command suggested by developers I receive the following error:
java -jar GANXiSw.jar -i test.ipairs
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/MultiKeyMap
at Net.<init>(Net.java:38)
at SLPAw.<init>(SLPAw.java:146)
at SLPAw.main(SLPAw.java:2050)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.MultiKeyMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
Apparently java is not able to import the org.apache.commons class properly. After some researching I checked if I have libcommons-collections3-java installed, which however is the case.
I read something about adding the library explicitly to my CLASSPATH, which however I also read to be not good practice.
What is the best approach to fix my issue?
I use Intelij Idea. On project i use http://www.simplejavamail.org . After build and test run on server i got error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
at org.simplejavamail.util.ConfigLoader.<clinit>(ConfigLoader.java:55)
at org.simplejavamail.email.EmailBuilder.<init>(EmailBuilder.java:153)
at com.company.Main.main(Main.java:186) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
After googleing i add slf4j-simple-1.7.25.jar to libraries, but after build it cause that same error. It's strange because if i trying import it in any project file IDE suggest it. I also try add slf4j-api-1.7.25.jar, slf4j-jdk14-1.7.25.jar but it's stil doesnt't help.
Sorry if i don't write important informations. It's my first java project.
I am investigating the jsprit library. For this I just created a new project in Eclipse and copied-pasted the demo example class. Then I added all jars to the path, including log4j-1.2.17.jar. Nevrtheless I cannot execute the demo code due to the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at jsprit.core.problem.vehicle.VehicleImpl$Builder.<clinit>(VehicleImpl.java:108)
at com.test.jsprit.main(jsprit.java:49)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
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)
... 2 more
What does it actually mean and how to solve this issue? Does it mean that some other *.jar file is missed?
UPDATE:
The error occurs at the following line:
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
You are using the wrong version of the log4j lib. You need the 2.x version.
See:
LogManager (Version 1.x)
LogManager (Version 2.x)
log4j-1.2.17.jar implements log4j version 1 and its pretty old. What you need is implementation of log4j 2 - add this as the dependency: link
I installed LibGDX and IntelliJ15.
Then I built my LibGDX App and followed the instructions in this guide :
https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA
I imported the programm with gradle into IntelliJ.
Whenever I try to start the DesktopLauncher, I get the following errors: Exception in thread "main" java.lang.ClassNotFoundException: com.hit.game.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)
I also tried to shorten the DesktopLauncher to:
System.out.println("asdfasdasd");
//LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
//new LwjglApplication(new HitGame(), config);
But I still get those errors :/
Does anybody have an idea or a hint what I am doing wrong ?
Wow,
after spending now more like 2 hours on this problem, it is a specific BUG in intellij 15.0.x ...
https://youtrack.jetbrains.com/issueMobile/IDEA-147788
One way to "build" properly is described in a Reddit post of User anubiann00b :
1. Run gradlew cleanIdea and gradlew idea, specifically in the InteilliJ terminal.
2. A popup comes up asking you to reload the project. Hit accept.
3. Ignore the message to import an unlinked gradle project.
4. Error message on make tells you there isn't an Android SDK. Go to the android module and change the SDK from Java to Android.
https://www.reddit.com/r/libgdx/comments/3tgjqi/using_libgdx_with_intellij_idea_desktop_module/
I've solved it by clicking on the desktop project then run>edit configurations>click on +>gradle>set Gradle project to Project:desktop and type run in tasks and apply and run