- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
想法是从文件系统读取edi文件并将其传输为XML。我尝试了从 smooks 下载的示例,效果很好。但是当我开始使用 Camel 处理器中的相同代码(和 edi 文件)时,我得到一个空指针。
代码
public class MyRouteBuilder extends RouteBuilder
{
@Override
public void configure()
{
from("file://C:/Users/Owner/Desktop/BPMN").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception
{
System.err.println("We just downloaded: " + exchange.getIn().getHeader("CamelFileName"));
Locale defaultLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "IE"));
// Instantiate Smooks with the config...
Smooks smooks = new Smooks("smooks-config.xml");
// smooks.setReaderConfig(new
// UNEdifactReaderConfigurator("urn:org.milyn.edi.unedifact:d03b-mapping:v1.4"));
System.err.println("Loaded smooks cfg");
try
{
// Create an exec context - no profiles....
ExecutionContext executionContext = smooks.createExecutionContext();
System.err.println("created execution context");
DOMResult domResult = new DOMResult();
// Configure the execution context to generate a report...
// executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html"));
// Filter the input message to the outputWriter, using the execution context...
byte[] body = exchange.getIn().getBody(String.class).getBytes();
System.err.println("Retrieved the body " + new String(body));
smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(body)), domResult);
Locale.setDefault(defaultLocale);
System.err.println(domResult.getNode());
// System.err.println
System.err.println(XmlUtil.serialize(domResult.getNode().getChildNodes(), true));
}
finally
{
smooks.close();
}
}
}).to("file:C:/ws-juno");
}
}
日志
[ Thread-1] FakeFtpServer INFO Starting the server on port 0
[ Thread-1] FakeFtpServer INFO Actual server port is 49852
[ main] MainSupport INFO Apache Camel 2.9.0 starting
[ main] DefaultCamelContext INFO Apache Camel 2.9.0 (CamelContext: camel-1) is starting
[ main] ManagementStrategyFactory INFO JMX enabled. Using ManagedManagementStrategy.
[ main] ultManagementLifecycleStrategy INFO StatisticsLevel at All so enabling load performance statistics
[ main] AnnotationTypeConverterLoader INFO Found 3 packages with 15 @Converter classes to load
[ main] DefaultTypeConverter INFO Loaded 168 core type converters (total 168 type converters)
[ main] DefaultTypeConverter INFO Loaded additional 0 type converters (total 168 type converters) in 0.004 seconds
[ main] rFileExclusiveReadLockStrategy WARN Deleting orphaned lock file: C:\Users\Owner\Desktop\BPMN\input-message.edi.camelLock
[ main] DefaultCamelContext INFO Route: route1 started and consuming from: Endpoint[file://C:/Users/Owner/Desktop/BPMN]
[ main] DefaultCamelContext INFO Total 1 routes, of which 1 is started.
[ main] DefaultCamelContext INFO Apache Camel 2.9.0 (CamelContext: camel-1) started in 4.508 seconds
We just downloaded: input-message.edi
Loaded smooks cfg
created execution context
Retrieved the body HDR*1*0*59.97*64.92*4.95*Wed Nov 15 13:45:28 EST 2006
CUS*user1*Harry^Fletcher*SD
ORD*1*1*364*The 40-Year-Old Virgin*29.98
ORD*2*1*299*Pulp Fiction*29.99
null
[://C:/Users/Owner/Desktop/BPMN] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-Owner-PC-49853-1329098945139-0-1. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException
at com.xcg.routes.MyRouteBuilder$1.process(MyRouteBuilder.java:69)[file:/C:/ws-juno/routes/target/classes/:]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)[camel-core-2.9.0.jar:2.9.0]
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)[camel-core-2.9.0.jar:2.9.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.6.0_26]
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)[:1.6.0_26]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)[:1.6.0_26]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)[:1.6.0_26]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)[:1.6.0_26]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)[:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)[:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.6.0_26]
at java.lang.Thread.run(Unknown Source)[:1.6.0_26]
最佳答案
为了他人的利益回答我自己的问题。
我发布的代码的问题是我(实际上camel默认情况下只记录最外面的异常)吞咽了异常。当我捕获异常并打印堆栈跟踪后,我发现根本原因是 Smook 的 edi-message-mapping xml 中的映射不正确。
此外,Smooks 在 GAE 上有一个网站 (http://edi-to-xml.appspot.com/),允许您解析 edi 消息并将其转换为 xml。
关于java - 无法使 Smooks EDI 与 Camel 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9254814/
在smooks网站上看到是支持EDI生成的。但是没有办法为 edi writer 指定配置(就像在模式 http://www.milyn.org/xsd/smooks/edi-1.1.xsd 中定义的
我需要使用一些配置设置来使用 Smooks 中介转换消息。例如,我想在转换期间将基本 URL 注入(inject)传出 xml 的属性值中。 在 Java 中,我会通过将 bean 添加到 Execu
使用 Smooks (1.4) 读取 CSV 并将其转换为 Person POJO。 CSV 由每行以逗号分隔的记录组成,每条记录都有竖线分隔的字段: Smith|John|45|male|Johnn
当通过直接 TCP、HTTP、SOAP 或其他传输协议(protocol)使用基于文本的 EDI X12 消息有效负载(例如 http://examples.x12.org/ )时,是否有人有关于以下
我正在尝试构建一个通用的 EDI 解析器,它可以处理给定文件中不存在任何情况段的情况。使用 XML 映射中的 minOccurs="0" 属性很容易做到这一点,但是我很难弄清楚当多个段重复使用同一标记
我在 C# 中做了很多编码合并和数据转换的工作,我只是想知道是否有任何好的“ helper ”来做这些而不是手动编码。(也就是说,无需像 Biztalk 这样的完整集成平台)我说的是合并和映射文本文件
我正在制作一个 freemarker 模板,这是一个示例。 ${(currentGrantorIndex)!?string} // want to comment this line
我能够在 freemarker 模板中使用 smooks 显示传入 XML 文件的内容,但我想添加本地系统的当前日期和时间来识别我的程序的执行。 ${BalanceInqu
我有一个大致如下的 xml 文件:
我想要通用转换器,以便任何 Java 对象都转换为 Map,并且嵌套对象表示为嵌套 Map。例如 class MyA { String a; Integer b; MyB c; Lis
我正在尝试做一些我认为是基本任务的事情。 我正在寻找一个简单而整洁的Java解决方案,它可以按元素拆分XML内容。我不想将整个内容加载到内存中(即我想流式传输元素),并且我想掌握每个元素的字符串表示形
受到 Smooks EDI writer 中提出的解决方案的启发,我有以下 Java 代码: // Creates minimal EDI message with one field populat
在smooks(版本1.5.1)中是否可以仅将两个选择元素中的一个生成元素映射到java字段? 示例: xsd 文件:
我正在 smooks 的帮助下在 java 程序中创建 ANSI.X12 消息。我正在使用 xml 文件(及其 http://www.milyn.org/schema/edi-message-mapp
如何使用 SMOOKS 将 XML 文件转换为 EDI 文件? 我能够将 EDI 转换为 XML,实际上这是 SMOOKS 提供的示例的一部分。 最佳答案 根据您的问题,我尝试对其进行了一些研究。请检
我正在编写这个在 Smooks 中运行并编辑 XML 的 groovy 脚本。我正在尝试将 xsi:nil="true"添加到空字段中,但我遇到的问题是 xsi 命名空间声明未添加到根字段中。这是我尝
我在使用 grails 和 Smooks 库时遇到问题。在独立的 java 项目上它可以正常工作,但是将它们添加到 Grails 项目后,我收到以下错误: package org.milyn does
想法是从文件系统读取edi文件并将其传输为XML。我尝试了从 smooks 下载的示例,效果很好。但是当我开始使用 Camel 处理器中的相同代码(和 edi 文件)时,我得到一个空指针。 代码 pu
我正在使用 camel 和 smooks 编写路由,生产者作为 JPA 存储库,生成 JPA 对象列表,我需要将其作为固定宽度文件发送到 sftp 服务器。 这是我认为发生这种情况所必需的 使用 JP
我是 smooks 的初学者。我遇到了一个问题。这就是java-java的转换。我有一个列表,其中有一个包含 2 个对象的内部列表。我怎样才能实现 list.list 以在 smooks 中列出副本?
我是一名优秀的程序员,十分优秀!