I am using Drools 6.0.1 and making use of the new Maven-based architecture to deploy my rules.
The POM of the project looks like shown at the end of this post.
I start the project with the parameter -Dkie.maven.settings.custom="X:\\maven2\\settings.xml"
to use a separate Maven repository for Drools. That settings.xml is also shown below.
When I run the project (.java shown at the end), the drools-internal maven, namely Aether
, still adds the central repository to its internal configuration. This is bad because obviously the system should run offline.
The output of running then is:
DEBUG [main] (KieRepositoryImpl.java:91) - KieModule Lookup. ReleaseId de.itm.droolstest:x123:1.0.1 was not in cache, checking classpath
DEBUG [main] (KieRepositoryImpl.java:97) - KieModule Lookup. ReleaseId de.itm.droolstest:x123:1.0.1 was not in cache, checking maven repository
DEBUG [main] (Logs.java:390) - Add publisher: com.google.inject.internal.InjectorImpl@784eb2c
-----[explicit bindings]-------------------------------------------------------
0. ProviderInstanceBinding{key=Key[type=com.google.inject.Injector, annotation=[none]], source=[unknown source], scope=Scopes.NO_SCOPE, provider=Provider<Injector>}
1. ProviderInstanceBinding{key=Key[type=java.util.logging.Logger, annotation=[none]], source=[unknown source], scope=Scopes.NO_SCOPE, provider=Provider<Logger>}
2. ProviderInstanceBinding{key=Key[type=org.slf4j.Logger, annotation=[none]], source=[unknown source], scope=Scopes.NO_SCOPE, provider=Provider<org.slf4j.Logger>}
3. InstanceBinding{key=Key[type=com.google.inject.Stage, annotation=[none]], source=[unknown source], instance=DEVELOPMENT}
[...] (many more lines removed for brevity)
202. ConstructorBinding{key=Key[type=org.apache.maven.lifecycle.internal.LifecycleDebugLogger, annotation=[none]], source=ClassRealm[maven, parent: ClassRealm[maven-parent, parent: null]], scope=Scopes.SINGLETON}
-----[implicit bindings]-------------------------------------------------------
-------------------------------------------------------------------------------
INFO [pool-1-thread-1] (NettyAsyncHttpProvider.java:199) - Number of application's worked threads is 8
DEBUG [pool-1-thread-1] (NettyAsyncHttpProvider.java:948) -
Non cached request
DefaultHttpRequest(chunked: false)
HEAD /nexus/content/groups/public/de/droolstest/x123/1.0.1/x123-1.0.1.jar HTTP/1.1
Host: nexus.my-domain.de:8081
Pragma: no-cache
Cache-Control: no-cache, no-store
Accept-Encoding: gzip
Connection: keep-alive
Accept: */*
User-Agent: Aether
using Channel
[id: 0x0fd71519]
DEBUG [New I/O client worker #1-1] (NettyAsyncHttpProvider.java:1048) -
Request DefaultHttpRequest(chunked: false)
HEAD /nexus/content/groups/public/de/itm/droolstest/x123/1.0.1/x123-1.0.1.jar HTTP/1.1
Host: nexus.my-domain.de:8081
Pragma: no-cache
Cache-Control: no-cache, no-store
Accept-Encoding: gzip
Connection: keep-alive
Accept: */*
User-Agent: Aether
Response DefaultHttpResponse(chunked: false)
HTTP/1.1 404 The server has not found anything matching the request URI
Date: Tue, 11 Mar 2014 09:42:48 GMT
Set-Cookie: rememberMe=deleteMe; Path=/nexus; Max-Age=0; Expires=Mon, 10-Mar-2014 09:42:48 GMT
Date: Tue, 11 Mar 2014 09:42:48 GMT
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1533
DEBUG [New I/O client worker #1-1] (NettyConnectionsPool.java:147) - Adding uri: http://nexus.my-domain.de:8081 for channel [id: 0x0fd71519, /192.168.100.113:51272 => nexus.my-domain.de/192.168.100.145:8081]
Exception in thread "main" Exception in thread "FileRepositoryConnector-1" java.lang.IllegalArgumentException: number of transferred bytes cannot be negative
at org.sonatype.aether.util.listener.DefaultTransferEvent.setTransferredBytes(DefaultTransferEvent.java:123)
at org.sonatype.aether.connector.file.FileRepositoryWorker.run(FileRepositoryWorker.java:299)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
java.lang.IllegalArgumentException: number of transferred bytes cannot be negative
at org.sonatype.aether.util.listener.DefaultTransferEvent.setTransferredBytes(DefaultTransferEvent.java:123)
at org.sonatype.aether.connector.file.FileRepositoryWorker.run(FileRepositoryWorker.java:299)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
(The artifact is, of course, in that x:/maven2 repository)
As you can see, the system tries to connect to our own Nexus, which is configured in the global settings.xml
, the one used for building the project.
So, my question(s) would be:
* how can I configure Drools to run its Maven completely offline
* How can I prevent Drools' Maven to take the project's pom.xml
as configuration? That pom.xml
should only be used when building the project, not at runtime! Can that be prevented?
Any help is appreciated!
And now the configuration files.
Project's 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>de.demo</groupId>
<artifactId>kieTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<type>pom</type>
<version>6.0.1.Final</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
The x:\maven2\settings.xml
(the one for drools):
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>x:/maven2/repository</localRepository>
<interactiveMode>false</interactiveMode>
<offline>true</offline>
<profiles>
<profile>
<id>droolsOffline</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
The actual Java class: package kieTest;
import org.kie.api.*;
public class MainKieTest {
public static void main(String[] args) {
KieServices ks = KieServices.Factory.get();
KieRepository repository = ks.getRepository();
ReleaseId releaseId = ks.newReleaseId("de.test.droolstest", "x123", "1.0.1");
KieContainer kieContainer = ks.newKieContainer(releaseId);
}
}