Unknown error in maven pom.xml when using intelliJ - java

so I recently installed maven in my pc. Did a little maven project with the guide of an online course in Udemy but I didn't get to finish it. My problem here is when I try to open maven in IntelliJ, pom.xml looks like this and I'm scared that this might cause a problem when I start another project on web dev using Java, SpringBoot, and RestAPI. I'm new to this so I'm not sure what to fix and make sure I will not face any errors. Thank you so much and looking forward to your helpful response.

It can be known from the error message that the reason for this error is because you did not add a constraint file for the xml file, so IDEA is prompting you to add a constraint space for the xml file.
You should check the constraint format of maven's pom.xml file and add it to your pom.xml file.
Another thing to know is that IDEA will use the built-in maven by default instead of the maven you downloaded. If you want to use the maven you downloaded, you should go to the settings to modify the maven configuration. (Of course you can use maven that comes with IDEA).

Related

I have created a library but can not create instance of any class from the library. What might be the problem and what should I do to solve it?

Recently I have worked on a spring boot application and after completing my boss asked me to make this project a library since we are going to use it on some other applications. Hence I make the jar of the project using gradle bootjar command and did all necessary steps defined here for uploading it to maven central (You guys can check:- artifact: heaven-communication; groupid: com.github.aasthalife). Now here comes the problem. When I add the dependency of that library I just created in my other demo application build.gradle file everything seems ok but when I want to create any instance of any class of the library, it shows in suggestion (my IDE is intellij-community edition) but after selecting, it is underlined in red. It says to import class but I already did. What is the problem here? I appreciate your time. Thanks
Sorry guys, I have found the mistake that I have done making the jar file of the library. I did not add: "jar{enabled=true}" command in my build.gradle file. I thought gradle jar command takes care of everything, but no. So, that is why it did not create any proper jar. After adding the command and running gradle jar command I solved this issue. Thank you all for your time.

How to build my EAR project using Maven from Command Line? [Possible duplicate]

I have a problem in front of me, witch I have no idea of how to start with, but let me first explain myself.
First, I found this post:
Maven2: Best practice for Enterprise Project (EAR file)
There is a similar problem to be solved, but If I am not mistaken, there is a word of 3 Maven projects that mentions Mike Cornell, who were answering the question. This part is not the same with me, and therefore, I cant use his answer. Or maybe I can?
I got two encapsulating EAR projects, each of them encapsulates a separate EJB and WAR project
Now, I worked with Ant so far, but I am forced to use Maven, and have no idea how to do it.
My workspace looks like this:
EAR-A
EJB-A
WAR-A
EAR-B
EJB-B
WAR-B
So, there is no Maven at all, and I looked on this post:
https://docs.jboss.org/tools/3.3.0.Final/en/maven_tools_reference_guide/html/adding_maven_support.html
To add maven support to an existing project, In witch case, I would be able to use the answer from Mike Cornell, that I mentioned above, BUT there is a problem.
My EJB-A and WAR-A depend on each other (I got a WsEndPoint there, for web-socket reasons, and therefore I have added each of them into the others build path), and when I follow the steps, of the converting to a Maven project, there is the step in the wizard that shows all dependencies of the project, there is a missing dependency, if I am in the EJB-A project, there is a missing dependency(error or could not find or something like that(cant remember...sorry)) of the WAR-A project, and the same when I do it with the WAR-A project, there is the same issue with the EJB project.
That was the reason I stopped, because, I was not sure how to deal with that.
My Maven looks like this:
As mentioned in the title, I need to do this from the command line.
That is to build the EAR with the EJB and the WAR projects all together.
I work in the command line from the workspace, where all the projects are located, and hope that you can help me. Thanks.
Ok, here is a solution I found and it worked for me.
First, I removed each project from the others build path, this way, they don't see each other.
Then in eclipse, I converted the projects to maven, and got the pom.xml file(s)
Then, I installed the projects with: mvn install
This way, I got the projects into my local repository and could add them as dependencies to my other projects pom file
That worked for me, I hope this will be helpful to the other guy with a similar issue.

How to import git java project to Eclipse

I've tried every option explained step by step here and here: and here
And I can't get it to work.
What I want to do is pick this project: , however it may be done (I've tried both through maven and git), and use its code in eclipse. And what I mean by that, is that I get to the point of seeing the folders in eclipse, but I can't create packages since it's not a java project, and if I mess up the code on the files that appear, it doesn't give me a warning nor in general interacts with said code.
So I guess I'm missing some piece of knowledge and I don't know where else to look for it. What should I do to use that project in my eclipse, and create my own code that calls and uses the classes and methods from said project?
Thank you in advance.
Just download it with git, then import it as a maven project. If this fails, create new "java project from existing sources", pointing as a source the simmetrics-core/src and simmetrics-example/src directories. If it fails, point separately simmetrics-core/src/main, simmetrics-core/src/test etc.
Since this artifact is present in the maven repository (https://mvnrepository.com/artifact/com.github.mpkorstanje/simmetrics/4.1.1), you can create your own new maven project in Eclipse and add simmetrics as a dependency to it in its pom.xml file
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics</artifactId>
<version>4.1.1</version>
</dependency>
This will put simmetrics to the classpath of your own project and you should be able use its API

Failed make using IntelliJ, JBoss due to multiple configuration issues including Pom.xml

Introduction
I have inherited a project that I am able to build using the maven command mvn clean install -DskipTests. However, I am not able to make using the inteliJ button. I am able to deploy the project using Remote debugging but I am not able to hotswap new code in/out due to make not working.
Errors during make
When I run make I get a series of errors such as:
Older Maven Version
I have been told to use an older version of maven, specifically 3.0.3 .
I have gone to the settings for the current project and manually set maven 3.0.3 as the default.
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Red Highlighting in POM.XML
I am seeing that InteliJ is highlighting a pom.xml in one of the sub-modules for errors. This code has been committed by colleagues so it is strange that there would be errors.
and
and
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Maven > Reimport does not solve the issue
Additionally, running Maven > re-import does not solve the issue.
Updating Indices
I tried selecting the proposed option to Update Maven Indices. This has brought up the following dialogs and is downloading in the background from both the maven servers but also a private artifactory.
The indices were taking too long to update so I invalidated the cache/restarted and will try again as proposed # Intelli J IDEA takes forever to update indices .
Summary of Questions
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Update
Indices finished downloading after some time.
I removed some of the problematic entries in the pom.xml and the project now is not red-underlying the various packages that they do not exist.
I am starting to believe the pom.xmlwas problematic. However, if someone downloads the dependencies/indices, then the problem no longer appears.
Update - Remove Module
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.

maven gae plugin questions

I'm having some issues making the maven google app engine plugin work properly.
First of all, I'm not even sure if the archetype I'm using is the correct one, their examples show version 0.7.0 but it seems like never versions exist (i tried 0.9.1 and that works), where can I find a overview of what versions of the plugin is available?
Secondly, the archetype seems.. messy, I don't like the package structure and it doesn't seem to actually include the GAE and GWT dependencies. I have to manually add them to my project in Eclipse, which kind of defeats the purpose of using maven. And how come they are breaking the gwt maven plugin? I know that one includes the actual gwt jars as maven dependencies?
I'm fairly new to Maven, but I have been using the gwt maven plugin for a while, and I'm very happy with everything about it. Is there any way I could just their archetype to do the base project and add the gae plugin to it?
UPDATE
I suspect the problem I'm seeing with the GAE maven plug-in is in regards to undefined properties in the POM. I have no idea if its due to error these aren't set-up or if its due to me actually have to manually set them up. The documentation on this plugin is sparse.
Thanks for the answer below, but I really don't want to add another archetype into play. I think the best solution for me is to try and adapt a GWT maven project manually, to include support for GAE.
I've used the archetype like so :
http://code.google.com/p/gae-mvn-archetype/
to generate a GAE project template.Then manually added my other dependencies. This got me a usable project which I can deploy to GAE and everything.
Also, for Eclipse importing, once the template project was done, I've imported it into eclipse using the m2_eclipse plugin :
http://m2eclipse.sonatype.org/installing-m2eclipse.html
(note that i've imported it into Eclipse as a Maven project, NOT as an Eclipse whatever project)
This imported the thing into eclipse with all the necessary dependencies and without errors.

Categories