BatchFTP "get" problem

All,

I would appreciate your help on the following issue.

I try to do an FTP get in my jcd but keep on getting an error.

I think the configuration in cm and environment is correct (UNIX, Manual connection Mode, ...). Is there some way to tell the Ftp Client we're in "GET" mode, and not in "PUT" mode? Any other suggestions?

An extract of the code:

public void start( ... com.stc.eways.batchext.BatchFtp batchFtp){

...

batchFtp.getClient().connect();

...

batchFtp.getClient().get();

...

It's at the "get()" the crash happens.

The stackTrace:

Batch FTP eWay error when doing data transfer operation in [get()], message=[com.stc.eways.batchext.FtpFileException: FtpFileTransferNamesAndCommandsGet.resolveTargetLocation(): Failed to list file. Got exception [java.io.IOException: FtpFileProviderImpl.listFileNames(): Got exception [java.lang.NullPointerException].].].|#]

....

at com.stc.eways.batchext.FtpFileClientImpl.sendAlertAndThrowException(FtpFileClie ntImpl.java:3042)

at com.stc.eways.batchext.FtpFileClientImpl.get(FtpFileClientImpl.java:2926)

at prj5035EbusConnectJCD.jcdEbusInFtp.start(jcdEbusInFtp.java:98)

at prj5035EbusConnect.svcEbusInFtp.jcdEbusInFtp_Runtime_Handler.handleRequest(jcdE busInFtp_Runtime_Handler.java:393)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:140)

at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInv ocationHandler.java:135)

at $Proxy45.handleRequest(Unknown Source)

at STC_MDB__eaSchedulerEbus_svcEbusInFtp.sendMessage(STC_MDB__eaSchedulerEbus_svcE busInFtp.java:213)

at STC_MDB__eaSchedulerEbus_svcEbusInFtp.onContents(STC_MDB__eaSchedulerEbus_svcEb usInFtp.java:100)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:146)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSe curityManager.java:940)

at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:151)

at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer .java:948)

at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListen erImpl.java:42)

at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(Me ssageEndpointInvocationHandler.java:136)

at $Proxy48.onContents(Unknown Source)

at com.stc.schedulerotd.scheduleradapter.FileReaderWork.run(FileReaderWork.java:77 )

at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:54)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Thread PoolImpl.java:382)

Many Thanks (and have a nice weekend)

koen

[3479 byte] By [KoenDeSmeta] at [2007-11-27 0:58:50]
# 1

Make sure the user ID is able to perform an ls/dir command. If that is not the case, most likely it is not finding any files that match your regular expression. What you will need to do is to verify that the otd found a file:

inFilename = sftpIn.getClient().getResolvedRemoteFile();

if )inFilename != null ){

batchFtp.getClient().get();

}

One there is a file, go get it. Good luck!

Regards,

John

johnferrona at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 2

Hi,

Thanks for your quick reply.

The user can connect to the remote server. When I ftp in the command prompt, I can logon, "ls", "cd", I can even "get" the file...

I'd love to call getResolvedNamesForGet, but I get a nullpointer exception. That's where my original question -if I can tell the eWay we're getting, not putting files- originated from. At a certain moment while debugging, I noticed the ResolvedNamesForPut was containing data, ResolvedNamesForGet wasn't.

Thoughts?

koen

KoenDeSmeta at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 3

Please post all the ftp-related code between the connect and the get, including where you are populatign configuration with the directory and file name. If you are not dynamically populating these things then carefully check the configuration of the target directory and file in the ftp eway properties.

mczapskia at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 4

There is no code between connect() and get().

I started with dynamically populating the different configurations. But currently, I pushed everything to the connectivity map and environment config.

These are the settings:

--> connectivity Map <--

*) Pre Transfer Command: None

*) Post transfer command: none

*) FTP - Directory Listing Style: UNIX

*) FTP - Use PASV: Yes

*) FTP - Mode: binary

*) Sequence Numbering Start 1 - Max 999999

*) Target Location: Append - No

*) Target Location: Directory : /tmp

*) Target Location: Directoy is pattern : No

*) Target Location: File: aa.txt

*) Target Location: File is pattern : No

*) General Settings - Synchronised: true

--> environment <--

*) general setting - connection mode : Manual

KoenDeSmeta at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 5

I use BatchLocal and BatchFtp to get a file like this:

public void start( ...BatchFtp ftp, BatchLocal localFile ...) throws Throwable {

ftp.getClient().setOutputStreamAdapter(localFile.getClient().getOutputStreamAdapter());

ftp.getClient().get();

}

Use the 'BatchLocal' element in the Connectivity Map to set up target path and filename

hbau42a at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 6
Perhaps you should use an _InputStreamAdapter_ rather then an _OutputStreamAdapter_ for the GET (input) operation?
mczapskia at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...
# 7

Hi all,

I think I have located the problem.

The file I was trying to get, was in a UNIX directory that also contained files with "Alternate Access Methods" defined a.k.a Access control Lists; I don't know exactly how these work in UNIX, but what I do know is that you can recognise them by the "+" sign after the rwx properties.

e.g.

ls -alrt ->

drwxrwxr-x+ 2 ias9i1ias8192 Nov 22 2004 clntst8.560

In the get() method, there is a statement FtpFileProviderImpl.listFileNames(); which lists all files in the current directory. This is the method the causes the exception.

I added the following lines of code, attached a java debugger and noticed that out of the 37 values contained in "files" -the 37 files in the directory-, 3 were null. These 3 were the ones that where having this + sign....

I moved the file to another (empty) directory and all code works fine now;

try {

com.stc.eways.batchext.FtpFileProviderImpl toto = (com.stc.eways.batchext.FtpFileProviderImpl) batchFtp.getProvider();

com.oroinc.net.ftp.FTPFile[] files = toto.listFiles();

for (int j = 0; j < files.length; j++) {

logger.debug( "fileName : " + files[j].getName() );

}

} catch ( Exception e ) {

logger.debug( "Error!!!!!!" );

e.printStackTrace();

}

I have been looking into the standard UNIX heuristics defined in FtpHeuristics.cfg but I don't think I can manually change something in order to get it working. Sounds like a real bug, don't you think?

thanks for your help,

koen

KoenDeSmeta at 2007-7-11 23:32:57 > top of Java-index,Java Enterprise System,Java Composite Application Platform Suite -- General Discussion...