3 Replies Latest reply on Dec 6, 2010 11:37 AM by Peter Chandler

    Exception in org.apache.camel.util.PackageHelper

    Peter Chandler Master

      Help: I am getting an exception in org.apache.camel.util.PackageHelper (below). I believe I am using org.springframework.jms, version = 2.5.6.SEC01, which should converted to 2.5601



      Why am I getting this exception?

      Is there a way to fix it?


      Side bar:

      I think:

                  LOG.debug("Failed to find out " + packageName + " version: " + e, e);

      should be:

                   LOG.debug("Failed to find out " + packageName + " version: " + value, e);




      2010-12-02 15:43:13,927 [Thread-0] DEBUG - Failed to find out org.springframework.jms version: java.lang.NumberFormatException: empty String
      java.lang.NumberFormatException: empty String
           at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
           at java.lang.Double.parseDouble(Double.java:510)
           at org.apache.camel.util.PackageHelper.isValidVersion(PackageHelper.java:63)
           at org.apache.camel.component.jms.JmsConfiguration.defaultCacheLevel(JmsConfiguration.java:1150)
           at org.apache.camel.component.jms.JmsConfiguration.configureMessageListenerContainer(JmsConfiguration.java:1052)
           at org.apache.camel.component.jms.JmsConfiguration.createMessageListenerContainer(JmsConfiguration.java:512)
           at org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:135)
           at org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:55)
           at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:60)
           at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:83)
           at org.apache.camel.impl.RouteService.doStart(RouteService.java:123)
           at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:53)
           at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:957)
           at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:197)
           at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
           at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:593)
           at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
           at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
           at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
           at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
           at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
           at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
           at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
           at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)



       * Licensed to the Apache Software Foundation (ASF) under one or more
       * contributor license agreements.  See the NOTICE file distributed with
       * this work for additional information regarding copyright ownership.
       * The ASF licenses this file to You under the Apache License, Version 2.0
       * (the "License"); you may not use this file except in compliance with
       * the License.  You may obtain a copy of the License at
       *      http://www.apache.org/licenses/LICENSE-2.0
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
      package org.apache.camel.util;
      import org.apache.commons.logging.Log;Class search for 'org.apache.commons.logging.Log'
      import org.apache.commons.logging.LogFactory;Class search for 'org.apache.commons.logging.LogFactory'
       * Some helper methods for working with Java packages and versioning.
       * @version $Revision: 767824 $
      public final class PackageHelper {
          private static final transient Log LOG = LogFactory.getLog(PackageHelper.class);
          private PackageHelper() {
              // Utility Class
           * Returns true if the version number of the given package name can be found and is greater than or equal to the minimum version.
           * For package names which include multiple dots, the dots are removed. So for example a spring version of 2.5.1 is converted to
           * 2.51 so you can assert that its >= 2.51 (so above 2.50 and less than 2.52 etc).
           * @param packageName the Java package name to compare
           * @param minimumVersion the minimum version number
           * @return true if the package name can be determined and if its greater than or equal to the minimum value
          public static boolean isValidVersion(String packageName, double minimumVersion) {
              try {
                  Package spring = Package.getPackage(packageName);
                  if (spring != null) {
                      String value = spring.getImplementationVersion();
                      if (value != null) {
                          // lets remove any extra dots in the string...
                          int idx = value.indexOf('.');
                          if (idx >= 0) {
                              StringBuffer buffer = new StringBuffer(value.substring(0, ++idx));
                              int i = idx;
                              for (int size = value.length(); i < size; i++) {
                                  char ch = value.charAt(i);
                                  if (Character.isDigit(ch)) {
                              value = buffer.toString();
                          double number = Double.parseDouble(value);
                          return number >= minimumVersion;
              } catch (Exception e) {
                  LOG.debug("Failed to find out " + packageName + " version: " + e, e);
              return true;