[
https://issues.jboss.org/browse/DROOLS-1051?page=com.atlassian.jira.plugi...
]
Matteo Mortari commented on DROOLS-1051:
----------------------------------------
Description of proposed patch.
In {{KieRepositoryScannerImpl}} :
{code}
private Map<ReleaseId, DependencyDescriptor> indexAtifacts(ArtifactResolver
artifactResolver) {
Map<ReleaseId, DependencyDescriptor> depsMap = new HashMap<ReleaseId,
DependencyDescriptor>();
for (DependencyDescriptor dep : artifactResolver.getAllDependecies()) {
Artifact artifact = artifactResolver.resolveArtifact(dep.getReleaseId());
log.debug( artifact + " resolved to " + artifact.getFile() );
if (isKJar(artifact.getFile())) {
depsMap.put(dep.getReleaseIdWithoutVersion(), new DependencyDescriptor(artifact));
}
}
return depsMap;
}
{code}
problem is that if the dependency "dep" is not resolvable at runtime, the method
{{artifactResolver.resolveArtifact(...)}} will return a null, and in turn a NPE, and in
turn will fail the initialization of the KieScanner.
Proposal is to null guard the rest of the above mentioned code - if the variable
"artifact" is not resolved, not considered as a KJar.
The ideal would be to have also the scope in the dependency/artifact information, so to
check for this specifically, but frankly couldn't locate this data to propose a better
patch for now - in case just reject it and let me know a few pointers I'm keen in
getting it corrected because we have this issue on our projects.
Many thanks.
ps: with the proposed patch:
{code}
2016-02-03 18:09:02,278 INFO [com.acme.run_test_deps.App] (main) start
2016-02-03 18:09:02,306 DEBUG [org.drools.compiler.kie.builder.impl.KieRepositoryImpl]
(main) KieModule Lookup. ReleaseId com.acme:test-deps:LATEST was not in cache, checking
classpath
2016-02-03 18:09:02,306 DEBUG [org.drools.compiler.kie.builder.impl.KieRepositoryImpl]
(main) KieModule Lookup. ReleaseId com.acme:test-deps:LATEST was not in cache, checking
maven repository
[WARNING] The POM for com.acme:onlyfor-test-dep:jar:1.0.0-SNAPSHOT is missing, no
dependency information available
2016-02-03 18:09:05,706 INFO [org.drools.compiler.kie.builder.impl.KieRepositoryImpl]
(main) KieModule was added:
ZipKieModule[releaseId=com.acme:test-deps:1.0.0-SNAPSHOT,file=C:\Users\mmortari\.m2\repository\com\acme\test-deps\1.0.0-SNAPSHOT\test-deps-1.0.0-SNAPSHOT.jar]
2016-02-03 18:09:07,005 DEBUG [org.kie.api.builder.KieScanner] (main)
org.drools:drools-core:jar:6.2.0.Final resolved to
C:\Users\mmortari\.m2\repository\org\drools\drools-core\6.2.0.Final\drools-core-6.2.0.Final.jar
2016-02-03 18:09:07,006 DEBUG [org.kie.api.builder.KieScanner] (main)
org.mvel:mvel2:jar:2.2.4.Final resolved to
C:\Users\mmortari\.m2\repository\org\mvel\mvel2\2.2.4.Final\mvel2-2.2.4.Final.jar
2016-02-03 18:09:07,007 DEBUG [org.kie.api.builder.KieScanner] (main)
log4j:log4j:jar:1.2.17 resolved to
C:\Users\mmortari\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar
2016-02-03 18:09:07,008 DEBUG [org.kie.api.builder.KieScanner] (main)
com.google.protobuf:protobuf-java:jar:2.5.0 resolved to
C:\Users\mmortari\.m2\repository\com\google\protobuf\protobuf-java\2.5.0\protobuf-java-2.5.0.jar
2016-02-03 18:09:07,009 DEBUG [org.kie.api.builder.KieScanner] (main)
org.kie:kie-internal:jar:6.2.0.Final resolved to
C:\Users\mmortari\.m2\repository\org\kie\kie-internal\6.2.0.Final\kie-internal-6.2.0.Final.jar
2016-02-03 18:09:07,011 DEBUG [org.kie.api.builder.KieScanner] (main)
com.thoughtworks.xstream:xstream:jar:1.4.7 resolved to
C:\Users\mmortari\.m2\repository\com\thoughtworks\xstream\xstream\1.4.7\xstream-1.4.7.jar
2016-02-03 18:09:07,012 DEBUG [org.kie.api.builder.KieScanner] (main)
org.slf4j:slf4j-api:jar:1.7.2 resolved to
C:\Users\mmortari\.m2\repository\org\slf4j\slf4j-api\1.7.2\slf4j-api-1.7.2.jar
2016-02-03 18:09:07,013 DEBUG [org.kie.api.builder.KieScanner] (main)
org.drools:drools-compiler:jar:6.2.0.Final resolved to
C:\Users\mmortari\.m2\repository\org\drools\drools-compiler\6.2.0.Final\drools-compiler-6.2.0.Final.jar
2016-02-03 18:09:07,286 WARN [org.kie.scanner.MavenRepository] (main) Unable to resolve
artifact: com.acme:onlyfor-test-dep:1.0.0-SNAPSHOT
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact
com.acme:onlyfor-test-dep:jar:1.0.0-SNAPSHOT in internalmirror
(
http://localhost:8081/nexus/content/groups/public/)
at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at
org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
at org.kie.scanner.MavenRepository.resolveArtifact(MavenRepository.java:216)
at org.kie.scanner.MavenRepository.resolveArtifact(MavenRepository.java:205)
at org.kie.scanner.MavenRepository.resolveArtifact(MavenRepository.java:201)
at org.kie.scanner.ArtifactResolver.resolveArtifact(ArtifactResolver.java:51)
at
org.kie.scanner.KieRepositoryScannerImpl.indexAtifacts(KieRepositoryScannerImpl.java:330)
at
org.kie.scanner.KieRepositoryScannerImpl.setKieContainer(KieRepositoryScannerImpl.java:73)
at
org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieScanner(KieServicesImpl.java:115)
at com.acme.run_test_deps.App.main(App.java:20)
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact
com.acme:onlyfor-test-dep:jar:1.0.0-SNAPSHOT in internalmirror
(
http://localhost:8081/nexus/content/groups/public/)
at
org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at
org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at
org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at
org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at
org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 11 more
2016-02-03 18:09:07,288 DEBUG [org.kie.api.builder.KieScanner] (main)
com.acme:onlyfor-test-dep:1.0.0-SNAPSHOT not resolved.
2016-02-03 18:09:07,289 DEBUG [org.kie.api.builder.KieScanner] (main)
commons-codec:commons-codec:jar:1.4 resolved to
C:\Users\mmortari\.m2\repository\commons-codec\commons-codec\1.4\commons-codec-1.4.jar
2016-02-03 18:09:07,291 DEBUG [org.kie.api.builder.KieScanner] (main)
org.antlr:antlr-runtime:jar:3.5 resolved to
C:\Users\mmortari\.m2\repository\org\antlr\antlr-runtime\3.5\antlr-runtime-3.5.jar
2016-02-03 18:09:07,292 DEBUG [org.kie.api.builder.KieScanner] (main)
org.codehaus.janino:janino:jar:2.5.16 resolved to
C:\Users\mmortari\.m2\repository\org\codehaus\janino\janino\2.5.16\janino-2.5.16.jar
2016-02-03 18:09:07,294 DEBUG [org.kie.api.builder.KieScanner] (main)
org.eclipse.jdt.core.compiler:ecj:jar:4.3.1 resolved to
C:\Users\mmortari\.m2\repository\org\eclipse\jdt\core\compiler\ecj\4.3.1\ecj-4.3.1.jar
2016-02-03 18:09:07,295 DEBUG [org.kie.api.builder.KieScanner] (main)
xpp3:xpp3_min:jar:1.1.4c resolved to
C:\Users\mmortari\.m2\repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar
2016-02-03 18:09:07,296 DEBUG [org.kie.api.builder.KieScanner] (main) junit:junit:jar:4.11
resolved to C:\Users\mmortari\.m2\repository\junit\junit\4.11\junit-4.11.jar
2016-02-03 18:09:07,297 DEBUG [org.kie.api.builder.KieScanner] (main)
org.slf4j:slf4j-log4j12:jar:1.7.2 resolved to
C:\Users\mmortari\.m2\repository\org\slf4j\slf4j-log4j12\1.7.2\slf4j-log4j12-1.7.2.jar
2016-02-03 18:09:07,298 DEBUG [org.kie.api.builder.KieScanner] (main)
org.hamcrest:hamcrest-core:jar:1.3 resolved to
C:\Users\mmortari\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
2016-02-03 18:09:07,299 DEBUG [org.kie.api.builder.KieScanner] (main)
xmlpull:xmlpull:jar:1.1.3.1 resolved to
C:\Users\mmortari\.m2\repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar
2016-02-03 18:09:07,301 DEBUG [org.kie.api.builder.KieScanner] (main)
org.kie:kie-api:jar:6.2.0.Final resolved to
C:\Users\mmortari\.m2\repository\org\kie\kie-api\6.2.0.Final\kie-api-6.2.0.Final.jar
RUNNING
{code}
is working OK, the KieScanner do initialize, enabling DEBUG in the log shows the 10second
timeout for check for updates, and the last line is showing the status of the KieScanner
indeed as running.
KieScanner does not initialize if missing to locate a kjar dependency
of test scope
-----------------------------------------------------------------------------------
Key: DROOLS-1051
URL:
https://issues.jboss.org/browse/DROOLS-1051
Project: Drools
Issue Type: Bug
Affects Versions: 6.2.0.Final, 6.3.0.Final
Reporter: Matteo Mortari
Assignee: Mark Proctor
Priority: Minor
Attachments: reproducer-DROOLS-1051.zip
I will attach PR for proposal of patch for {{KieRepositoryScannerImpl}}.
I will attach reproducer code.
Suppose a kjar has a _test_ scope dependency which may not be resolvable at runtime; the
KieContainer will be created correctly (warning raised in log) but the initialization of
the KieScanner fail with NPE.
Expected behavior: also the KieScanner shall be able to initialize if the KieContainer is
working correctly.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)