2015-10-07 3 views
1

Мне нужно сделать некоторые настройки с помощью Camel ActiveMQ. Чтобы я мог читать данные и выталкивать их в очередь. У меня есть xml-файл. Построение проекта в порядке. Во время выполнения программы я получаю xml-ошибку.Получение ошибки xml при использовании Camel ActiveMQ

Код

public static void main(String[] args) { 
     ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext(
       "config/my.xml"); 
     System.out.println("reading done"); 
    } 

my.xml

<?xml version="1.0"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:camel="http://camel.apache.org/schema/spring" xmlns:osgi="http://www.springframework.org/schema/osgi" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/util 
     http://www.springframework.org/schema/util/spring-util.xsd 
     http://www.springframework.org/schema/osgi 
     http://www.springframework.org/schema/osgi/spring-osgi.xsd 
     http://www.springframework.org/schema/osgi-compendium 
     http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd 
     http://camel.apache.org/schema/spring 
     http://camel.apache.org/schema/spring/camel-spring.xsd 
     http://www.springframework.org/schema/osgi 
     http://www.springframework.org/schema/osgi/spring-osgi.xsd"> 

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> 
     <property name="brokerURL" value="tcp://localhost:61616" /> 
    </bean> 

    <camelContext xmlns="http://camel.apache.org/schema/spring"> 
     <route> 
      <from uri="timer://MyTimer?fixedRate=true&amp;period=4000" /> 
      <setBody> 
       <constant>Hello World!</constant> 
      </setBody> 
      <to uri="activemq:camel.timer" /> 
     </route> 
     <route> 
      <from uri="activemq:camel.timer" /> 
      <to uri="file:C:/temp/sandpit/timer" /> 
     </route> 
    </camelContext> 

</beans> 

ОШИБКА

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to create the JAXB binder; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
    this problem is related to the following location: 
     at org.apache.camel.model.config.PropertyDefinition 
     at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties 
     at org.apache.camel.model.config.PropertiesDefinition 
     at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties 
     at org.apache.camel.spring.CamelContextFactoryBean 
    this problem is related to the following location: 
     at org.apache.camel.model.PropertyDefinition 
     at private java.util.List org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.properties 
     at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean 
     at org.apache.camel.spring.CamelEndpointFactoryBean 
     at private java.util.List org.apache.camel.spring.CamelContextFactoryBean.endpoints 
     at org.apache.camel.spring.CamelContextFactoryBean 

- with linked exception: 
[com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
    this problem is related to the following location: 
     at org.apache.camel.model.config.PropertyDefinition 
     at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties 
     at org.apache.camel.model.config.PropertiesDefinition 
     at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties 
     at org.apache.camel.spring.CamelContextFactoryBean 
    this problem is related to the following location: 
     at org.apache.camel.model.PropertyDefinition 
     at private java.util.List org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.properties 
     at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean 
     at org.apache.camel.spring.CamelEndpointFactoryBean 
     at private java.util.List org.apache.camel.spring.CamelContextFactoryBean.endpoints 
     at org.apache.camel.spring.CamelContextFactoryBean 
] 
    at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:305) 
    at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85) 
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59) 
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) 
    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.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127) 
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93) 
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) 
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) 
    at com.ambika.testmq.ReadDataFromTCPPort.main(ReadDataFromTCPPort.java:8) 
Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
    this problem is related to the following location: 
     at org.apache.camel.model.config.PropertyDefinition 
     at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties 
     at org.apache.camel.model.config.PropertiesDefinition 
     at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties 
     at org.apache.camel.spring.CamelContextFactoryBean 
    this problem is related to the following location: 
     at org.apache.camel.model.PropertyDefinition 
     at private java.util.List org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.properties 
     at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean 
     at org.apache.camel.spring.CamelEndpointFactoryBean 
     at private java.util.List org.apache.camel.spring.CamelContextFactoryBean.endpoints 
     at org.apache.camel.spring.CamelContextFactoryBean 

- with linked exception: 
[com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
    this problem is related to the following location: 
     at org.apache.camel.model.config.PropertyDefinition 
     at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties 
     at org.apache.camel.model.config.PropertiesDefinition 
     at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties 
     at org.apache.camel.spring.CamelContextFactoryBean 
    this problem is related to the following location: 
     at org.apache.camel.model.PropertyDefinition 
     at private java.util.List org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.properties 
     at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean 
     at org.apache.camel.spring.CamelEndpointFactoryBean 
     at private java.util.List org.apache.camel.spring.CamelContextFactoryBean.endpoints 
     at org.apache.camel.spring.CamelContextFactoryBean 
] 
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source) 
    at javax.xml.bind.ContextFinder.find(Unknown Source) 
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
    at org.apache.camel.spring.handler.CamelNamespaceHandler.createJaxbContext(CamelNamespaceHandler.java:188) 
    at org.apache.camel.spring.handler.CamelNamespaceHandler.getJaxbContext(CamelNamespaceHandler.java:175) 
    at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:303) 
    ... 24 more 
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
    this problem is related to the following location: 
     at org.apache.camel.model.config.PropertyDefinition 
     at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties 
     at org.apache.camel.model.config.PropertiesDefinition 
     at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties 
     at org.apache.camel.spring.CamelContextFactoryBean 
    this problem is related to the following location: 
     at org.apache.camel.model.PropertyDefinition 
     at private java.util.List org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.properties 
     at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean 
     at org.apache.camel.spring.CamelEndpointFactoryBean 
     at private java.util.List org.apache.camel.spring.CamelContextFactoryBean.endpoints 
     at org.apache.camel.spring.CamelContextFactoryBean 

    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) 
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) 
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source) 
    ... 31 more 

Может кто-нибудь мне помочь? заранее заблаговременно

ответ

0

Попробуйте удалить посторонние пространства имен в качестве отправной точки.

Измени фасоль тег в

<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.xsd 
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 
+0

Если это не сработает, какую версию Camel вы используете? Camel 1 требует другого пространства имен: http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd –

+0

Спасибо jirawat за ответ , Я изменил файл xml в соответствии с вашим предложением. Но это не решает проблему. Я получаю такую ​​же ошибку. Я использую баны версии Camel 2.15.3. – user940782

+1

вопрос ликвидация. основная проблема заключалась в том, что в моем пути сборки были некоторые барабаны Camel 2.12. Поэтому я удалил их – user940782

0

Просто разработки комментарий по @ user940782 снова, так что ответ не пропустил.

Я использую встроенный Activemq для развертывания моего приложения на основе Camel. Мои ActiveMQ v5.10.1 использует Camel v2.13.1 Мой верблюд приложение использует v2.16.0

Основываясь на комментарий, я изменил версию Верблюд в моем приложении к 2.13.1 И вопрос был решен.

Смежные вопросы