使用camel JPA组件时出错:无法解析端点:jpa:由于:索引4处的预期方案特定部分:jpa:

时间:2015-01-29 10:54:59

标签: apache-camel

您好我正在尝试使用camel JPA组件将实体发送到postgresql DB 我在创建路线时遇到以下错误。请帮忙。 Persistence.xml和路由如下。我正在使用Spring DSL进行路由。

Jan 29, 2015 3:49:47 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route processSdpRoute at: >>> To[jpa:] <<< in route: Route(processSdpRoute)[[From[direct:processSdpRecord]] -> [p... because of Failed to resolve endpoint: jpa: due to: Expected scheme-specific part at index 4: jpa:
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363)
    at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:122)
    at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:318)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route processSdpRoute at: >>> To[jpa:] <<< in route: Route(processSdpRoute)[[From[direct:processSdpRecord]] -> [p... because of Failed to resolve endpoint: jpa: due to: Expected scheme-specific part at index 4: jpa:
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:910)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:780)
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2068)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1816)
    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 org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:254)
    at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
    ... 17 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa: due to: Expected scheme-specific part at index 4: jpa:
    at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:607)
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:489)
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:71)
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:190)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:106)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:499)
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:212)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:907)
    ... 26 more
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 4: jpa:
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.failExpecting(URI.java:2835)
    at java.net.URI$Parser.parse(URI.java:3038)
    at java.net.URI.<init>(URI.java:595)
    at org.apache.camel.util.URISupport.normalizeUri(URISupport.java:448)
    at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:605)
    ... 36 more




My Persistence.xml is below

<?xml version="1.0" encoding="UTF-8"?>

<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
  <persistence-unit name="PERSISTENCE_UNIT_NAME" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/fdp-sa-db" />
      <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
      <property name="javax.persistence.jdbc.user" value="postgres" />
      <property name="javax.persistence.jdbc.password" value="postgres" />
      </properties>
     </persistence-unit>
</persistence>

我的Spring-config.xml如下:

<?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:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
        http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/security  http://www.springframework.org/schema/security/spring-security-3.1.xsd 
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">


    <bean id="transactionManagerlocal" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactorylocal"/>
    </bean>
<bean id="entityManagerFactorylocal"
                class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
                <property name="persistenceUnitName" value="PERSISTENCE_UNIT_NAME" />
     </bean>

    <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
    <property name="entityManagerFactory" ref="entityManagerFactorylocal"/>
   <property name="transactionManager" ref="transactionManagerlocal"/>
</bean>

</beans>

Route Definition is below:

 <bean id="sdpFileProcessor" class="com.ericsson.sdp.processor.SDPFileProcessor"/> 

        <!-- this is an included XML file where we only the the routeContext -->
        <routeContext id="processSdpRoute" xmlns="http://camel.apache.org/schema/spring">
        <route id="processSdpRoute">
        <from uri="direct:processSdpRecord"/>
        <!-- <filter>
            <mvel>request.body.offer_type == 3 &amp;&amp; request.body.offer_id == 20</mvel> -->
                 <process ref="sdpFileProcessor" /> 
            <to uri= "jpa:" />
         <!--  </filter> -->
         </route>
        </routeContext>
       </beans>

0 个答案:

没有答案