Maven for javaee-api - eclipse

I use the latest m2eclipse to generate a standard ejb project, but then I got an error:
Missing artifact javaee:javaee-api:jar:5:provided
The pom.xml is as follow:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>IMS-LEXXWAR</groupId>
<artifactId>ims.base.ejb</artifactId>
<packaging>ejb</packaging>
<version>1.0.0</version>
<name>ims.base.ejb JEE5 EJB</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>java.net1</id>
<name>Java.Net Maven1 Repository, hosts the javaee-api dependency</name>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.1</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
<finalName>ims.base.ejb</finalName>
</build>
</project>
What's wrong?

I ended up using this:
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>5.0-2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

This is a weird problem as things are working fine on my machine (c). With the the following repository definition:
<repositories>
<repository>
<id>java-net-m1-repository</id>
<name>Java.net Maven 1.x Repository</name>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
And this dependency:
<dependencies>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
</dependencies>
The artifact gets downloaded by m2eclipse/maven without problems:
1/19/10 3:09:48 PM CET: Downloading java-net-m1-repository : javaee/poms/javaee-api-5.pom
1/19/10 3:09:48 PM CET: Downloaded [java-net-m1-repository] -> http://download.java.net/maven/1/javaee/poms/javaee-api-5.pom
1/19/10 3:09:49 PM CET: Downloading java-net-m1-repository : javaee/jars/javaee-api-5.jar
1/19/10 3:09:52 PM CET: Downloaded [java-net-m1-repository] -> http://download.java.net/maven/1/javaee/jars/javaee-api-5.jar
So I actually don't know what is happening exactly.
To debug it, I'd first switch to the command line. In your case, I'd start by checking the URL from which the artifact is getting downloaded (this should be printed in the console, using the -X option shouldn't be necessary) and try to mimic this download with something like wget.
If you don't find anything obvious, then check the effective POM that you can obtain using the following command:
mvn help:effective-pom
It's hard to point you in a special direction without more details but I would take a look at it (could it be a proxy problem?).
Another idea would be to try to reproduce this problem on another machine/configuration and, if it works, check the differences.
As I said, this should just work. But without a way to reproduce and/or more information, debugging this problem feels like walking in the dark :)

You don't have the artifact installed in the local repository and maven cannot find it in the repositories it knows about either.
The name for javaee.javaee-api looks formal enough but mvnrepository.com does not know anything about it. If it is a jar which you have locally (why would it be called javaee though?), you need to install it in the local mvn repository using the mvn install command (the exact command used for installing is usually provided with that error you've been seeing).

Related

Eclipse oxygen 3 maven doesn't compile java files

I'm new to Maven and I'm trying to create a basic Jersey project with Eclipse Oxygen 3 IDE. For some reason when I run the compile or install goal, the target folder copy the java files, and indeed I don't see that Eclipse/Maven is creating any class file.
The Build/Clean options of Eclipse are disable, and using CTRL+B (compile shortcut) doesn't do anything.
The POM is as follows.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>some.group.id</groupId>
<artifactId>MyName</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Any name</name>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>TargetName</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>/home/someuser/java/bin/javac</executable>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Thanks for every help out there.
Edit
The project is created in Eclipse using "New" -> "Other" -> "Maven" -> "Maven project", and in the file system it doesn't contain a .project file.
Also I added the path of the compiler (see the edited pom.xml above), but the result is the same.

How to resolve 'Offline / Missing artifact org.geotools:gt-shapefile:jar:17-SNAPSHOT' in Maven?

I'm new to Maven and am trying to create a simple Maven project given in geotools.org
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- use the latest snapshot -->
<geotools.version>17-SNAPSHOT</geotools.version>
</properties>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tutorial</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>boundless</id>
<name>Boundless Maven Repository</name>
<url>http://repo.boundlessgeo.com/main</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The error I am getting is 'Offline / Missing artifact org.geotools:gt-shapefile:jar:17-SNAPSHOT'. How do I resolve this? I am using Eclipse Neon.1a Release (4.6.1).There is no option for selecting Project ‣ Update All Maven Dependencies. In some of the similar questions asked here it was recommended to change the repository URL. Which URL shall I change? Java.net repository OR Open Source Geospatial Foundation Repository OR Boundless Maven Repository?
It looks like the Boundless artifactory was down at that moment. For the time being you can use version 16-RC1 as the latest released version, 15.2 as the last stable release.
If you absolutely must be on the cutting edge, I'd recommend downloading/cloning master and building it locally.
I think that instead of ${geotools.version} you should place a real version number of the project, like 15.1
I am not sure though if that's the problem
Also, you might want to consider changing to Gradle build. I think it is a lot simpler

Having issue with pom.xml

I am trying to integrate Selenium TestNG to maven but having trouble in adding dependencies to pom.xml (as described in this article ), and getting error on the same. Issue appears only when I add selenium and testng dependencies, I have already imported those library to the project. Below is xml code
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ProV1</groupId>
<artifactId>ProV1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And this is the error I am getting
As suggested in some articles I cleaned the project, refreshed but nothing worked out.
I am a newbie to Maven so will be very greatfull for all helpful suggestion on how to fix this.
Issue resolved by removing dependencies, there was no need to add dependencies. Maven adds them automatically.

How do you pre-compile Drools rules?

I want to pre-compile my .drl files to .class files so they do not have to be compiled a run time. The documentation makes it sounds like the kie-maven-plugin does this, but it is not generating anything for me. It compiles the rules files but does not output anything. Any suggestions?
I'm using the mvn package command, and my pom.xml file is below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie</groupId>
<artifactId>kie-parent-with-dependencies</artifactId>
<version>6.0.1.Final</version>
<!-- relativePath causes out-of-date problems on hudson slaves -->
<!--<relativePath>../droolsjbpm-build-bootstrap/pom.xml</relativePath>-->
</parent>
<packaging>kjar</packaging>
<artifactId>default-kiesession</artifactId>
<name>Drools API examples - Default KieSession</name>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.0.1.Final</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<repositories>
<!-- Bootstrap repository to locate the parent pom when the parent pom has not been build locally. -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
<scm>
<connection>scm:git:git#github.com:droolsjbpm/drools.git</connection>
<developerConnection>scm:git:git#github.com:droolsjbpm/drools.git</developerConnection>
<url>https://github.com/droolsjbpm/drools</url>
</scm>
</project>
There was a bug in 6.0.1.Final that caused the maven plugin to not save the compiled bytecode inside the kjar. It was fixed after, so if you take the 6.0.2-SNAPSHOT (community) version, or the RedHat BRMS 6.0.1.GA (product) version, it will work.
BZ ticket: https://bugzilla.redhat.com/show_bug.cgi?id=1063255
commit that fixes the bug: https://github.com/droolsjbpm/drools/commit/94b9ccf810100c7ec3f8ed186111720ddb2729d3
FYI, when the correct kjar is generated, it contains a kbase.cache file inside the jar for each defined kbase. These cache files contain the compiled bytecode.
It works for me with kie-maven-plugin 6.1.0.Final, but packaging "kjar" should be specified in order to get KIE base cache inside jar file.
It's described in Drools documentation. Just for anybody who find this as first post for 'precompile gdst' on google ;-).
You have to define generateModel=YES when compiling. On mvn command line -DgenerateModel=YES or in pom.xml inside kie-maven-plugin <configuration> secion with <generateModel>YES</generateModel>

mvn install not installing/embedding dependencies

I have been told that the install goal should mean that my resulting jar file will have all required dependencies included into the deployment. This, however, doesn't appear to be working for me.
Here's my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.zone.commandit</groupId>
<artifactId>CommandIt</artifactId>
<version>0.2</version>
<name>CommandIt</name>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>milkbowl-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2-R1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.26-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-cldc11</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-core</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-interpreter</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-j2se</artifactId>
<version>5.1_2.1.0</version>
</dependency>
</dependencies>
</project>
From this, I expect a CommandIt-0.2.jar file with commons-io and the kahlua libraries (which are installed in the local repository). The bukkit and Vault dependencies should not be included as they are provided in the runtime environment.
However, upon inspecting the project jar file with 7zip, I find only META-INF and my own source code. What am I doing wrong?
You can use the Maven Assembly plugin to generate a JAR containing all your dependencies.
Add the following in the build > plugins section:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
The Maven target to run this plugin is assembly:single.
Maven dependencies are downloaded to the local maven repository, it is usually .m2 directory in your user home directory. Packaging JAR doesn't include any other JARs into the result. If you want to make a web application, use packaging WAR (or EAR). In the WAR file there are your JARs inc. all dependencies included.
mvn install executes plugins which simply put whatever artifacts were built, in this case a JAR file with your code, into your local repository, typically located at ~/.m2/repository.
If you want to assemble something to distribute, like a tarball containing JARs and shell scripts, looking into the Maven assembly plugin. If you want to assemble a single JAR file containing your code and the code in your dependencies, the Maven assembly plugin can be run using the jar-with-dependencies descriptor.