JNI Error followed by Java Error when opening exectuable-jar - maven

Good evening,
I encountered a problem while building an executable jar with Intellij. Before I never encountered Problems with it, but this time there is JNI Error occured and a Java Error occured message. I already tried the tips I found in Stackoverflow. It won't work with Maven Assembly Plugin or Maven Dependency Plugin. Moreover I tried creating the MANIFEST in main/java and main/resources. When I create it in main/java nothing happens when i open the jar with the second method the error mentioned earlier occures.
The only way it works is using this option in Artifacts
But using this option all of the libraries are in the file Path individually and the jar size is 75 kb. My goal was to create ONE fat executable jar. Btw another maven project I created works finde after creating the jar. Thanks in advance.

Related

Jar hell - force load one version

Is there a way to force a java application to load a particular version of a jar, and not include the other version in the classpath?
Many other users here have noted that Elasticsearch unit tests throw jar hell errors. I have tried all the suggestions, and nothing has worked. I have set up tons and tons of 'exclusions' in my pom.xml, and this has not helped. How exactly is this jar being loaded?
java.lang.RuntimeException: found jar hell in test classpath
..
Caused by: java.lang.IllegalStateException: jar hell!
class: javax.servlet.annotation.WebFilter
jar1: /Users/xx/.m2/repository/org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/1.0.1.Final/jboss-servlet-api_3.0_spec-1.0.1.Final.jar
jar2: /Users/xx/.m2/repository/org/jboss/spec/javax/servlet/jboss-servlet-api_3.1_spec/1.0.0.Final/jboss-servlet-api_3.1_spec-1.0.0.Final.jar
How to find which jar is linked to jboss-servlet-api_3.0_spec-1.0.1.Final.jar? I have tried using tattletale(this did not generate reports) and maven-duplicate-finder(this did not find anything). I could hack it to set the jar-check option to false, but then I get shadowing errors.
These jars do not show up in my maven dependency tree.
I tried deleting the two versions from my .m2 directory, but they just popup again when I am running the app - is there a way to find out where it is being loaded from?

Spark can't find Guava Classes

I'm running Spark's example called JavaPageRank, but it's a copy that I compiled separately using maven in a new jar. I keep getting this error:
ERROR SparkUncaughtExceptionHandler: Uncaught exception in thread Thread[Executor task launch worker-0,5,main]
java.lang.NoClassDefFoundError: com/google/common/collect/Iterables
Despite the fact that guava is listed as one of Spark's dependencies. I'm running compiled Spark 1.6 that I downloaded pre-compiled from the apache website.
Thanks!
The error means that the jar containing com.google.common.collect.Iterables class is not in the classpath. So your application is not able to find the required class in runtime.
If you are using maven/gradle , try to clean, build and refresh the project. Then check your classes folder and make sure the guava jar is in the lib folder.
Hope this will help.
Good luck!

Maven java compile error can not access CommonClassA

Background:
I am developing Maven multi module project.
One of the module is common module needed by other all modules.
This module contain CommonClassA.java.
common module is properly compiled.
It is installed into maven local repository properly.
One of the class(Billtype.java) in other module (EmployeeBilling) refers this class(CommonClassA.java).
Maven Dependency for common module is properly specified in pom.xml of EmployeeBilling module.
Problem:
While compiling EmployeeBilling module it throws
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project EmployeeBilling: Compilation failure
[ERROR] \MyWorkspace\Biz\EmployeeBilling\src\main\java\com\employee\Billtype.java:[79,19] error: cannot access CommonClassA
[ERROR] -> [Help 1]**
Supporting details:
dependency defined in EmployeeBilling> pom.xml:
Other classes from common module seems accessible as no error observed
There are no other errors like Class not found/file not found.
The class CommonCLassA implements Serializable
Same error occurs from Eclipse as well as commond line
I am using M2E plugin
Tools:
jdk1.7.0_02
OS: Windows 7
Eclipse JUNO and apache-maven-3.1.0
Thanks in advance!
If project builds properly using eclipse compiler then it should work with Maven.
Few things to check if its not working with maven:
Manually check in repository that jar is installed properly and it contains your class file.
Try to build project using locally installed Maven instead of maven in eclipse.
Set -DskipTest=true while installing your jar, as it can cause issues at times.
If these steps don't work then show us your pom.
With no more information it's hard to find the cause. But I also had this problems now and then, and there are some things which could go wrong:
Are you using the right JAVA version (everywhere) ?
... and the right java PROVIDER? (Oracle, IBM, OpenJDK) In my case it's often this issue, I'm sometimes bound to IBM JDK, although I try to use Oracle where I can and this sometimes breaks my build.
Is the right maven dependency VERSION used? If you depend on it multiple times, and all in the same (lower than root) dept of dependencies, Maven will just "choose" a version. It could be that thát version is incompatible with your code of thát particular dependency
Skipping tests sometimes WORKS! It has something to do with maven phases and getting stuff ready for using it elsewhere.
Good luck :)
I had the same problem. Even the jar dependency has the required class files. Finally I deleted the local maven repo and restarted the build. Now it worked without any issue.
It looks like you are using an old version of maven-compiler-plugin (v2.3.2).
I suggest you upgrade it to 3.x. it won't magically fix your issue but it will definitely give you better / more detailed error message.

Intellij trying to treat pom.xml as jar file

While trying to run test (on a maven project) from Intellij , I am constantly getting below mentioned error
[my-module] Exception in parsing jar file for extract from jar: /path/to/pom.xml java.util.zip.ZipException: The JAR/ZIP file (/path/to/pom.xml) seems corrupted, error: error in opening zip file
However all maven cycles run well when run from the command line.
Has anyone faced this issue before ?
I have already tried all these things
Invalidated Intellij Idea
Deleted my .m2 repo and recreated the project
ok , finally fixed.The osgi facets apparently were responsible.The issue was resolved once the facet was removed.Do not know the exact reason but the intellij osgi facet is known to be unstable. More info here
Even in 2020 this IntelliJ (Ultimate 2019.2) plugin tries to open a pom.xml file as a jar file. Disabling the OSGI plugin helped in my case:

Maven - POM resolves dependencies in Eclipse but not when deploying

I'm pretty new to troubleshooting Maven problems and need some direction. My project is in eclipse and I'm using the m2eclipse plugin. When i import my project to eclipse all dependencies are resolved and its business as usual. However when i deploy to one of my shared environments the mvn deploy is failing due to "package ... does not exist" exception on some Spring components. I'm also seeing alot of "cannot find symbol" issues.
The first thing i checked was the Settings.xml file I used locally against what the shared environment is using and they are the same.
Any suggestions on what else could be causing the deploy to fail? BTW my POM uses teh repositories tag to specify an additional repository however this doesnt seem to be having any affect on the failing deploy.
Thanks,
org.apache.maven.BuildFailureException: Compilation failure
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
Most likely your dependencies are using the wrong scope, which causes the libraries not be be included in e.g. the output war file.
As a first step I would confirm that your build passes on the command line and maybe share your pom file here.

Resources