Bug 717526 - Revert filtering in server/jar
Revert filtering in server/jar
Product: RHQ Project
Classification: Other
Component: Build System (Show other bugs)
Unspecified Unspecified
urgent Severity unspecified (vote)
: ---
: ---
Assigned To: Simeon Pinder
Mike Foley
Depends On:
Blocks: jon3
  Show dependency treegraph
Reported: 2011-06-29 02:41 EDT by Heiko W. Rupp
Modified: 2012-02-07 14:24 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-02-07 14:24:50 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
screen shot of ws version still being correctly set after filter changes (77.21 KB, image/png)
2011-07-29 11:36 EDT, Simeon Pinder
no flags Details
Screenshot (200.87 KB, image/png)
2011-08-01 08:16 EDT, Sunil Kondkar
no flags Details

  None (edit)
Description Heiko W. Rupp 2011-06-29 02:41:46 EDT
Currently in server/jar we filter on *each* build the sources into filtered-sources just to replace one property ( org.rhq.enterprise.server.system.ServerVersion#namespace ) with the pom version, so that webservices know the correct namespace.

This has several negative effects:
- IntelliJ sees target/filtered-sources as a source directory and complains about duplicated classes
- running 'mvn test' twice in a row to debug things, each time compiles all the sources in filtered-sources again, considerably slowing down debugging.

We should put the pom.version into a .properties file, that will just be included in server.jar and where the namespace code then gets its data.
Comment 1 Heiko W. Rupp 2011-06-29 02:48:54 EDT
Actually it turns out, that ServerVersion.namespace is used in a lot of places as a constant , so using a method to obtain the namespace may be no option.
A static class initializer may help here e.g.

    static {
        namespace = System.getProperty("pom.version");

   public static final String namespace;
Comment 2 Ian Springer 2011-06-29 10:21:09 EDT
The CoreServer class in server-jar has an example of loading build properties from the classpath. There is also the MavenArtifactProperties class that I wrote, which provides the ability to load the standard maven build properties file for the specified Maven artifact, e.g.:

MavenArtifactProperties richFacesMavenProps = MavenArtifactProperties.getInstance("org.richfaces.framework", "richfaces-api");
Comment 3 Heiko W. Rupp 2011-06-30 05:19:31 EDT
The static initializer approach from comment#1 is failing:

modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceTypeAdapter.java:[25,46] attribute value must be constant

The compiler sees that the "public static final String namespace" is only initialized in that initializer and not  a real constant.

Can we perhaps use some sed mechanics on release builds to replace the version and otherwise keep the String constant with some "dummy" value -- much like we do with the pom versions?
Comment 4 Lukas Krejci 2011-07-20 10:03:24 EDT
Commit 6a75748bbe847d611f8ecdcf64b09134fde63340 makes this a bit less of an issue. Basically instead of doing resource filtering on the whole src/main/java, I split the code into "normal" and "filtered". The normal code lives under src/main/java and is your ordinary java sources with no special maven attention. The filtered sources live under src/filtered-sources/java and are subject to maven resource filtering. The filtered java files are put into target/filtererd-sources/java which is then set as an additional source directory. Effectively, the sources from src/main/java and target/filtered-sources/java then make up the full source tree and are compiled normally into target/classes.

The advantage of this approach is three-fold:

1) There is a clear separation of source files that need special treatment.
2) The build only recompiles the filtered sources each time it is invoked (even if there were no changes to the source files). This is a big improvement over the former implementation that had to recompile all the sources in server jar each time a build was invoked.
3) Increased compatibility with the Eclipse maven plugin (m2e) that wouldn't handle well the change of the source directory and would force the user to actually edit files in the source directory (that was redefined to be in target) and thus the user would loose changes everytime a maven build would commence. The only special case left are the filtered source files but because it is made explicitly an exceptional kind of a source file, the developer is more easily aware of special treatment needed for it.


To test this, we need to make sure the Web services still define the correct namespace. Simeon, could you please provide more feedback on how to actually do that? I know nothing about our web services infrastructure.
Comment 5 Mike Foley 2011-07-28 16:13:47 EDT
confirmed web services by following these steps:


and then visiting this URL:


this page defines an endpoint as follows:

Endpoint Name 	jboss.ws:context=rhq-rhq-enterprise-server-ejb3,endpoint=WebservicesManagerBean
Endpoint Address 	http://foleymonsterbox1.foleyhomenetwork:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl

but ...

there is no WSDL at this location 

(and I expect there would some WSDL)

Simeon ... could you confirm that this is the correct behavior for web services?
Comment 6 Mike Foley 2011-07-28 16:40:05 EDT
added BZ 726502  https://bugzilla.redhat.com/show_bug.cgi?id=726502 while trying to verify.  discussed with spinder.  verification of this BZ is blocked by BZ 726502.
Comment 7 Simeon Pinder 2011-07-29 11:36:52 EDT
Created attachment 515903 [details]
screen shot of ws version still being correctly set after filter changes
Comment 8 Simeon Pinder 2011-07-29 11:37:29 EDT
Fixed BZ 726502 and verified that Webservice version is still being correctly set.  See attached screenshot.  Nice work Lukas.

Moving to ON_QA.
Comment 9 Sunil Kondkar 2011-08-01 08:15:43 EDT
Verified on build#231 (Version: 4.1.0-SNAPSHOT Build Number: c4a82bc)

1. Followed the steps in:


2. Visited this URL:  https://localhost:7443/jbossws/services

3.  Clicked on:

4. Verified that the namespace in the WSDL is displayed as:


Please refer the attached screenshot.

Marking as verified.
Comment 10 Sunil Kondkar 2011-08-01 08:16:10 EDT
Created attachment 516123 [details]
Comment 11 Mike Foley 2012-02-07 14:24:50 EST
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE

Note You need to log in before you can comment on or make changes to this bug.