How to load "context.xml" from classpath in Java? - java

I am trying to load my spring context.xml file using Java from the classpath. My context.xml file is in src/main/resources.
public static void main(String[] args) {
ClassPathXmlApplicationContext context = null;
try {
context = new ClassPathXmlApplicationContext("classpath:context.xml");
context.registerShutdownHook();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (context != null) {
context.close();
}
}
}
Above code works fine when I am running in my eclipse. But as soon as I package it into a runnable jar by right clicking the project and select export as a runnable jar and then run the jar from a ubuntu machine as -
java -jar test.jar
Then I am getting below exception -
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [context.xml]; nested exception is java.io.FileNotFoundException: class path resource [context.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.host.sd.corp.ldap.Application.main(Application.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.io.FileNotFoundException: class path resource [context.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 18 more
Is there anything I am missing?

You probably didn't include the resources in src/main/resources in your jar. I don't believe the Maven plugin is involved in Eclipse's Jar Export utility.

Related

Spring Boot read properties file from command line Could not resolve placeholder 'ConfigPath'

I'm trying to read a configuration file from command line. In main I do this:
public static void main(String[] args) {
if(args.length > 0) {
SpringApplication.run(HeliosAdminBackendApplication.class, args);
} else {
System.out.println("Error");
System.exit(0);
}
}
And, following this question, I've created a class MyConfig like this:
import lombok.Getter;
#Configuration
#ConfigurationProperties
#PropertySource(value = "file:${ConfigPath}")
public class MyConfig {
#Getter
#Value("${property_name}")
private String myproperty;
}
Then I've created the .jar file, then went in the folder containing the jar and try to run it by doing:
java -jar myapp.jar --spring.config.location=file:application.yml
My application.yml file is the same folder of my jar. I've also set the path to C:/my/path/to/folder/ but the error persists. Is the path written wrong? Or do I have to add/modify something in the code?
EDIT
Full stack trace:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class
[it.sysdata.helios_backend_admin.HeliosAdminBackendApplication];
nested exception is java.lang.IllegalArgumentException: Could not
resolve placeholder 'ConfigPath' in value "file:${ConfigPath}"
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at it.sysdata.helios_backend_admin.HeliosAdminBackendApplication.main(HeliosAdminBackendApplication.java:24)
... 8 more Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'ConfigPath' in value
"file:${ConfigPath}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211)
at org.springframework.core.env.AbstractEnvironment.resolveRequiredPlaceholders(AbstractEnvironment.java:575)
at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:450)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:271)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
... 21 more
Here is the answer for your question regarding Why do I have to use "additional" and not just location?
First of all when ever you use spring.config.location for loading configuration properties then spring-boot trys to search the configuration at classpath or under config directory. Here is the order of search -
file:./config/
file:./
classpath:/config/
classpath:/
But remember if you are using the spring.config.locaton then it will always look for either "classpath" or "config" not the external configuration.
To load the external configuration/custom configuration then spring boot provides "spring.config.additional-location" which search the configuration in following order -
file:./custom-config/
classpath:custom-config/ (This is was your case)
file:./config/
file:./
classpath:/config/
classpath:/
I hope now got the answer why to use the "spring.config.additional-location" for loading external configuration.

Unable to execute Spring JDBC Project from JAR

I'm able to execute the project in Eclipse, but when I export it as a jar (Eclipse Option : Extract the required libraries in jar) I'm getting following exception
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [spring.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:119)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:111)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1363)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1352)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:179)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:149)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:96)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:513)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:393)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:257)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:128)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:636)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:85)
at com.mk.util.DataLoad.main(DataLoad.java:121)

How to solve BeanDefinitionStoreException caused by FileNotFoundException in SPRING?

I'm trying out an activity which calls a method draw() in Triangle bean using SPRING. However, when I try to access the spring.xml file I came across with an error.
The Error is :
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at org.spring.application.SpringApplication.main(SpringApplication.java:23)
Caused by: java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 13 more
Here is main which is the SpringApplication.java :
package org.spring.application;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringApplication
{
public static void main(String[] args)
{
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
Triangle triangle = (Triangle) context.getBean("Triangle");
triangle.draw();
}
}
Here are the code in the spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Triangle" class="org.spring.application.Triangle"/>
</beans>
And here is the Project Folder:
Project Folder
I'm using NetBeans IDE. I also included the Spring Library and Components Logging.
Can someone help me and point out if I'm doing something wrong. Thank you.
You need to add the package. new ClassPathXmlApplicationContext("spring.xml"); should be new ClassPathXmlApplicationContext("org/spring/application/spring.xml");
You should place your spring.xml in the resource folder.
Use the following structure:

Read .properties file in .xml file

I have appcontext.xml file in the class path. I am using config.properties file in appcontext.xml to read database properties. Property file is stored in src/main/config/core/config.properties structure and I am using it in xml file as,
<property name="locations">
<list>
<value>${PF_CORE_HOME}/config/core/config.properties</value>
</list>
</property>
but it gives error,
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:89) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:162) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at com.gsl.pf.core.AdaptorManager.<init>(AdaptorManager.java:28) ~[pf-core-0.1.0-SNAPSHOT.jar:na]
at com.gsl.pf.core.AdaptorManager.getInstance(AdaptorManager.java:34) ~[pf-core-0.1.0-SNAPSHOT.jar:na]
at com.gsl.pf.fwk.FrameworkLoader.initialize(FrameworkLoader.java:35) ~[pf-fwk-0.1.0-SNAPSHOT.jar:na]
at com.gsl.pf.scimsvr.app.Loader.initialize(Loader.java:32) ~[classes/:na]
at com.gsl.pf.scimsvr.app.ScimServer.start(ScimServer.java:62) [classes/:na]
at com.gsl.pf.scimsvr.app.ScimServer.main(ScimServer.java:47) [classes/:na]
Caused by: java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156) ~[spring-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
... 12 common frames omitted
is there any other way to read .property file in .xml.
This way works if you do it properly.
Here's your issue:
Caused by: java.io.FileNotFoundException: class path resource [C:/prov-eng-2/prov-eng/provfwk/pf-core/src/main/config/core/config.properties] cannot be opened because it does not exist
You're reading this file from the CLASSPATH, but that path is not part of it.
You don't include /src in your CLASSPATH. I'd put that .properties file in a /resources directory and package that into your CLASSPATH (e.g. a relative path under /classes).

where is struts looking for config files?

I inherited a Struts 1 app consisting of about eight separate packages all compiled into the same app. I've been tasked with rewriting its ant build script. Previously it was copying all the config files separately into the /usr/local/tomcat/shared/classes dir, but our ops team has asked us to streamline things so the build script just creates a war file that can be dropped into tomcat.
I get an error when my ConfigurationManager class tries to load its config file. This file, config.xml, is currently being copied into WEB-INF before it's warred up with the rest of the app. So when I look at the exploded war (ROOT) I do find /usr/local/tomcat/webapps/ROOT/WEB-INF/config.xml. Here is the relevant portion of ConfigurationManager:
private static final String BASE_CONFIG_FILE = "WEB-INF/config.xml";
private void loadConfigFiles() throws RCConfigurationException {
try {
log.error("classpath: " + System.getProperty("java.class.path"));
ConfigurationFactory factory = new ConfigurationFactory();
URL configURL = getClass().getResource(BASE_CONFIG_FILE);
factory.setConfigurationURL(configURL);
config = factory.getConfiguration();
} catch (ConfigurationException e) {
log.error("Exception loading configuration files.", e);
throw new RCConfigurationException("Exception loading configuration files", e);
}
}
The log.error() call outputs this:
13:16:10,561 ERROR ConfigurationManager:75 - classpath: /usr/local/tomcat/bin/bootstrap.jar
My localhost.2013-01-29.log shows this:
SEVERE: Exception starting filter GlobalRootManager
java.lang.ExceptionInInitializerError
at com.rc.util.config.ConfigurationManager.getInstance(ConfigurationManager.java:66)
at com.rc.commonbusinesswebapp.servlet.filter.GlobalRootManager.init(GlobalRootManager.java:42)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NullPointerException
at org.apache.commons.configuration.ConfigurationFactory.setConfigurationURL(ConfigurationFactory.java:220)
at com.rc.util.config.ConfigurationManager.loadConfigFiles(ConfigurationManager.java:79)
at com.rc.util.config.ConfigurationManager.<init>(ConfigurationManager.java:55)
at com.rc.util.config.ConfigurationManager.<init>(ConfigurationManager.java:26)
at com.rc.util.config.ConfigurationManager$LazyHolder.<clinit>(ConfigurationManager.java:37)
... 29 more
I am spinning my wheels so I hope someone here can help me. Thanks.
WEB-INF is not on a web app's classpath.
WEB-INF/classes is; one option would be to locate the file at the root of the classpath if you want to load the config file as a classpath resource.

Categories

Resources