我是Camel的新手。我正在为以下场景编写骆驼路线
我这样写了
public void configure() throws Exception {
JaxbDataFormat jaxb = new JaxbDataFormat();
JAXBContext ctx = JAXBContext.newInstance(Book.class);
jaxb.setContext(ctx);
from("file:data/source?noop=true").to("validator:books.xsd")
.to("file:data/destination").split()
.tokenizeXML("book").unmarshal(jaxb)
.to("jpa:com.labs.Book");
}
我的XML文件是:
<book>
<author>Kishore</author>
<title>The Second Book</title>
<genre>Fiction</genre>
</book>
我的XSD是:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="author" nillable="false"/>
<xs:element type="xs:string" name="title" nillable="false"/>
<xs:element type="xs:string" name="genre" nillable="false" fixed="{Fiction,Bio}"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我有XML的JAXB模型。我也有pesristence.xml文件。但是当我尝试执行我的应用程序时,我得到如下的异常
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:WARN No appenders could be found for logger (org.springframework.orm.jpa.LocalEntityManagerFactoryBean).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1168 camel WARN [main] openjpa.Enhance - Unenhanced classes were detected even though the enhancer has ran. Ensure that the EntityManagerFactory is created prior to creating any Entities.
Exception in thread "main" org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[jpa://com.labs.Book]. Reason: <openjpa-2.3.0-r422266:1540826 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
com.labs.Book".
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:409)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:123)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:202)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1154)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:993)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:993)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1154)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:993)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
at org.apache.camel.impl.RouteService.startChildService(RouteService.java:334)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:158)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2263)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2193)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1981)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1851)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651)
at com.labs.App.main(App.java:36)
Caused by: <openjpa-2.3.0-r422266:1540826 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
com.labs.Book".
at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:115)
at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:312)
at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:236)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:155)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:376)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:519)
at com.sun.proxy.$Proxy20.createEntityManager(Unknown Source)
at org.apache.camel.component.jpa.JpaEndpoint.createEntityManager(JpaEndpoint.java:284)
at org.apache.camel.component.jpa.JpaProducer.<init>(JpaProducer.java:44)
at org.apache.camel.component.jpa.JpaEndpoint.createProducer(JpaEndpoint.java:106)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:405)
... 82 more
感谢您的时间,感谢您的帮助。如果可能的话,请参考Camel JPA示例的一些链接,其中JPA Component用作制作人。
答案 0 :(得分:0)
根据错误消息以及DuckDuckGo的搜索结果显示的内容,您在配置中缺少一部分,并且编织类com.labs.Book。
我不知道OpenJPA,但this link应该为您提供更多信息。