私はApache Camelを使用して、sftpを使用してサーバーからファイルを取得しています。私のコードは無効なバンドルコンテキスト例外
SFTPから受信している://example.com:?22/DEV139 /アップロード/アラモユーザ名=管理&パスワード=管理&バイナリ=真&切断=真& =真
それは可能削除しますログにファイルの内容が表示されるので、このディレクトリからファイルを正常に取得できますが、次の例外がスローされます。
2017-11-06 16:18:42,498 |エラー| || FromAlamoSFTP => [msgtyp:AlamoCSV msgdst:CDX] || java.lang.IllegalStateException:無効なBundleContextです。 org.apache.felix.framework.BundleContextImpl.getBundleでorg.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514) (BundleContextImpl.java:112)org.apache.camel.coreで で。 org.apache.camel.component.bean.BeanHelper.isAssignableToExpectedType(BeanHelper.java:121) (org.apache.camel.component.bean.BeanInfo.matchMethod)で、 (BeanInfo.java:999) at org.apache.camel.component.bean.BeanInfo.removeNonMatchingMethods(BeanInfo.java:999) at org.apache.camel.component.bean.BeanInfo.chooseMethod(BeanInfo.java:566) at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:254) at org.apache.ca mel.component.bean.BeanInfo.createInvocation(BeanInfo.java:185) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:159) at org.apache.camel.management.InstrumentationProcessor。プロセス(InstrumentationProcessor.java:77) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196) at org.apache.camel.processor.Pipeline.process(Pipeline.java:121) at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) at org.apache.camel.util.AsyncProcessorHelper。プロセス(AsyncProcessorHelper.java:109) at org.apache.camel.processor.Pipeline.process(Pipeline.java:63)(CamelInternalProcessor.java:171) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:454) at org.apache.camel。 org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:226) のorg.apache.camel.component.fileの のコンポーネントファイルのリモート。RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137) 。 GenericFileConsumer.poll(GenericFileConsumer.java:190) at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTaskでjava.util.concurrent.FutureTask.runAndReset java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 301において(FutureTask.java:308) (ScheduledThreadPoolExecutor.java:180) でjavaのでjava.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) で.RUN(ScheduledThreadPoolExecutor.java:294)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)で .lang.Thread.run(Thread.java:748)
マイコードは次のとおりです。
public class FromAlamoRouteBuilder extends RouteBuilder implements
InitializingBean, DisposableBean {
@EnforceInitialization
private String DEAD_LETTER_MQ = "";
@EnforceInitialization
private String ALAMO_SFTP_SOURCE;
@EnforceInitialization
private String DESTINATION_QUEUE;
@EnforceInitialization(preventZero = false)
private int exceptionMaximumRedeliveries;
@EnforceInitialization(preventZero = false)
private int exceptionMaximumRedeliveriesDelay;
public void configure() throws Exception {
onException(Exception.class)
.handled(true)
.retriesExhaustedLogLevel(LoggingLevel.ERROR)
.retryAttemptedLogLevel(LoggingLevel.WARN)
.maximumRedeliveries((int) exceptionMaximumRedeliveries)
.redeliveryDelay((int) exceptionMaximumRedeliveriesDelay)
.bean("logging", "error(*, '${exception.stacktrace}')")
.to(DEAD_LETTER_MQ)
.stop();
/*
* The exchange body is expected to be an Alamo CSV file
*/
from(ALAMO_SFTP_SOURCE)
.routeId("FromAlamoSFTP")
.setExchangePattern(ExchangePattern.InOnly)
.bean("logging", "info(*, 'Received message " + ALAMO_SFTP_SOURCE + "[${body}]')")
.setHeader(MsgHdr.MESSAGE_TYPE, constant("AlamoCSV"))
.setHeader(MsgHdr.MESSAGE_DESTINATION, constant("CDX"))
.bean("logging", "info(*, 'Attempting to place Alamo msg on DESTINATION QUEUE " + DESTINATION_QUEUE + "')")
.to(DESTINATION_QUEUE)
.bean("logging", "info(*, 'Successfully placed Alamo msg on " + DESTINATION_QUEUE + "')");
}
public void setDeadLetterQueue(String dEAD_LETTER_MQ) {
DEAD_LETTER_MQ = dEAD_LETTER_MQ;
}
public void setExceptionMaximumRedeliveries(int exceptionMaximumRedeliveries) {
this.exceptionMaximumRedeliveries = exceptionMaximumRedeliveries;
}
public void setExceptionMaximumRedeliveriesDelay(
int exceptionMaximumRedeliveriesDelay) {
this.exceptionMaximumRedeliveriesDelay = exceptionMaximumRedeliveriesDelay;
}
public void setDestinationQueue(String queue){
this.DESTINATION_QUEUE = queue;
}
public void setAlamoSftpSource(String bcRelease){
this.ALAMO_SFTP_SOURCE = bcRelease;
}
public void afterPropertiesSet() throws Exception {
System.out.println("FromAlamoRouteBuilder is starting up");
FieldInitialization.checkAllFields(this);
}
public void destroy() throws Exception {
System.out.println("FromAlmoRouteBuilder is shutting down");
}
}
SFTPを使用してもよろしいですか? SFTPはSSHの一部であり、21ではなく22番のポートで動作します.21はFTPの標準ポートですので、実際にはFTPS(明示的)を使用する必要があります。 – Lothar
私はサーバーの資格情報を渡したくないので、スタックオーバーフローに関するサーバー情報を隠すためにポートを21に変更しました。しかし私は自分のコードで22を使用します。 –
奇妙なことは、ファイルを正常に取得できて、このエラーが発生することです。 –