Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-685

Implicit external dependency on DynaBean while loading a config

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      100% repro.

      Getting an exception: DynaBean not found when trying to load an apache config file.
      Exception:

      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:264)
              at com.sun.proxy.$Proxy0.<clinit>(Unknown Source)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739)
              at org.apache.commons.configuration2.builder.fluent.Parameters.createParametersProxy(Parameters.java:307)
              at org.apache.commons.configuration2.builder.fluent.Parameters.fileBased(Parameters.java:186)
              at com.example.App.main(App.java:13)
      Caused by: java.lang.ClassNotFoundException: org.apache.commons.beanutils.DynaBean
              at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
              ... 11 more
      

      when running:

      package com.example;
      
      import org.apache.commons.configuration2.YAMLConfiguration;
      import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
      import org.apache.commons.configuration2.builder.fluent.Parameters;
      import org.apache.commons.configuration2.ex.ConfigurationException;
      
      class App {
      
        public static void main(String[] args) throws ConfigurationException {
          Parameters params = new Parameters();
          FileBasedConfigurationBuilder<YAMLConfiguration> builder1 = new FileBasedConfigurationBuilder<>(YAMLConfiguration.class)
            .configure(params.fileBased().setFileName("file.yml"));
      
          YAMLConfiguration conf = builder1.getConfiguration();
        }
      
      }
      

      with build.gradle:

      apply plugin: 'java'
      apply plugin: 'application'
      
      mainClassName = "com.example.App"
      
      repositories {
          jcenter()
      }
      
      dependencies {
        compile group: 'org.apache.commons', name: 'commons-configuration2', version: '2.2'
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            fabienrenaud Fabien Renaud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: