Camel
  1. Camel
  2. CAMEL-3773

Apache Camel version banner is wrong in uber-jar

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: 2.7.0
    • Component/s: camel-core
    • Labels:
    • Patch Info:
      Patch Available

      Description

      At context start a version banner is printed to the log:
      Apache Camel 2.6.0 (CamelContext: camel) started in 2.436 seconds
      The version string is calculated by ServiceSupport.getVersion():

      Package aPackage = getClass().getPackage();
      if (aPackage != null) {
          version = aPackage.getImplementationVersion();
          if (version == null) {
              version = aPackage.getSpecificationVersion();
          }
      }
      

      but, in Maven shade-plugin packaged project (to create single uber-jar for distribution to SE environment), the Manifest versions are project version, not Camel. So the wrong version is printed. It would be nice to have this improved to print real Camel version.

        Activity

        Hide
        Willem Jiang added a comment - - edited
        Apache Camel 2.6.0 (CamelContext: camel)
                                          ~~~~~~ This is the camel context name.
        ~~~~~~~~~~~~~~~~~~ This is camel version. 
        
        Show
        Willem Jiang added a comment - - edited Apache Camel 2.6.0 (CamelContext: camel) ~~~~~~ This is the camel context name. ~~~~~~~~~~~~~~~~~~ This is camel version.
        Hide
        Claus Ibsen added a comment -

        Uber JARs is not supported. You should use the individual JARs we distribute.

        Show
        Claus Ibsen added a comment - Uber JARs is not supported. You should use the individual JARs we distribute.
        Hide
        Claus Ibsen added a comment -
        Show
        Claus Ibsen added a comment - Btw there is a FAQ about the uber JAR issue http://camel.apache.org/why-do-camel-throw-so-many-noclassdeffoundexception-on-startup.html
        Hide
        Arkadi Shishlov added a comment -

        For the reference, here is my Maven shade plugin setup, which allows me to build fully working Camel uber-jar.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifactSet>
                            <excludes>
                                <exclude>org.jboss.seam:jboss-seam</exclude>
                            </excludes>
                        </artifactSet>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <manifestEntries>
                                    <Main-Class>com.tieto.cih.core.main.Main</Main-Class>
                                    <Specification-Vendor>Tieto</Specification-Vendor>
                                    <Implementation-Vendor>Tieto Latvia</Implementation-Vendor>
                                </manifestEntries>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.schemas</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/services/org/apache/camel/TypeConverter</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
        
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/maven/plugin.xml</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/spring.tooling</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/info.xml</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/DISCLAIMER</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/README.txt</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/DEPENDENCIES</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/LICENSE</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/LICENSE.txt</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/NOTICE</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                <resource>META-INF/NOTICE.txt</resource>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        

        You might want to add this to FAQ to replace misleading answer.
        Rejecting uber-jar distribution as a valid target is very inconvenient for SE deployment scenarios.

        Attached patch is not exactly what the original getVersion() provided, but very close if we take in account current versioning scheme.

        Show
        Arkadi Shishlov added a comment - For the reference, here is my Maven shade plugin setup, which allows me to build fully working Camel uber-jar. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <excludes> <exclude>org.jboss.seam:jboss-seam</exclude> </excludes> </artifactSet> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>com.tieto.cih.core.main.Main</Main-Class> <Specification-Vendor>Tieto</Specification-Vendor> <Implementation-Vendor>Tieto Latvia</Implementation-Vendor> </manifestEntries> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/services/org/apache/camel/TypeConverter</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/maven/plugin.xml</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/spring.tooling</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/info.xml</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/DISCLAIMER</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/README.txt</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/DEPENDENCIES</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/LICENSE</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/LICENSE.txt</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/NOTICE</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/NOTICE.txt</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> You might want to add this to FAQ to replace misleading answer. Rejecting uber-jar distribution as a valid target is very inconvenient for SE deployment scenarios. Attached patch is not exactly what the original getVersion() provided, but very close if we take in account current versioning scheme.
        Hide
        Claus Ibsen added a comment -

        Thanks for the patch.

        However with loading resources using classloader can unfortunately be a bit tricky depending on the host platform.
        For example OSGi, JBoss, J2EE app servers etc may not work as easily as you would have thought.

        So we need to test your patch that it works seamless. Which it ought to do as you load a resource from within the same JAR that the given class is from. But we have seen issues in the past.

        Show
        Claus Ibsen added a comment - Thanks for the patch. However with loading resources using classloader can unfortunately be a bit tricky depending on the host platform. For example OSGi, JBoss, J2EE app servers etc may not work as easily as you would have thought. So we need to test your patch that it works seamless. Which it ought to do as you load a resource from within the same JAR that the given class is from. But we have seen issues in the past.
        Hide
        Claus Ibsen added a comment -

        trunk: 1080929.

        Show
        Claus Ibsen added a comment - trunk: 1080929.
        Hide
        Chris Wolf added a comment -

        I was able to create an uber-jar. My Shade plugin configuration is similar to Arkadi Shishlov's, but since some of my dependencies are signed jars, I needed to filter out the signatures. Here's my configuration:

              <plugin>
                <!-- create single, executable Jumbo Jar containing all the dependencies -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.5</version>
                <executions>
                  <execution>
                    <phase>package</phase>
                    <goals>
                      <goal>shade</goal>
                    </goals>
                    <configuration>
                      <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                          <mainClass>demo.camel.tools.JMSWebMonitor</mainClass>
                        </transformer>
                        <!-- prevents multiple spring.handlers and spring.schemas from over-writing each other (will append instead) -->
                        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                          <resource>META-INF/spring.handlers</resource>
                        </transformer>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                          <resource>META-INF/spring.schemas</resource>
                        </transformer>
                      </transformers>
                      <filters>
                        <!-- filter out jar signatures from shaded jars -->
                        <filter>
                          <artifact>*:*</artifact>
                          <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                          </excludes>
                        </filter>
                      </filters>             
                    </configuration>
                  </execution>
                </executions>
              </plugin>
        
        Show
        Chris Wolf added a comment - I was able to create an uber-jar. My Shade plugin configuration is similar to Arkadi Shishlov's, but since some of my dependencies are signed jars, I needed to filter out the signatures. Here's my configuration: <plugin> <!-- create single, executable Jumbo Jar containing all the dependencies --> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-shade-plugin </artifactId> <version> 1.5 </version> <executions> <execution> <phase> package </phase> <goals> <goal> shade </goal> </goals> <configuration> <transformers> <transformer implementation= "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > <mainClass> demo.camel.tools.JMSWebMonitor </mainClass> </transformer> <!-- prevents multiple spring.handlers and spring.schemas from over-writing each other (will append instead) --> <transformer implementation= "org.apache.maven.plugins.shade.resource.AppendingTransformer" > <resource> META-INF/spring.handlers </resource> </transformer> <transformer implementation= "org.apache.maven.plugins.shade.resource.AppendingTransformer" > <resource> META-INF/spring.schemas </resource> </transformer> </transformers> <filters> <!-- filter out jar signatures from shaded jars --> <filter> <artifact> *:* </artifact> <excludes> <exclude> META-INF/*.SF </exclude> <exclude> META-INF/*.DSA </exclude> <exclude> META-INF/*.RSA </exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Arkadi Shishlov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development