Using Maven to download drools sources - eclipse

I'm new to maven and drools, so this could be obvious...
I'm trying to work off of the drools snapshot repository using maven/eclipse. I'd like to be able to link the sources/javadoc when updating using maven but I keep getting messages similar to:
Can't download java-source for artifact org.drools:drools-process-task:5.1.0.20091223.193911-177
Any idea what I'm doing wrong?

I created a simple project to reproduce this error and, using the following 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>maven-drools-testcase</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-drools-testcase</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>repository.jboss.org</id>
<url>http://repository.jboss.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots.jboss.org</id>
<url>http://snapshots.jboss.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.M1</version>
</dependency>
-->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I wasn't indeed able to download the sources from eclipse (which are in the repository!). This works fine with version 5.1.0.M1 though so there must be a problem with the JBoss Snapshots Repository (maybe the metadata?). You should open an issue at Drools Jira.
UPDATE: I did a bit more testing and, strangely, if I add the following dependency in the pom.xml:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.SNAPSHOT</version>
<classifier>sources</classifier>
</dependency>
The sources JAR gets properly downloaded.
As I said, I'm don't know exactly what is the root cause of the problem and wonder if this is not a problem with m2eclipse after all. Actually, you should maybe try to open an issue in M2Eclipse Jira first and see if they detect a problem with their code or with the JBoss Snapshot repository (in which case they will send you to Drools Jira I guess).

Before drools 5.2.0.Final (released 2 years ago), the maven poms were a mess and source jars didn't get uploaded correctly. That's fixed in 5.2, 5.3, 5.4, 5.5, ...
Upgrade to drools 5.5.0.Final.

Related

Keycloak API call dependency for Red Hat SSO 7.3.0.GA

I am calling keycloak api in my project using below code. It is working in Keylcloak 7.0.1. But, it is not working RedHat SSO 7.3.0.GA
Keycloak kc = KeycloakBuilder.builder()
.realm(MASTERREALM)
.username(USERNAME)
.password(PASSWORD)
.serverUrl(SERVER_URL).clientId(CLIENT_ID)
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()).build();
UsersResource usersResource = kc.realm(REALM).users();
This is working fine when connecting to Keycloak 7.0.1 using below dependencies
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.7.0.Final</version>
</dependency>
<!-- Keycloak api dependencies -->
List<UserRepresentation> listUserResource = usersResource.search(strUserName);
My questions:-
1) when I try to connect Red Hat SSO 7.3.0.GA what dependencies I have to use.
I have tried use below dependency. it is throwing maven build error of dependencies are not available in central repository. Since, This artifact is located at Redhat GA repository.
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.0.redhat-00002</version>
</dependency>
2) How to define Redhat GA repository in pom.xml file
Thanks in advance
From the RedHat docs, include the following in your ~/.m2/settings.xml file:
<!-- Configure the JBoss Enterprise Maven repository -->
<profile>
<id>jboss-enterprise-maven-repository</id>
<repositories>
<repository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
assuming that you have access to the JBoss EAP Maven repository. You'll need to either enable the jboss-enterprise-maven-repository profile on the command line with mvn -Pjboss-enterprise-maven-repository <target> or by adding:
<activeProfiles>
<activeProfile>jboss-enterprise-maven-repository</activeProfile>
</activeProfiles>
to your ~/.m2/settings.xml file.

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

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>

POM dependencies not working (Eclipse, Maven, POM)

I have a project in Eclipse (Helios), with Maven pom.xml.
My project is a web app that will use Hibernate, MySQL.
But i have endless woes in getting pom.xml right. I am new to maven, and can't believe setting up dependencies is so tough(do others have similar expierience / or am i dumb).
My pom.xml is here:
<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>MyProj1</groupId>
<artifactId>MyProj1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<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>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>Scala Tools</id>
<name>Scala Tools</name>
<url>http://scala-tools.org/repo-releases/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.4.Final</version>
</dependency>
<!--
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.6.4.Final</version>
</dependency>
-->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.6-brew</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1-jboss</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.16</version>
</dependency>
</dependencies>
</project>
The error i get is:
Missing artifact commons-logging:commons-logging:jar:1.1.1:compile
Missing artifact org.hibernate:hibernate-entitymanager:jar:3.6.4.Final:compile
Missing artifact javassist:javassist:jar:3.12.0.GA:compile
Missing artifact org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
Missing artifact org.slf4j:slf4j-api:jar:1.6.1:compile
Missing artifact org.hibernate:hibernate-core:jar:3.6.4.Final:compile
Missing artifact commons-collections:commons-collections:jar:3.1:compile
Missing artifact org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
Missing artifact javax.transaction:jta:jar:1.1:compile
Missing artifact antlr:antlr:jar:2.7.6-brew:compile
Missing artifact dom4j:dom4j:jar:1.6.1-jboss:compile
Missing artifact xml-apis:xml-apis:jar:1.0.b2:compile
Missing artifact asm:asm:jar:1.4.3:compile
Missing artifact cglib:cglib:jar:2.1.1:compile
---
All the above errors go away, if i remove the mysql dependency from the pom.xml file.
I am totally confused why mysql should have dependency on these.
Isn't Maven supposed to resolve these dependencies automatically? Afterall isn't that the whole idea of using Maven.
Experts please guide me in the right direction.
You can search for dependencies here:
http://mvnrepository.com
For Maven2 it is:
http://repo1.maven.org/maven2/
Hibernate in particular is notoriously difficult for setting up the right dependencies.
See: How can I use Maven to get the latest Hibernate release?

Maven for javaee-api

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).