Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Cannot find the declaration of element 'beans'

 
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I am new to Spring and I am having a problem getting my standalone application to run outside of the Spring Source environment. When I export the program I receive the following error when I try to run it. I can't understand why it runs great within Spring and gets errors when it is move outside that environment. Thanks for any assistance you can provide.


Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefiniti
onStoreException: Line 9 in XML document from class path resource [org/interface
Transfer/fgc-common-dao-context.xml] is invalid; nested exception is org.xml.sax
.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.

This is my common-dao-contex.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">


<context:component-scan base-package="org/interfaceTransfer"/>

<context:property-placeholder location="file:src/fgc-common.properties" ignore-unresolvable="true"/>


</beans>
 
Sheriff
Posts: 13551
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing I would check is path and/or classpath. When you run the app in the Spring Source (I assume you mean STS) environment, the platform takes care of these settings for you. When you run outside of the STS, you have to take care of it yourself somehow.
 
Tim Bryant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured this out, it had to do with using Spring to create a runnable JAR file. When creating the JAR file with Spring it allows you to select one of three options under Library handling:
- Extract required libraries into generated JAR
- Package required libraries into generated JAR
- Copy required libraries into a sub-folder next to the generated JAR
When I used option 1 & 2 this would cause the error to occur. When I used option 3 the application worked correctly without any errors.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also getting the same error
Here is my xml file



Here is the error

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!