Getting the following ERROR while trying to deploy a EAR project in JBoss AS 7.
(MSC service thread 1-5) Context initialization failed. java.io.FileNotFoundException: class path resource [.properties] cannot be opened because it does not exist
A more detailed snapshot of the errors is given below.
16:20:08,548 ERROR [org.springframework.web.servlet.DispatcherServlet]
(MSC service thread 1-5) Context initialization failed:
org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to parse configuration class [xx.xx.Config]; nested exception
is java.io.FileNotFoundException: class path resource
[wwwr.properties] cannot be opened because it does not exist at
org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
[spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE] Caused by:
java.io.FileNotFoundException: class path resource [wwwr.properties]
cannot be opened because it does not exist
16:20:08,588 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyWeb]]
(MSC service thread 1-5) StandardWrapper.Throwable:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class [com.xx.Config]; nested exception is
java.io.FileNotFoundException: class path resource [wwwr.properties]
cannot be opened because it does not exist
I am using JBoss AS7 server and MyEclipse as IDE.
Well I found the solution to be involving the following steps
1) Make sure that the property file is in the Class Path of the projects involved or at least in the modules deployed in Jboss.
1- a) Verify that the modules.xml file has the right entries
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.xx.yy">
<resources>
<resource-root path="./properties/"/>
2) Verify that the Manifest.mf file in the EAR has the required dependencies.
Dependencies: com.xx.yy
3) Clean build and Deploy to server.
Related
Without context root tag, able to deploy on jboss server 7.3.10 and able to access application with default context root
War File Application
jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>MyApp</context-root>
</jboss-web>
With context root tag , getting below exception
10:54:28,163 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.unit."UtxQVAClient-1.0.0.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."UtxQVAClient-1.0.0.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "UtxClient-1.0.0.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:183)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0027: Failed to parse XML descriptor "/C:/Users/Applications/jboss-eap-7.3.10/jboss-eap-7.3/standalone/deployments/UtxClient-1.0.0.war/WEB-INF/web.xml" at [3,5]
at org.wildfly.extension.undertow.deployment.WebParsingDeploymentProcessor.deploy(WebParsingDeploymentProcessor.java:134)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:176)
... 8 more
**Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[3,5]
Message: Unexpected element 'context-root' encountered**
at org.jboss.metadata.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:115)
at org.jboss.metadata.parser.servlet.WebMetaDataParser.parse(WebMetaDataParser.java:196)
at org.jboss.metadata.parser.servlet.WebMetaDataParser.parse(WebMetaDataParser.java:51)
at org.wildfly.extension.undertow.deployment.WebParsingDeploymentProcessor.deploy(WebParsingDeploymentProcessor.java:96)
... 9 more
This declaration shouldn't be in a "web.xml" file but in a jboss-web.xml file as it is jboss specific.
Scenario
There was a requirement in my project to multi-thread calls made to a Webservice. This is implemented using ThreadPoolTaskExecutor (Spring).
As the thread class required values to be fed at runtime, had implemented the code as below -
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml");
for (DocumentData documentData : documentDataList){
MinerThread minerThread = applicationContext.getBean("minerThread",MinerThread.class);
minerThread.setHeader(header);
minerThread.setDocumentData(documentData);
minerThread.setBatchSize(batchSize);
minerThreadExecutor.execute(minerThread);
}
Issue
In local I have tomcat server and this implementation works as expected. However on Weblogic (on the client machine, I don't have access to Weblogic) when the war is deployed it throws FileNotFound Exception.
As the application context object is created via ClassPathXmlApplicationContext API thought the error was thrown because the location was not under the Weblogic classpath. There was nothing set in the Weblogic server classpath. However even after including WEB-INF/classes in the classpath the same exception is thrown.
Exception
2013/01/29 09:19:12,853 [ERROR] RequestQueueListener - org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [../shared-common-context.xml]
Offending resource: class path resource [application-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [../shared-common-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [../shared-common-context.xml] cannot be opened because it does not exist
BeanDefinitionParsingException is caused because of the relative path that was added in the Weblogic classpath.
On the Weblogic the file is at the location -
./wls10.3.4/ColorisPPT1/user_projects/domains/Coloris_PPT1_Domain/servers/Coloris_PPT1_AdminServer/tmp/.appmergegen_1336142780924_documentservice.war/WEB-INF/classes
When the war if built (Maven is used) the application-context.xml is placed under WEB-INF/classes folder.
Could someone please suggest how to proceed with this.
I have a spring test case that annotated as following
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = {"classpath:conf/allocadia-base.xml", "classpath:META-INF/jdoconfig.xml"})
my jdoconfig is
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
when I run the test I get
java.lang.IllegalStateException: Failed to load ApplicationContext
.
.
.
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [META-INF/jdoconfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'jdoconfig'.
if I changed jdoconfig to
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_2_3.xsd">
the error is
Caused by:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://java.sun.com/xml/ns/jdo/jdoconfig]
Offending resource: class path resource [META-INF/jdoconfig.xml]
I use the latest spring 3.2 and JDO 2.3-e
the application works fine when I deploy it to tomcat I'm just getting this error when trying to run the test
Your jdoconfig.xml consist incorrect url. Try this:
xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd"
Validating jdoconfig with incorrect url
How to solve validation error on xsi:noNamespaceSchemaLocation in jdoconfig.xml
I have a project organized like this:
core
-- /src/main/resources/company/config/spring-config.xml
webapp
-- /WEB-INF/applicationContext.xml
The webapp depends on core.jar, which is included correctly in WEB-INF/lib when I deploy.
In web.xml I have:
<param-value>
/WEB-INF/applicationContext.xml
</param-value>
And in applicationContext.xml I have:
<import resource="classpath:/company/config/spring-config.xml" />
But when I run, I get this error:
2012-10-04 20:03:39,156 [localhost-startStop-1] springframework.web.context.ContextLoader ERROR: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/company/config/spring-config.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [company/config/spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [company/config/spring-config.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
....
Caused by: java.io.FileNotFoundException: class path resource [company/config/spring-config.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
... 36 more
When spring-config.xml is in webapp, everything works fine.
I noticed the leading / is removed from some of the errors on the stack trace, and I wonder if this has anything to do with it.
Also, I am (unfortunately) using Spring 2.5, if that matters.
For future reference, I figured out the problem after much debugging. It turns out Eclipse was building my "core" library as a jar, but with a web application package layout, so instead of my resource being located here:
/company/config/spring-config.xml
it was located here:
/WEB-INF/company/config/spring-config.xml
which caused the problem. I had checked the jar a few times before, but had never noticed the sneaky "/WEB-INF" hiding in plain sight.
Removing the project and re-importing it into Eclipse (via the Maven pom.xml file) was not enough to fix the problem.
I had to manually delete the Eclipse-specific .project, .classpath, and .settings files. When I did that and re-imported the project everything was fixed.
The moral of the lesson is: ALWAYS check your resource paths when the exception says "File Not Found".
i am deploying application(spring-hibernate) in tomcat6 but it is giving error-
ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: com.myPackage.myProject.calendar.bpo.BusinessDirectoryBPOImpl; nested exception is java.io.FileNotFoundException: class path resource [com/myPackage/framework/bpo/BaseBPOImpl.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:180)
......
all jar files are already in \WEB-INF\lib*.jar.
am i missing any class file or any jar file.
how to solve this error.
Thanks
Yugal
com.myPackage.myProject.calendar.bpo.BusinessDirectoryBPOImpl is looking for
com/myPackage/framework/bpo/BaseBPOImpl.class
which it cannot find.
Check for sure if this specific class is present under WEB-INF\lib in a jar or WEB-INF\classes as a class file.