在jboss esb中与ftp服务器通信

时间:2011-11-19 10:22:03

标签: jboss-esb

我的任务是配置ftp服务器并使用Jboss ESB从中读取文件。所以我在jboss-esb.xml中配置了ftp服务器,如下所示,我的服务类和错误在下面

<providers>
<ftp-provider name="FTPprovider" hostname="192.168.1.6">
<ftp-bus busid="helloFTPChannel">
<ftp-message-filter username="durga" password="durga" passive="false" 
directory="jboss" input-suffix=".dat"
work-suffix=".esbWorking" post-delete="false" post-suffix=".COMPLETE"
error-delete="false" error-suffix=".HAS_ERROR" />
</ftp-bus>
</ftp-provider>
<jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
jndi-URL="localhost">
<jms-bus busid="quickstartEsbChannel">
<jms-message-filter dest-type="QUEUE"
dest-name="queue/quickstart_helloworld_ftp_esb" 
selector="source='fromHelloworldFTPAction'" />
</jms-bus>
</jms-provider>
</providers>
<services>
<service category="myCategory" name="myFileListener"
description="Hello World File Action (esb listener)">
<listeners>
<ftp-listener name="FtpGateway" busidref="helloFTPChannel"
maxThreads="1" is-gateway="true" scheduleidref="cron-schedule" />
<jms-listener name="helloWorldFileAction" busidref="quickstartEsbChannel"
maxThreads="1" />
</listeners>
<actions>
<action name="notificationAction"   class="org.jboss.soa.esb.samples.quickstart.helloworldftpaction.test.Notifier">
<property name="okMethod" value="notifyOK" />
<property name="notification-details">
<NotificationList type="ok">
<target class="NotifyFTP">
<ftp URL="ftp://durga:durga@192.168.1.6/jboss"
filename="hello.txt" />
</target>
</NotificationList>
</property>
</action>
</actions>
</service>
</services>

package org.jboss.soa.esb.samples.quickstart.helloworldftpaction.test;
import org.jboss.soa.esb.actions.ActionLifecycle;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.helpers.ConfigTree;
public class Notifier implements ActionLifecycle{
protected ConfigTree    _config;
public Notifier(ConfigTree config) { _config = config; } 
public Message notifyOK(Message message) throws ActionProcessingException {
String filePayload = "Hello World";
message.getBody().add(filePayload);
System.out.println("messags is ------------------------"+message.getBody().get());
return message;
}
@Override
public void destroy() throws ActionLifecycleException {
// TODO Auto-generated method stub
}
@Override
public void initialise() throws ActionLifecycleException {
// TODO Auto-generated method stub
}
}
create esb service, FtpServerExample.esb
11:16:53,019 INFO  [AbstractFileGateway] No value specified for: max-millis-for-response -  This will be an 'inbound-only' gateway
11:16:53,045 WARN  [ServiceController] Problem starting service jboss.esb:deployment=FtpServerExample.esb
java.lang.RuntimeException: java.lang.NullPointerException
    at org.jboss.soa.esb.listeners.config.Configuration.create(Configuration.java:132)
    at org.jboss.soa.esb.listeners.config.JBoss4ESBDeployment.startService(JBoss4ESBDeployment.java:82)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    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:616)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy44.start(Unknown Source)
    at org.jboss.soa.esb.listeners.config.JBoss4ESBDeployer.start(JBoss4ESBDeployer.java:432)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
Caused by: java.lang.NullPointerException
at org.jboss.soa.esb.schedule.ScheduleProvider.getSchedule(ScheduleProvider.java:165)
at org.jboss.soa.esb.schedule.ScheduleProvider.addListener(ScheduleProvider.java:83)
at org.jboss.soa.esb.listeners.config.ScheduleProviderFactory.createInstance(ScheduleProviderFactory.java:65)
at org.jboss.soa.esb.listeners.config.Configuration.create(Configuration.java:116)
... 47 more
11:16:53,048 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
ObjectName: jboss.esb:deployment=FtpServerExample.esb
State: FAILED
Reason: java.lang.RuntimeException: java.lang.NullPointerException
I Depend On:
jboss.esb:deployment=jbossesb.esb

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.esb:deployment=FtpServerExample.esb
State: FAILED
Reason: java.lang.RuntimeException: java.lang.NullPointerException
I Depend On:
jboss.esb:deployment=jbossesb.esb

2 个答案:

答案 0 :(得分:3)

我认为这是因为尝试使用scheduleidref“cron-schedule”而没有定义它。

<ftp-listener name="FtpGateway" busidref="helloFTPChannel"
maxThreads="1" is-gateway="true" scheduleidref="cron-schedule" />

这看起来很像https://issues.jboss.org/browse/JBESB-3721

答案 1 :(得分:0)

如果您的应用程序正在读取/写入文件夹的操作,检查文件夹的权限和文件夹的所有者。

我们有这样的问题并且已经解决。