Announcement Announcement Module
Collapse
No announcement yet.
Profile exception configure. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Profile exception configure.

    Hello everyone, my name is Vadim.
    I would love to get some advise maybe help from you guys.

    I'm learning spring and I willing to do the profile things in spring, which help's me to configure my app, deploy and execute from different profile's.

    But after configure it I got exception which say's to me this:

    Code:
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from file [/home/vadim/workspace-sts/SpringTutorial/bin/msgeventtwo-SpringConfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 147; cvc-complex-type.3.2.2: Attribute 'profile' is not allowed to appear in element 'beans'.
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    	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.GenericXmlApplicationContext.load(GenericXmlApplicationContext.java:117)
    	at demidov.spring.home.appEventBuilder.AppOutClass.main(AppOutClass.java:21)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 147; cvc-complex-type.3.2.2: Attribute 'profile' is not allowed to appear in element 'beans'.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:453)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3232)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2709)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2051)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:741)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3065)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:881)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:237)
    	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
    	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    	... 8 more
    Using:
    - Spring Tool Suite Version: 3.1.0.RELEASE Build Id: 201210061306
    - Java version "1.6.0_18" (Java SE 1.7)

    My AppOut Class is:

    Code:
    package demidov.spring.home.appEventBuilder;
    
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.context.support.GenericXmlApplicationContext;
    
    import demidov.spring.home.eventListener.MessageEvent;
    import demidov.spring.home.eventListener.MessageEventTwo;
    
    public class AppOutClass implements ApplicationContextAware {
    
    	ApplicationContext actx;
    	
    	
    	public static void main(String[] args) {
    		
    		GenericXmlApplicationContext gxac = new GenericXmlApplicationContext();
    		gxac.getEnvironment().setActiveProfiles("msgeventtwo");
    		gxac.load("classpath:*-SpringConfig.xml");
    		gxac.refresh();
    		AppOutClass appOC = (AppOutClass) gxac.getBean("appoutClass");
    		appOC.publishEventMessageEventTwo("Two_Event");
    		
    	}
    
    	
    	
    	public void publishEventMessageEvent(String msg) {
    		actx.publishEvent(new MessageEvent(this, msg));
    		
    	}
    
    	
    	public void publishEventMessageEventTwo(String msg) {
    		actx.publishEvent(new MessageEventTwo(this, msg));
    		
    	}
    	
    	
    	@Override
    	public void setApplicationContext(ApplicationContext apc)
    			throws BeansException {
    		this.actx = apc;
    		
    	}
    
    }
    One of my Xml configuration with profile is this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="
           http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" profile="msgeventtwo"> 
        
           
         		<bean id="appoutClass" class="demidov.spring.home.appEventBuilder.AppOutClass"></bean>
           		
           		<bean id="messageListnerClassTwo" class="demidov.spring.home.eventListener.MessageListnerTwoClass"></bean>
           		
           </beans>
    If you know something please help me to solve this one.

    Thank you.
    With Best regards, Vadim.

  • #2
    The profile attribute was added in spring 3.1. You are using the 3.0 xsd (and maybe jars?).
    See: http://java.dzone.com/articles/using...g-profiles-xml

    Comment


    • #3
      Really help. Thank you.. I just copy from internet the name space's which include 3.0 xsd. But my jars was downloaded as 3.2.0.
      Thank you for answer.

      Comment

      Working...
      X