Results 1 to 4 of 4

Thread: Spring errorLog

  1. #1
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default Spring errorLog

    Java Code:
    package springsMore;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class MainApp {
    	public static void main(String[] args) {
    	 
    	 ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    	 HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
    	 obj.getMessage();
     }
    }
    
    
    
    package springsMore;
    
    public class HelloWorld {
    	 private String message;public void setMessage(String message){
    		 this.message = message;
    	 }
    	 public void getMessage(){
    	 System.out.println("Your Message : " + message);
    	 }
    	}
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
     <bean id="helloWorld" class="springsMore.HelloWorld">
     <property name="message" value="Hello World!"/>
     </bean>
    </beans>
    I have used this code from tutorials point book.
    https://www.tutorialspoint.com/sprin...g_tutorial.pdf 20th page
    If I run program, I receive:
    Mar 12, 2017 12:28:49 AM org.springframework.context.support.ClassPathXmlAp plicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlAp plicationContext@497470ed: startup date [Sun Mar 12 00:28:49 EET 2017]; root of context hierarchy
    Mar 12, 2017 12:28:49 AM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [Beans.xml]
    Exception in thread "main" org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:344)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:304)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:181)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:217)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:188)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:252)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:127)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:93)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:129)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:613)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:514)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
    at springsMore.MainApp.main(MainApp.java:9)
    Caused by: java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getI nputStream(ClassPathResource.java:172)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:330)
    ... 13 more


    picture.bmp

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Spring errorLog

    I don't even do Spring, but surely the error message tells you what went wrong?
    IOException parsing XML document from class path resource [Beans.xml];
    nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default Re: Spring errorLog

    So it means that xml file path is wrong written?

  4. #4
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default Re: Spring errorLog

    Found it.
    Java Code:
     ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    xml name did not matched with file name.

Similar Threads

  1. new to spring mvc with JPA
    By javastuden in forum New To Java
    Replies: 0
    Last Post: 07-26-2011, 09:25 AM
  2. Replies: 1
    Last Post: 12-27-2010, 05:21 PM
  3. spring mvc
    By karq in forum Advanced Java
    Replies: 0
    Last Post: 12-13-2010, 04:28 PM
  4. spring mvc
    By jpnr99 in forum New To Java
    Replies: 4
    Last Post: 10-14-2010, 09:58 AM
  5. EJB 3.0 VS Spring
    By nanaji in forum Advanced Java
    Replies: 4
    Last Post: 01-28-2009, 04:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •