Maven and Eclipse: project build error dependency - java

I just started working with Maven, and I've ran into several issues.
The latest is that one:
Project build error: 'dependencies.dependency.version' for com.github.koraktor:steamcondenser:jar is missing.
I'm running eclipse for Java Developers, with m2eclipse plugin, on Windows 7 x64.
What I'm trying to do is install this API into my project:
https://github.com/koraktor/steam-condenser-java
I have been googling for the last hour with no success. What am I supposed to do?
I tried adding the dependency from both the eclipse plugin and the pom.xml itself, but it didn't help.
EDIT:
Thanks everyone, as you said, all I had to do was including the version in the pom.xml.

Maven needs a "version" specifier in the dependency.
I use http://mvnrepository.com a lot to get the real Maven code for a given project. In this case, it's at: http://mvnrepository.com/artifact/com.github.koraktor/steam-condenser/1.2.0.
Here's their version of the dependency:
<dependency>
<groupId>com.github.koraktor</groupId>
<artifactId>steam-condenser</artifactId>
<version>1.2.0</version>
</dependency>

Related

Intellij recognizes maven dependency as SNAPSHOT

I am using Intellij IDEA 2021.3.1 Community edition on Linux for one of my Maven project. In the pom.xml file, there is a dependency with system scope having version 3.0-20211116.183306-362 as mentioned below:
<dependency>
<groupId>com.wd.xml</groupId>
<artifactId>wdXml</artifactId>
<scope>system</scope>
<systemPath>/home/mylib/wdXml-3.0-20211116.183306-362.jar</systemPath>
<version>3.0-20211116.183306-362</version>
</dependency>
The pom.xml does not have any issue, and mvn package command runs fine. However, the editor shows compilation errors in the Java class using this dependency.
Upon hours of digging, I found that in the 'Project Dependencies View' Intellij lists this dependency as com.wd.xml:wdXml:3.0-SNAPSHOT instead of com.wd.xml:wdXml:3.0-20211116.183306-362.
UPDATE
I believe it is because of this Maven convention
version if you distribute it, then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...). Don't use dates as they are usually associated with SNAPSHOT (nightly) builds. If it's a third party artifact, you have to use their version number whatever it is, and as strange as it can look. For example,
2.0, 2.0.1, 1.3.1
How do I resolve this? Is there any setting in the IDE that can be tweaked.

Could not find artifact sun-jaxb:jaxb-api:jar:2.2 in central

I am trying to upgrade a project from JDK 7 to JDK 8.
In order to fix some issues during compile time, I needed to upgrade Maven to 3.6.3 as well.
The other issue is fixed with this upgrade however, I am getting the below error during mvn install
Failed to execute goal on project jbossha-PATCH: Could not resolve dependencies for project com.company.wae:jbossha-PATCH:jar:5.1.0.GA: Could not find artifact sun-jaxb:jaxb-api:jar:2.2 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
When I check my m2 repo, the jax-api.jar is present under sun-jaxb folder. If I delete sun-jaxb, it is created again with jax-api.jar.
This dependency is present in a lot pom.xml within the project.
Why the error is saying that it can not find the artifact and is there a way to solve this issue?
Why the error is saying that it can not find the artifact and is there a way to solve this issue?
Because the dependency in the POM files is incorrect. I checked, and there are no official dependencies for "sun-jaxb" in Maven Central.
The correct Maven dependency for the JAXB apis in Java 8 is
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.8</version>
<scope>provided</scope>
</dependency>
as described in "https://stackoverflow.com/questions/63608553". I checked and the artifact is there, as are older and newer versions.
So a good solution would be to update all of the POM dependencies.
Now I presume that you are trying to build was building correctly before you started porting it. (Did you check?) If it was, then it must having been getting the "sun-jaxb:jaxb-api:jar:2.2" dependency from ... somewhere:
It might have been in Maven Central "unofficially" and removed as a result of a clean-up
You (or the previous maintainer) might have installed it directly into the local repo on your build box.
You might have been getting it from another repo; e.g. a corporate Maven repo where someone has previously uploaded it.
It would be a good idea to figure out how it worked before.

Apache Spark Maven POM errors

I am trying out Apache Spark and have a little problem that I am stuck with. I have this JavaSparkHiveExample.java example from the Apache Spark Github together with a pom.xml that I have created as a Maven project in IntelliJ IDEA.
I am able to run other Spark examples (using another simpler POM) but this one is giving me the following errors:
Scala is installed in Idea
I am new with Maven and would therefore appreciate some things I could try in order to solve this problem.
Issue is with the value of $project.version. It is referring to your project' version (2.3.0-snapshot). There isn't any maven dependency with this version in Maven central repository, hence you are facing this issue. Instead of using the project version, you can add a new property like this and refer it for all dependency version
<properties>
<spark.version>1.6.2</spark.version>
</properties>
and then use it in the dependency
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
</dependency>
Make sure the version you are using is available in maven repository
https://mvnrepository.com/

Maven dependencies for IBM Websphere packages

I'm trying to convert a "classic" JAVA EE project, using IBM websphere 8.0.0.5, into a maven multi module project and facing issues with the IBM dependecies.
We use IBM classes from the following packages:
com.ibm.websphere.asynchbeans
com.ibm.websphere.scheduler
com.ibm.websphere.ce.cm
com.ibm.ws.asynchbeans
com.ibm.ws.util.ThreadPool
To get my local project to be compiled I downloaded the was.installer-8.0.0.pm from IBM and installed it to my maven using
mvn install -f "was.installer-8.0.0.pom" -D serverInstallationFolder="C:\Program Files (x86)\IBM\WebSphere\AppServer"
This step was successfull according to command line output.
I then added the following dependencies to my project as described from IBM:
In parent:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
<version>8.0.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
In module:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
</dependency>
But I still can't compile my project as the IBM packages are not found.
Can anyone help me to find and correct a mistake I made?
Edit
After following BevynQ tip from the comments I copied the "was_public.jar" to "was_public-8.0.0.jar" (described at IBM here) and added it to my repository:
mvn install:install-file -Dfile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.jar" -DpomFile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.pom"
I then changed the dependencies to:
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was_public</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was</artifactId>
</dependency>
This helped to get the compiling errors for the imports to com.ibm.websphere done.
What I now have still open is the packages com.ibm.ws.* package. Anyone have an idea?
Edit 2
I added the following dependency and then I was rid of the com.ibm.ws.* import errors.
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>1.0.0</version>
</dependency>
But it still does not compile as now indirectly references can not be found (in my case commonj.work.WorkManager). It seems I need to add further .jars for every single thing. Isn't there an easier way to provide all websphere jars at once as descirbe in the above linked tutorial with the com.ibm.toolsdependency (which do not work)?
In general, com.ibm.websphere are public API for use by applications (this is true of the packages you listed above) which is consistent with these being in was_public.jar
However, com.ibm.ws package is generally product internals. May I ask what interface methods you are using from the com.ibm.ws.asynchbeans package? Maybe there is a public API alternative.
Regarding commonj.work, the only place I can find this in the WebSphere Application Server product image is WAS/plugins/com.ibm.ws.prereq.commonj-twm.jar so it looks like you will need to use that to compile against.
Here's the solution so I solved my dependency problems:
I configured the company repository manager (nexus) as a mirror. In this nexus all ibm packages are present. As you can think that solved the main problem.
I then added the following dependencies according to common maven style:
Dependencies in pom.xml (version numbers extracted to properties):
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>${ibm.ws.runtime.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.ws.prereq</groupId>
<artifactId>commonj-twm</artifactId>
<version>${ibm.ws.prereq.commonj-twm.version}</version>
</dependency>
Sorry I can't provide a "nice" solution that's useable by all people but the answer from njr and the comment from BevynQ helped at lot to get clearer with the problem and helped to solve the problem in a "more manual" way by copying the needed jars by hand.
I was facing this issue as I tried to build a project using Maven version 3.3.9, running on Java version 1.8.0_101, as depicted in the screenshot:
This is how I resolved it: Step 1. Download the commonj.jar from here.
Step 2. Determine which JDK your Maven is using by typing mvn -version in the command prompt.
Step 3. Go to that directory and place the commonj.jar file there in the jre/lib/ext directory, as shown below. Now your project should build in maven without any issues.

Missing artifact com.google.android:android:jar:4.4_r1

I'm trying to use Android 4.4_r1 and Maven for a project but for some reason the version maxima maven let me use is 4.1.1.4
I know it is not possible redristribucion android.jar and therefore the necessary maven-android-sdk-deployer, I've cloned the project and have run the command
mvn clean install -Pall,with-javadoc
and install all libraries, later when i edit the pom.xml file i get the following error
Missing artifact com.google.android:android:jar:4.4_r1
I've checked into the path ~/.m2/repository/com/google/android/android and i can see the following versions
1.5_r4 2.2.1 2.3.1 4.1.1.4 4.2.2_r2 4.3_r2 4.4 4.4_r1
What am I doing wrong?
From https://github.com/mosabua/maven-android-sdk-deployer -
The android.jar artifacts in Maven central are available with the
groupId com.google.android, whereas this tool uses android.android to
avoid overlap.
This means that when using the Maven Android SDK deployer your pom.xml should reference the artifact like this -
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.4.2_r2</version>
<scope>provided</scope>
</dependency>
Note: the 4.4_r1 is no longer shipped in the Android SDK as it has been replaced by 4.4.2_r2.
The 4.1.1.4 version was the last com.google.android:android version uploaded to Maven Central, that's why it's the latest one you can reference using com.google.android:android.

Categories

Resources