Intellij trying to treat pom.xml as jar file - maven

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:

Related

Maven and intellijIDEA

Today I found disattached maven libraries in IDEA project,
went through file->settings->pluggins, marked disbundled 'maven', restarted IDEA. Nothing
changes. Json etc still reddish. Any ideas?
I’ve configured the project by adding a new Maven module and copied the pom.xml file into it once again. Now it works fine.
More information on how to convert a project to Maven is described in the documentation: https://www.jetbrains.com/help/idea/convert-a-regular-project-into-a-maven-project.html

Importing to IntelliJ - Error package org.springframework.boot does not exist

Dear Stackoverflow Community, I have the following problem with my spring boot starter application. I imported the starter project as a new maven project into IntelliJ. But IntelliJ does not find the dependencies I specified in the pom.
Image of my Application Class:
If I try to run the project I get the following error message.
Image of the Error Message:
I already tried everything from re-installing IntelliJ to re-importing the project or redownloading the dependencies. I simply dont know why IntelliJ doesn´t find the dependencies.
My pom.xml looks as following
Image of my pom.xml:
The first time I tried to edit the pom.xml it said to me "this file does not belong to the project". Maybe this might be one reason.
Running the whole thing with 'mvn install' or 'mvn clean verify' works.
Try this and then build: mvn -U idea:idea
Had the same problem. I have tried everything: invalidating cache, deleting the whole .m2 folder, changing settings, reloding the project, nothing helped.
The solution for me was to delete the .iml files which are IntelliJ module files used for keeping module configuration. After reopening the project it worked.
The idea was not mine, I found the hint here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/203365204--package-does-not-exist-error-despite-autocomplete-being-aware-of-them
Sometimes your workspace could get corrupted.
In my case, I tried to Reload the project and it worked
in my case changed JDK version in Maven importer from JDK 11 to my local JDK version 1.8
Here is how my IntelliJ settings for spring boot application looks like
Click open -> browse your workspace -> and select POM.xml file
Check this in your intelliJ settings
Do this too [Settings --> Maven --> Importing]
I just had the same issue. My solution was to remove all dependencies from the pom, reload via maven -> Reload All Maven Projects. Run mvn compile. Add dependencies back to the pom, maven -> Reload All Maven Projects. Run mvn compile.
Now the Intellij build works.
You need to change Maven's JDK for importing option from Project JDK to the Path variable for Java on your machine.
You can get to this by going to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing. Scroll down to the bottom and look for JDK for importing:. Select from the list the path variable for JAVA.
For Windows users, JAVA_HOME should be an option in the drop-down list.
Follow these steps, your problem should be solved. You just need to add Spring-framework-starter-web and Spring-framework-starter-tester from your pom.xml file.
Got to generate(ALT+Insert)
Add dependencies
Search "springframwork"
Add...
Here is the link
In my case, adding the project as maven project helped .

JNI Error followed by Java Error when opening exectuable-jar

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.

Maven Project in Eclipse `org.springframework cannot be resolved to a type` from target path

I've rolled onto a maven project that when I run mvn clean install from command line builds and runs fine. I had this project displaying in Eclipse without errors earlier in the week before I hosed my system. This makes me think I have a configuration wrong and hoping someone can give me a sanity check.
Inside of Eclipse, I'm seeing reported errors related to org.springframework cannot be resolved to a type in files in paths like <project_path>/target/<project>-<version>/WEB-INF/... What is catching my eye is that path of target which is a derived folder.
Maven Dependencies Showing:
Facets Enabled:
Project Explorer View:
From the above screenshots, you can see that the related jar files are pulled properly from the maven dependencies. Any ideas on what I have misconfigured and why I'm seeing the errors from the target path?
The build and WebContent folders indicate that you haven't properly imported Maven project into the Eclipse, hence errors.
One of the way to fix this:
Delete project from the Eclipse.
Go to project folder and delete all not needed folders. (Leave src).
Go to Eclipse click File -> Import..., select Existing Maven Projects, select your project folder, Finish.

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