2017-10-27 1 views
0

xml (문자열) 페이로드를 jaxb 생성 빈으로 비 정렬 화하는 낙타 경로를 테스트하고 다음 빈 프로세서에서 사용됩니다. 모든 것은 실제 흐름에 완벽하게 작동하지만 난 내 길을 테스트 할 JUnit을 실행하려고 할 때 오류 얻을 :이 사람을 포함한 모든 청사진 컨텍스트 파일을 (나는 getBlueprintDescriptor을 (오버라이드 (override) 한낙타 경로 테스트 오류 : IllegalArgumentException : 데이터 형식 'jaxb'을 (를) 만들 수 없습니다.

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.536 sec <<< FAILURE! - in com.equifax.icc.esb.tradinghistory.routes.report.PreDataRetrievalServiceTest 
preDataRetrievalOrchestrationSuccessTest(com.equifax.icc.esb.tradinghistory.routes.report.PreDataRetrievalServiceTest) Time elapsed: 4.575 sec <<< ERROR! 
org.apache.camel.FailedToCreateRouteException: Failed to create route report-info-preparation-service-route at: >>> Unmarshal[ref:bthRequestModel] <<< in route: Route(report-info-preparation-service-route)[[From[direct:re... because of Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath 
Caused by: java.lang.IllegalArgumentException: Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the class path: 

를) 및 포함 JAXB DataFormat에 대한 빈 선언). 됩니다 다음은 getBlueprintDescriptor() 메소드와 콩 선언 :

@Override 
    protected String getBlueprintDescriptor() { 
     return "/OSGI-INF/blueprint/test-beans-context.xml," 
       +"/OSGI-INF/blueprint/test-env-context.xml," 
       + "/OSGI-INF/blueprint/test-camel-context.xml"; 
} 

<bean class="org.apache.camel.model.dataformat.JaxbDataFormat" id="bthRequestModel"> 
      <property name="prettyPrint" value="false" /> 
      <property name="fragment" value="true" /> 
      <property name="ignoreJAXBElement" value="true" /> 
      <property name="contextPath" value="com.vedaxml.vxml2.veda_bth_request_v1" /> 
     </bean> 

내가 createRegistry을 (무시 시도)뿐만 아니라 :

:

@Override 
    protected JndiRegistry createRegistry() throws Exception { 
     JndiRegistry registry = super.createRegistry(); 
     JaxbDataFormat jdf = new org.apache.camel.model.dataformat.JaxbDataFormat(false); 
     jdf.setFragment(true); 
     jdf.setIgnoreJAXBElement(true); 
     jdf.setContextPath("com.vedaxml.vxml2.veda_bth_request_v1"); 

     DataFormat jaxb = (DataFormat) jdf; 

     registry.bind("bthRequestModel", jdf); 
     //registry.bind("jaxb", new org.apache.camel.model.dataformat.JaxbDataFormat()); 

     return registry; 
    } 

이 오류 아래에 나와 있습니다

2017-10-27 22:38:56,613 INFO org.apache.camel.test.junit4.CamelTestSupport ******************************************************************************** 
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.792 sec <<< FAILURE! - in com.equifax.icc.esb.tradinghistory.routes.report.PreDataRetrievalServiceTest 
preDataRetrievalOrchestrationSuccessTest(com.equifax.icc.esb.tradinghistory.routes.report.PreDataRetrievalServiceTest) Time elapsed: 4.316 sec <<< ERROR! 
org.apache.camel.FailedToCreateRouteException: Failed to create route report-info-preparation-service-route at: >>> Unmarshal[ref:bthRequestModel] <<< in route: Route(report-info-preparation-service-route)[[From[direct:re... because of Cannot find data format in registry with ref: bthRequestModel 
Caused by: java.lang.IllegalArgumentException: Cannot find data format in registry with ref: bthRequestModel 

taFormat이 null 인 경우 https://issues.apache.org/jira/browse/CAMEL-3508

DataFormatDefinition.java 코드 (아래에 있음)를 디버깅하는 동안 Routecontext.getcamelContext()에서 jaxbcontext가 null 인 것을 확인했습니다.


public DataFormat getDataFormat(RouteContext routeContext) { 
     if (dataFormat == null) { 
      Runnable propertyPlaceholdersChangeReverter = ProcessorDefinitionHelper.createPropertyPlaceholdersChangeReverter(); 

      // resolve properties before we create the data format 
      try { 
       ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), this); 
      } catch (Exception e) { 
       throw new IllegalArgumentException("Error resolving property placeholders on data format: " + this, e); 
      } 
      try { 
       dataFormat = createDataFormat(routeContext); 
       if (dataFormat != null) { 
        // is enabled by default so assume true if null 
        final boolean contentTypeHeader = this.contentTypeHeader == null || this.contentTypeHeader; 
        try { 
         setProperty(routeContext.getCamelContext(), dataFormat, "contentTypeHeader", contentTypeHeader); 
        } catch (Exception e) { 
         // ignore as this option is optional and not all data formats support this 
        } 
        // configure the rest of the options 
        configureDataFormat(dataFormat, routeContext.getCamelContext()); 
       } else { 
        throw new IllegalArgumentException(
          "Data format '" + (dataFormatName != null ? dataFormatName : "<null>") + "' could not be created. " 
            + "Ensure that the data format is valid and the associated Camel component is present on the classpath"); 
       } 
      } finally { 
       propertyPlaceholdersChangeReverter.run(); 
      } 
     } 
     return dataFormat; 
    } 

public static DataFormat getDataFormat(RouteContext routeContext, DataFormatDefinition type, String ref) { 
     if (type == null) { 
      ObjectHelper.notNull(ref, "ref or type"); 

      // try to let resolver see if it can resolve it, its not always possible 
      type = routeContext.getCamelContext().resolveDataFormatDefinition(ref); 

      if (type != null) { 
       return type.getDataFormat(routeContext); 
      } 

      DataFormat dataFormat = routeContext.getCamelContext().resolveDataFormat(ref); 
      if (dataFormat == null) { 
       throw new IllegalArgumentException("Cannot find data format in registry with ref: " + ref); 
      } 

      return dataFormat; 
     } else { 
      return type.getDataFormat(routeContext); 
     } 
    } 

내가 DataFormatDefinition 클래스의 인스턴스를 만들 수있는 JaxbDataFormat 객체를 주입 생성자를 시도했다 (그래서 DATAFORMAT이 null이 아닌)하지만 여전히 내가 같은 오류가 나타 DATAFORMAT 레지스트리에서 찾을 수 없습니다 얻을.

아무도 나를 고칠 수 있습니까? 미리 감사드립니다.

답변

0

JNDI에서 만들고 바인딩해야하는 모델 클래스가 아니라 camel-jaxb의 실제 DataFormat 클래스입니다. 클래스 이름은 같지만 패키지 이름은 다릅니다.

+0

답장을 보내 주셔서 감사합니다. 실례 합니다만 당신을 따라 가지 않습니다. 나는 JaxbDataFormat 클래스를 만들고 바인딩하고있다. 레퍼런스 이름이 모델 (이름 지정 규칙이 프로젝트라는 방식)처럼 들리는 것입니다. 당신이 당신의 제안을 친절히 설명해 주시겠습니까? 감사. – user3359005

관련 문제