I need an auto-incrementing integer column in Hive and stumbled across UDFRowSequence.
I created a Maven project in IntelliJ, added the .java file, and let the IDE import the dependencies. I then ran mvn package, copied the resulting .jar to a cluster node, and added the .jar resource in Hive:
hive> add file udf-row-sequence-1.0-SNAPSHOT.jar;
Added resources: [udf-row-sequence-1.0-SNAPSHOT.jar]
Unfortunately, I'm unable to create the temporary function:
hive> create temporary function row_sequence as 'com.alexwoolford.hive.udf.UDFRowSequence';
FAILED: Class com.alexwoolford.hive.udf.UDFRowSequence not found
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask
And yet, if I look at the contents of the .jar file I can see that the class exists:
jar tf udf-row-sequence-1.0-SNAPSHOT.jar
[...]
com/alexwoolford/hive/udf/UDFRowSequence.class
[...]
Can you see what I'm doing wrong?
The issue was caused by using add file instead of add jar, i.e.
add jar udf-row-sequence-1.0-SNAPSHOT.jar;
Even though you do "ADD JAR", sometimes even order of adding the JARS do matter, I faced this issue while adding ESRI Hive UDF jars.
add jar esri-geometry-api-1.2.jar;
add jar spatial-sdk-hive-1.0.3-SNAPSHOT.jar;
works
add jar spatial-sdk-hive-1.0.3-SNAPSHOT.jar;
add jar esri-geometry-api-1.2.jar;
Doesn't work
Related
I am making a 2d game, which I have compiled into a .jar to test if it works.
When in run the jar file with java -jar command I get the following error:
Error: Could not find or load main class com.grizeldi.splatoon.Main
I know that there are many solutions here on StackOveflow, but I have tried updating java, messing with -cp... Nothing worked so far.
Code: github repo
Help anyone?
EDIT1: I have my code on a USB stick, but I have tried moving it to C: and D: but nothing worked.
EDIT2: I have added the .jar on the github.
One way is to update the Manifest with the classpath to the other jars:
Class-Path: lib.jar
An alternative is to add the contents of the jars your main jar depends on to your main jar, so you have only one jar file. Make sure you don't add the jars themselves to the main jar, as nested jars won't work.
When dealing with native libraries (.so, .dll), simply place these in the same directory as the jar. The downside of this is that you have multiple files.
In that case, it might be easiest to just add a startup script (.sh, .bat), specifying the classpath and the classname of Main, aswell as a -Djava.library.path.
There is also another way: extract the native library from the jar at runtime, save it to a temporary location, and load it explicitly. See here for more info on that.
I decompiled a jar, imported the files into eclipse, and edited a few key java files. Whenever i try to export however, it gives me a
"JAR creation failed. See details for additional information. UHC-2.4.1/META-INF/MANIFEST.MF was replaced by the generated MANIFEST.MF and is no longer in the JAR. uk/co/eluinhost/UltraHardcore/features/core [in UHC-2.4.1] is not on its project's build path Unable to get package fragment root: UHC-2.4.1/uk/co/eluinhost/UltraHardcore/features/core/GoldenHeads.java uk/co/eluinhost/UltraHardcore/features/core [in UHC-2.4.1] is not on its project's build path" error.
I have searched far and wide for a solution, but have nor found one. I have tried refreshing the project etc, and all the necessary libraries are specified. Please help? Additional information: If I edit any other class (just add a space then delete it and then save) that class gets added to the error message as well.
I had the same issue. I noticed that all of the files that were listed as "not on the project's build path" were open for editing in Eclipse. Once I closed all of the open files, I was able to export the jar.
I assume they are locked for editing and so not exportable.
There are two issues:
It looks like you have the MANIFEST.MF file (UHC-2.4.1/META-INF/MANIFEST.MF ) so just
when you are exporting the jar file select the option for existing manifest file and point it to UHC-2.4.1/META-INF/MANIFEST.MF .
You are missing a jar file (download the UHC-2.4.1.jar from here and and add it to class path.
I know you wrote that you have all the "necessary libraries" but make sure you have added them to your class path.
Import the project from the parent folder, that's what fixed it for me.
In case you haven't noticed, they are not packages in your eclipse picture, that's one reason
I have a maven desktop project that uses JPA as persistent layer; this layer deals with one MySQL database and one SQL Server database.
When I run it inside Eclipse, there is no problema; but when I try to export it outside the output when I run jar the console prints the famous:
javax.persistence.PersistenceException: No persistence provider for
EntityManager named axaptaUnitName
axaptaUnitName is the unit that deals with SQL Server. I have tried all three type of exportation from Eclipse, extract required libraries into JAR, package into JAR, and copy in external folder; none of them works.
All libraries (including the connector with SQL Server) are correctly added to classpath; inside Eclipse all works perfect; so I assume that it's some kind of exportation problem.Any suggestions?
Edit: I've tried to replace Microsoft SQL driver with JTDS driver; but the issue still happening.
Here is Work around for this.
I simply exported it as a runnable Jar with option - "Extract required libraries into generated Jar".
Opened generated Jar with a archiever software.
Then I found there is no "Persistence.xml" in META-INF folder.
I dragged my "Persistence.xml" file in that META-INF folder in achiever's window itself.
Closed archiever program.
After that, the PersistenceException was disappeared.
I'm assuming you use the "uber-jar" method where all dependency jars are exploded into one big jar. The problem with this approach is if the jar has files with same relative path they could override each other. Consider this scneario:
// contents of A.jar
com/foo/Class1.class
com/foo/Class2.class
META-INF/persistence.xml
// contents of B.jar
com/bar/Class1.class
com/bar/Class2.class
META-INF/persistence.xml
When A.jar and B.jar are exploded and re-packaged into Uber.jar, the earlier META-INF/persistence.xml will get overwritten causing errors / unwanted behavior
A better solution to deploy your standalone application is to keep all dependencies in their original jar packaging, place them in a single folder and run using command like this (windows):
java -cp "dependency/;myprog.jar" com.foo.MyMainClass
(all dependency jars are placed on the folder "dependency")
I've found one solution:
Instead of exporting project with Eclipse, I have generated a jar with Maven this way.
I've been trying to make use of the SQLite jdbc class from Xerial. Every time I try to run what I have, it fails, giving me the following error:
java.lang.ClassNotFoundException: org.sqlite.Driver
I'm using Ivy, and have the following in my ivy.xml file.
<dependency org="org.xerial" name="sqlite-jdbc" rev="3.7.2"/>
This includes the sqlite-jdbc-3.7.2.jar file in my class path. I've also tried manually adding it, to no avail.
The command that runs this also contains the jar on the command line:
java -cp ... sqlite-jdbc-3.7.2.jar ...
I still get the class not found exception on the following line:
Class.forName("org.sqlite.Driver");
I've tried searching around for this particular issue, but it seems most of the time it's resolved simply by including the jar in the class path, which shouldn't be the issue here, as Eclipse lists the jar in the class path.
Can you confirm that the jar version sqlite-jdbc-3.7.2 has class org.sqlite.Driver?
You can check it by unzipping the jar file and check if unzippied folder has directory structure org\sqlite\Driver.class?
I think the sqlLite Driver name is org.sqlite.JDBC and not org.sqlite.Driver . Source.
I want to create an executable JAR-file from my eclipse project. It references other projects, which also reference other projects (and so on) and some JAR files.
According to this answer, everything should go "within 2 clicks". But not for me:
It reports a warning:
Problem writing mg/build/classes/META-INF/MANIFEST.MF to JAR: duplicate entry: META-INF/MANIFEST.MF duplicate entry: META-INF/MANIFEST.MF
It looks like it tries to include existing manifests from all projects, which simply doesn't make sense. I actually do not want to include any of them, just to generate a new one. I haven't found any way to switch it off. OK, it's just a warning.
It looks like I need to manually take care of all the referenced jar files... actually, Eclipse knows them, I do not.
I need to either include the content of all the referenced jar files or to copy all of them into the target folder and list them in the Manifest. I've got no idea how to do it.
I also wonder if the jardesc file is usable from ant build scripts.
I got the same error message ("duplicate entry") when, in my case
I checked the option to include an existing manifest file.
AND I specified to include MANIFEST.MF among the files to be included in the .jar.
Once I excluded MANIFEST.MF in the "Select the resources to export:" file tree of the jar generation wizard, the warning disappeared.
As for including referenced projects with your jar, I recommend making them into jar files as well, and including those in the project you want to make a jar of.
Then, make sure to set the manifest's classpath correctly.