Configuration java.lang.NoClassDefFoundError apache commons配置错误
我正在尝试为Oracle ADF项目创建一个共享库。我创建了一个util,用于读取属性的外部文件并加载到ADF服务中。因此,我为这个共享项目创建了一个maven项目,它构建了一个jar。当添加这个库时,我在编译时没有问题。我能够将新类导入到consume ADF服务项目中。当我部署新的ear时。在测试使用ConfigService读取外部属性文件的行时,我遇到以下异常:Configuration java.lang.NoClassDefFoundError apache commons配置错误,configuration,apache-commons,apache-commons-config,Configuration,Apache Commons,Apache Commons Config,我正在尝试为Oracle ADF项目创建一个共享库。我创建了一个util,用于读取属性的外部文件并加载到ADF服务中。因此,我为这个共享项目创建了一个maven项目,它构建了一个jar。当添加这个库时,我在编译时没有问题。我能够将新类导入到consume ADF服务项目中。当我部署新的ear时。在测试使用ConfigService读取外部属性文件的行时,我遇到以下异常: java.lang.NoClassDefFoundError: Could not initialize class com.
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)
配置服务:
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;
公共类配置服务{
专用静态ADFLogger logger=ADFLogger.createADFLogger(ConfigService.class);
基于私有文件的配置配置服务;
私有静态字符串DEFAULT\u CONFIG\u FILE\u PATH=“C:\\com.aar.webservices.common.CONFIG\\application.properties”;
私有字符串文件路径;
公共服务(){
超级();
}
/**
*用于访问配置服务的公共接口
*@返回
*/
公共文件基配置getConfigService(){
Parameters params=新参数();
如果(this.configService==null){//检查配置服务的单例实例是否已初始化;如果未初始化。
试一试{
文件属性文件=新文件(默认配置文件路径);
基于文件的配置生成器=
新的FileBasedConfiguration Builder(PropertiesConfiguration.class)
.configure(params.properties().setFile(propertyFile));
this.configService=builder.getConfiguration();
info(“已成功初始化属性bean”);
}捕获(配置异常cex){
logger.severy(“配置服务加载失败!”);
严重(cex);
}
}
返回此.configService;
pom依赖项:
<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>
<!-- <!– https://mvnrepository.com/artifact/org.apache.commons/commons-jexl –>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.commons</groupId>-->
<!-- <artifactId>commons-jexl</artifactId>-->
<!-- <version>2.1.1</version>-->
<!-- </dependency>-->
<!-- <!– https://mvnrepository.com/artifact/org.apache.commons/commons-jexl –>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.commons</groupId>-->
<!-- <artifactId>commons-jexl</artifactId>-->
<!-- <version>2.1.1</version>-->
<!-- </dependency>-->
<!-- <!– https://mvnrepository.com/artifact/org.apache.commons/commons-vfs2 –>-->
<!-- <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>
org.apache.commons
commons-lang3
3.7
罐子
编译
公用记录
公用记录
1.2
公地小海狸
公地小海狸
1.9.4
通用编解码器
通用编解码器
1.13
公共jxpath
公共jxpath
1.3
log4j
log4j
1.2.17
org.apache.commons
commons-lang3
3.9
org.apache.commons
公共文本
1.8
org.apache.commons
commons-configuration2
2.6
罐子
编译
朱尼特
朱尼特
4.12
罐子
测试
com.oracle.adf.library
BC4J运行时
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
ADF模型运行时
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
MDS运行时
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
MDS运行时依赖项
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
BC4J安全
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
Oracle JDBC
12.2.1-1-0
聚甲醛
假如
com.oracle.adf.library
BC4J Oracle域
12.2.1-1-0
聚甲醛
假如
此解决方案对我有效:此解决方案对我有效: