1

I am trying to create a shared library for Oracle ADF projects. I created a util for reading external file for properties and load into ADF services. So, I created a maven project for this shared project which builds a jar. When adding this library I have no issue at compile time. I am able to import the new class into the consume ADF service project. When I deployed the new ear. I get the following exception when testing that line where my ConfigService is used to read an external property file:

java.lang.NoClassDefFoundError: Could not initialize class com.sun.proxy.$Proxy322
    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:306)
    at org.apache.commons.configuration2.builder.fluent.Parameters.properties(Parameters.java:245)
    at com.aar.webservices.common.config.ConfigService.getConfigService(ConfigService.java:37)

ConfigService:

public class ConfigService {
    private static ADFLogger logger = ADFLogger.createADFLogger(ConfigService.class); 
    private FileBasedConfiguration configService;
    private static String DEFAULT_CONFIG_FILE_PATH="C:\\com.aar.webservices.common.config\\application.properties";
    private String filePath;

    public ConfigService(){
        super();
    }

    /**
     * A public interface to get  access to the Configuration service
     * @return
     */
    public FileBasedConfiguration getConfigService() {
        Parameters params = new Parameters();
        if(this.configService == null) {// Check if the singleton instance of config service is initialized ; If not initialize.
            try {
                File propertyFile = new File(DEFAULT_CONFIG_FILE_PATH);
                FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                        new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                                .configure(params.properties().setFile(propertyFile));

                this.configService = builder.getConfiguration();
                logger.info("Successfully initialized property bean.");
            } catch (ConfigurationException cex) {
                logger.severe("Loading of Config service failed!");
                logger.severe(cex);
            }
        }
        return this.configService;

pom dependencies:

<dependencies>
  <!--Apache Common Configuration related depdendencies    -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.7</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.2</version>
    </dependency>
      <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
      <dependency>
          <groupId>commons-beanutils</groupId>
          <artifactId>commons-beanutils</artifactId>
          <version>1.9.4</version>
      </dependency>
    <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.13</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-jxpath/commons-jxpath -->
    <dependency>
      <groupId>commons-jxpath</groupId>
      <artifactId>commons-jxpath</artifactId>
      <version>1.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.9</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-text -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
      <version>1.8</version>
    </dependency>
<!--    &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.commons/commons-jexl &ndash;&gt;-->
<!--    <dependency>-->
<!--      <groupId>org.apache.commons</groupId>-->
<!--      <artifactId>commons-jexl</artifactId>-->
<!--      <version>2.1.1</version>-->
<!--    </dependency>-->
<!--    &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.commons/commons-jexl &ndash;&gt;-->
<!--    <dependency>-->
<!--      <groupId>org.apache.commons</groupId>-->
<!--      <artifactId>commons-jexl</artifactId>-->
<!--      <version>2.1.1</version>-->
<!--    </dependency>-->
<!--    &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.commons/commons-vfs2 &ndash;&gt;-->
<!--    <dependency>-->
<!--      <groupId>org.apache.commons</groupId>-->
<!--      <artifactId>commons-vfs2</artifactId>-->
<!--      <version>2.4.1</version>-->
<!--    </dependency>-->

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-configuration2</artifactId>
      <version>2.6</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <type>jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>BC4J-Runtime</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>ADF-Model-Runtime</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>MDS-Runtime</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>MDS-Runtime-Dependencies</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>BC4J-Security</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>Oracle-JDBC</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.oracle.adf.library</groupId>
      <artifactId>BC4J-Oracle-Domains</artifactId>
      <version>12.2.1-1-0</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • this solution worked for me: https://stackoverflow.com/questions/44802350/getting-noclassdeffounderror-when-trying-to-set-up-propertiesconfiguration – Andrew Norman Jul 21 '20 at 19:52

0 Answers0