• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

spring example error

 
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying below example
http://www.tutorialspoint.com/spring/spring_autowired_annotation.htm


When I run MainApp.java getting below error











Jun 13, 2016 3:44:00 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@27d6c5e0: display name [org.springframework.context.support.ClassPathXmlApplicationContext@27d6c5e0]; startup date [Mon Jun 13 15:44:00 EDT 2016]; root of context hierarchy
Jun 13, 2016 3:44:00 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [Beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [Beans.xml]; nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:385)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:158)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:184)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:411)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:338)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
at MainApp.main(MainApp.java:6)
Caused by: java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:64)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1246)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1236)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)
... 13 more




How to resolve this error to run this example to see the age and name. please advise
sprin3Err.png
[Thumbnail for sprin3Err.png]
spring jars
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:64)



which java version are you using?
 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java 1.8 i am using i think. if you see attachment i posted in previous post it says JRE java SE 1.8.

where i have to confirm/change on eclipse?
how to make sure i always by default use 1.8 for all future java projects i develop not like 1.4 or 1.5 etc

i opened command prompt on my windows laptop and typed
javac -version which also shows jdk1.8 but not sure why eclipse thinks i have 1.5 what all the places i have to make sure all my projects point to same jdk1.8 even as runtime jre also
 
Greenhorn
Posts: 11
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, If you want to execute Spring Program which is using ApplicationContext then you should be add below listed jar files into your classpath.

If BeanFactory used
1) %SPRING_HOME%\ dist\org.springframework.core-3.0.3.RELEASE.jar
2) %SPRING_HOME%\ dist\org.springframework.beans-3.0.3.RELEASE.jar
3) %HOME%\Softwares\Jars\jakarta-commons\commons-logging.jar
Additionally following jars are required in case of spring context
4) %SPRING_HOME%\ dist\org.springframework.context-3.0.3.RELEASE.jar
5) %SPRING_HOME%\ dist\org.springframework.asm-3.0.3.RELEASE.jar
6) %SPRING_HOME%\ dist\org.springframework.expression-3.0.3.RELEASE.jar
 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If BeanFactory used
1) %SPRING_HOME%\ dist\org.springframework.core-3.0.3.RELEASE.jar
2) %SPRING_HOME%\ dist\org.springframework.beans-3.0.3.RELEASE.jar
3) %HOME%\Softwares\Jars\jakarta-commons\commons-logging.jar



I have put all above 3 jars.

I am still getting error in below class

Description Resource Path Location Type
ApplicationContext cannot be resolved to a type MainApp.java /SpringAutoWire/src line 6 Java Problem
Autowired cannot be resolved to a type TextEditor.java /SpringAutoWire/src line 4 Java Problem
ClassPathXmlApplicationContext cannot be resolved to a type MainApp.java /SpringAutoWire/src line 6 Java Problem
The import org.springframework.context cannot be resolved MainApp.java /SpringAutoWire/src line 1 Java Problem
The import org.springframework.context cannot be resolved MainApp.java /SpringAutoWire/src line 2 Java Problem



 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

6) %SPRING_HOME%\ dist\org.springframework.expression-3.0.3.RELEASE.jar



i aded above jar still same error. Any of you were able to run this example successfully?
 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://stackoverflow.com/questions/12084265/spring-applicationcontext-cannot-be-resolved-even-with-jar

as mentioned in above cool link
i put spring context 3.0.3 jar boom many errors gone except auto wire.
 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looking at below ling to resolve other error

http://stackoverflow.com/questions/30371675/autowired-field-cannot-not-be-resolved-to-a-type
 
sai rama krishna
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now getting below errror

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:154)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:215)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:88)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at MainApp.main(MainApp.java:6)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more


after importing all 4.1.6 jars ftrom below and setting build path
http://maven.springframework.org/release/org/springframework/spring/4.1.6.RELEASE/
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic