Bug 1319808

Summary: Upgrading container to LATEST version causes exception
Product: [Retired] JBoss BRMS Platform 6 Reporter: Jiri Locker <jlocker>
Component: Kie-ServerAssignee: Mario Fusco <mfusco>
Status: CLOSED WONTFIX QA Contact: Jiri Locker <jlocker>
Severity: high Docs Contact:
Priority: urgent    
Version: 6.3.0CC: kverlaen, lpetrovi, psiroky, tradej
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-01 10:28:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
server.log with NullPointerException
none
server.log with RuntimeException
none
kie-maven-settings.xml
none
Full server.log on DEBUG
none
Maven metadata with snapshots only
none
Maven metadata with snapshots and releases none

Description Jiri Locker 2016-03-21 15:01:27 UTC
Created attachment 1138619 [details]
server.log with NullPointerException

Description of problem:
KIE Server logs exception when a container version is changed to LATEST.

Version-Release number of selected component (if applicable):
6.3.0.ER1

How reproducible:
-

Steps to Reproduce:
1. Start a KIE Server with 'my_server' ID.
2. Log in to Business Central, go to Rule Deployments.
3. Add a container to 'my_server' template. Use any project built and deployed in Business Central.
4. In container's Version Config tab, change its version to 'LATEST' and click Upgrade.

Actual results:
No visible response in UI. Error message in server log. Sometimes it's:

> [org.kie.server.services.impl.KieServerImpl] Error updating releaseId for container 'testcontainer': java.lang.NullPointerException
> 	at org.drools.compiler.kie.util.ChangeSetBuilder.build(ChangeSetBuilder.java:56)

sometimes:

> [org.kie.server.services.impl.KieServerImpl] Error creating container 'testcontainer' for module 'example:test-project:LATEST': java.lang.RuntimeException: Cannot find KieModule: example:test-project:LATEST
> 	at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:117)

Expected results:
No error.

Additional info:

Comment 1 Jiri Locker 2016-03-21 15:02:37 UTC
Created attachment 1138620 [details]
server.log with RuntimeException

Comment 2 Jiri Locker 2016-03-21 15:21:37 UTC
Created attachment 1138639 [details]
kie-maven-settings.xml

I have kie.maven.settings.custom system property pointing to this Maven settings file. Business Central and KIE Server are deployed on the same EAP 6 server so they both use the same settings.

Comment 3 Petr Široký 2016-03-22 23:54:41 UTC
I wasn't able to reproduce this with simple (standalone) kie-server itest (not involving the controller). The container is correctly updated to the "LATEST" version.

This could be related to the custom Maven settings config. 

Would it be possible to get a full server log, ideally with DEBUG enabled?

Comment 4 Jiri Locker 2016-03-23 16:14:52 UTC
I won't be able to get the DEBUG log by the end of this week.

I wonder if https://bugzilla.redhat.com/show_bug.cgi?id=1303018 may be related to this.

Comment 5 Mario Fusco 2016-03-23 16:24:35 UTC
Jiri, I don't think that this issue can be related with that other BZ you linked. If the cause was that I guess it just wouldn't find the last KieModule's version and didn't throw that NPE in the ChangeSetBuilder.

I'm still unable to reproduce this problem so please keep me updated on this.

Comment 6 Jiri Locker 2016-03-29 16:21:01 UTC
Created attachment 1141337 [details]
Full server.log on DEBUG

Attaching full server log on DEBUG level.

Look for two errors:

1) Error updating releaseId for container 'container1': java.lang.NullPointerException
This is after upgrading the container version from 1.0-SNAPSHOT to LATEST.

2) Error creating container 'container1' for module 'org.jboss.qa:remote-kjar:LATEST': java.lang.RuntimeException: Cannot find KieModule: org.jboss.qa:remote-kjar:LATEST
This is logged during server startup after the container was upgraded to LATEST.

Different exceptions but the cause should be same. We investigated with Petr and found out that maven-metadata.xml in repositories/kie/org/jboss/qa/remote-kjar is missing the <latest> tag, which is supposed to contain version of the latest snapshot release. If I build the project with a final version, though, <release> tag is added to maven-metadata.xml and that's why upgrading to RELEASE version works.

Comment 7 Jiri Locker 2016-03-29 16:23:21 UTC
Created attachment 1141338 [details]
Maven metadata with snapshots only

Comment 8 Jiri Locker 2016-03-29 16:24:31 UTC
Created attachment 1141339 [details]
Maven metadata with snapshots and releases

Comment 9 Petr Široký 2016-03-30 15:32:04 UTC
The root cause seems to be hidden somewhere in the deploy code of Aether/Maven. maven-deploy-plugin suffers from the same, so there is likely not much we can do at this point. We need to figure out if this is a bug and if so, report upstream JIRA for Aether/Maven.

Generally, we should discourage people from using LATEST and RELEASE version strings. Maven itself does not support them either and they are bringing a lot of other issues.

Comment 10 Petr Široký 2016-03-31 13:13:58 UTC
I've created reproducer directly in kie-ci: https://github.com/droolsjbpm/drools/pull/710

Comment 11 Mario Fusco 2016-04-01 10:28:16 UTC
I investigated this issue using the reproducer provided by Petr and I agree with him that there's no way to fix this.

In reality this problem looks identical to the one I reported on the Aether mailing-list more than a year ago https://dev.eclipse.org/mhonarc/lists/aether-users/msg00529.html and for which the only answer I received was:

"LATEST is broken by design !!!!"

It also worth to be mentioned that support for RELEASE and LATEST has been deprecated (if not removed) in Maven 3.x since this has the problem of leading to non-reproducible builds https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution

For these reasons we strongly suggest to also deprecate support for these metaversions label in BRMS 6.3 and totally remove it in 7.x.

Comment 12 Lukáš Petrovický 2016-04-01 10:30:45 UTC
Tomas, can we have this documented somewhere? (The fact that LATEST is problematic and should not be used in Maven projects?)

Comment 13 Tomas 'Sheldon' Radej 2016-04-05 09:25:36 UTC
Created issue https://issues.jboss.org/browse/BXMSDOC-256 .