compilation error java hadoop [duplicate] - java

I am getting an unexpected error when trying to instantiate a Configuration object in my Map/Reduce program.
The error is as follows:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
I am using Hadoop 2.2.0. The program worked fine with an earlier version of Hadoop. However, now I need to write this job submitter for the version 2, and this does not seem to be working.
As a side note, I could not find all the required JAR files for this version. I have read the following solution to a similar problem: Where are hadoop jar files in hadoop 2?. However, this did not work for me. It fails with the above runtime error.
I tried using older JAR files to resolve these issues, but new error keep occurring.
Does anyone have a solution to this problem? I am using NetBeans, if that makes any difference from some reason.

Including JARs in folders listed below worked for me:
share\hadoop\common
share\hadoop\common\lib
share\hadoop\mapreduce
share\hadoop\mapreduce\lib
share\hadoop\yarn
share\hadoop\yarn\lib

I resolved the problem by downloading the JAR files from commons.apache directory and from Maven repositories. Each time I added a new JAR to the project, the application crashed with a different error (a different class was not found) until I downloaded all of the JAR files from the Maven repository. After downloading a lot of JAR files from the online repositories, most of the JAR related problems seem to be resolved.

you can try right-clicking the Project, ->Build Path -> Configure Build Path
Go to your src folder, point to "Native Library", then edit the location to the location of your hadoop native library folder (normally: ~/hadoop-x.x.x/lib/native/"folder-depending-on-your-system")

Related

Folders can not be found after converting a JAVA project into a runnable JAR

I hope somebody can help me with my problem. After hours of scanning all different posts concerning the abovementioned topic I now decided to answer my own question. None of the other posts solved my problem.
I want to export an existing JAVA project as runnable JAR. Therefore I'm changing all absolute references to the following:
this.getClass().getResource("/somekindofimage.png").toString();
This way I can reach all available files in the runnable JAR.
However I need to reference a folder...so I tried it the same way:
this.getClass().getResource("/somekindoffolder").toString();
which gives me the following path:
file:\C:\Users\...\1_data_collection
By creating a file and checking with "is.Directory" it returns false.
I unzipped the runnable JAR. All folders, all files that are needed are included. They are attached as sources via BuildPath.
When I test the abovementioned path with Windows Explorer it directs me to the folder I'm looking for.
I'm using Eclipse Neon 2 as IDE, my JAVA Version is 1.8-0_144.
Thanks in advance!
You can't refer to files in a JAR using a File path. You have to load them as resources from the classpath.
Make sure the resources and dependencies you need are packaged in the JAR. There's a Maven Shade plugin, if you're using Maven, that will do it for you.

Why java code working in Intellij Idea, but not working JAR file after building artifact

My code working well from Intellij Idea by clicking Run. But created JAR file (build artifact) doesn't run with JVM Launcher error: "A JNI error has occur, pls check your installation and try again".
Previously it's was OK with builded JAR, but recently I modified my code and made some improvements and added some external JAR files to my project (HtmlUnit, HttpClient, etc).
I suppose that problem with dependencies, but how to fix?
You haven't included whole error message. It may be either problem with dependencies (not present/found) or they signature (some java libraries are signed and the problems occurs when the archive is repacked).
I was able to fix the problem by:
Configure the archive for the project:
Choose second option: "Copy to the output directry and link via manifest"
Build artifact
The artifact will be generated in the choosen directory. Also the dependencies will be copied next to it
You can enter into the directory from command line and run the app (or create a script):

STS project gives error cannot be read or is not a valid ZIP file

I am for the first time trying java in Spring Tool Suite and using an example project imported, now running into endless issues. I tried building the project and go the following error:
Archive for required library: 'C:/Users/cccc/.m2/repository/com/vaadin/vaadin-client/7.1.0/
vaadin-client-7.1.0.jar' in project 'quicktickets-dashboard' cannot be read or is not a
valid ZIP file quicktickets-dashboard Build path Build Path Problem
This is probably a spring issue and not related to the project itself. Please does anyone have a working solution to this. Tried a few, building, closing, rebuilding, deleting local repository etc. but still the same issue. Any ideas appreciated.
The most likely explanation is that your maven cache is corrupted. First, check if the C:/Users/cccc/.m2/repository/com/vaadin/vaadin-client/7.1.0/vaadin-client-7.1.0.jar jar is complete. Run jar tvf on the file to make sure you can use it.
If you're lucky, things will work if you delete the C:/Users/cccc/.m2/repository/com/vaadin/vaadin-client/7.1.0/ folder, but if that doesn't work, you will have to try deleting C:/Users/cccc/.m2/repository. It's just a local cache of artifacts downloaded from maven central or an internal repository, so it is OK to delete.
I am 90% certain this would fix your problem.
I clear /.m2/repository/.cache and it works fine.

selenium-server-standalone-2.37.0.jar is broken?

I'm trying to use the library "selenium-server-standalone-2.37.0.jar" in a project. The project was previously using "selenium-server-standalone-2.24.1.jar", but I think that is too out of date for my current version of Chrome.
When I tried to switch out the old jar for the new jar, though, I started getting the Eclipse error:
Description Resource Path Location Type
Archive for required library: 'mypath/lib/selenium-server-standalone-2.37.0.jar' in project 'BookProject' cannot be read or is not a valid ZIP file BookProject Build path Build Path Problem
So I tried unpacking the jar with 7-zip, but in there I got the error:
Can not open file 'mypath/selenium-server-standalone-2.37.0.jar' as archive
Is this jar actually broken, or is there something I'm missing here? If this one isn't working, does anyone know where I could find the previous version? I couldn't find that anywhere.
If you are unable to open the jar even using 7-zip, then it's corrupt.
I'd recommend re-downloading it. Furthermore, when using eclipse, it might be a good idea to clear your dependency cache when upgrading things.. that usually solves things.
Edit
I suppose that it could be possible that the jar itself is just corrupt. If that's the case, try going to https://code.google.com/p/selenium/downloads/list and where it says "Search: Current Downloads" Select "Deprecated Downloads"
I still use
https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.35.0.jar

commons-logging-1.1.jar; cannot read zip file entry

I have imported a GWT project from GIT , but when i run maven Install
it says
.m2\repository\commons-logging\commons-logging\1.1\commons-logging-1.1.jar; cannot read zip file entry
and if i simply run my application , i get this
\git\my-Search-Engine\qsse\war}: java.lang.NoClassDefFoundError: com/google/inject/servlet/GuiceServletContextListener
I tried to find out the way , one solution i found was to move the guice-servlet-3.0 from build path to \qsse\war\webinf\lib
but if i do that i start getting this exception
ava.lang.NoClassDefFoundError: com/google/inject/Injector
any idea how can i resolve this
For first question:
Can you open it in a WinZip or other compression tool.
Try deleting that jar and build again. Let Maven download it a fresh.
For Second Questin:
Which GWT version are you using ?
Verify that the required JAR is in your classpath including guice.jar and guice-servlet-3.0.jar
And also, guice-servlet-3.0.jar should not be in you launch configuration classpath. It has to be in your project classpath.
For the second question, can you also move the other guice jars to webinf\lib ? (guice-3.0.jar should be missing)

Categories

Resources