Operating System - HP-UX
1748285 Members
3976 Online
108761 Solutions
New Discussion юеВ

Re: Java and/or ftp problem

 
Tomek Gryszkiewicz
Trusted Contributor

Java and/or ftp problem

Hi,
i've got a java, or ftp, or network problem. I am using the very simple java class which connects to ftp server and downloading the file. So, on one of the servers this class crashed with exception:
Connected to URL ftp://user:pass@host/PROD/test.txt
Exception in thread "main" java.lang.NullPointerException
at URLLineReader2.ready(URLLineReader2.java:67)
at URLLineReader2.main(URLLineReader2.java:92)

It is crashing when executing:
m_in = urlc.getInputStream();

I have many other machines, on which this class is running very well. On every machine i have 11i, java version is the same:
java version "JavaVM-1.3.0.01"
Java(TM) 2 Runtime Environment, Standard Edition (build jinteg:02/14/01-23:51)
HotSpot VM (build 1.0.1fcs jinteg:02/15/01-02:43 PA2.0, mixed mode)

I cannot change the java versionbecause appserver is using it.

I can connect from this machine to the ftp server using a normal ftp client, with the same user and password, and download this file... I've tried to use IP instead of host name.

Any ideas?

-Tomek
8 REPLIES 8
Jeff Schussele
Honored Contributor

Re: Java and/or ftp problem

Hi Tomek,

I'm not sure just how that class works, but if it uses the ~username/.netrc file as input for the username/PW, then I would check the ownership & perms on that file.
It must be 600 & owned by that user & the primary group of that user.

BTW - I strongly urge all to find other ways to do unattended ftp xfers - like ssh/sftp/scp so that you don't need .netrc files. They're HUGE security holes.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Umapathy S
Honored Contributor

Re: Java and/or ftp problem

Tomek,
I feel the problem is there in the java class. Since, the plain ftp client has no problems, double check the java code.

You can attach it here, may be somebody can go through it and give some suggestions.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Tomek Gryszkiewicz
Trusted Contributor

Re: Java and/or ftp problem

No, it is not using .netrc

And it is not the problem in java code - the same class is working on over 40 different machines (HPUX, NT) - only on the specified one i have a problems.
Mark Greene_1
Honored Contributor

Re: Java and/or ftp problem

Are the java-related patches on the HP server where the code is crashing different from the patchs on the other servers where it is not?

mark
the future will be a lot like now, only later
Tomek Gryszkiewicz
Trusted Contributor

Re: Java and/or ftp problem

I am checking the patches now. But i am not using standard java - this java is provided with application server.

-Tomek
Paddy_1
Valued Contributor

Re: Java and/or ftp problem

Seems like it can find the url mentioned or whatever is the unput stream yielding it.

The exception says the value given by the input stream is non-existent or has some error naming it..

can you attach the source so that we can analyse it further.
The sufficiency of my merit is to know that my merit is NOT sufficient
Umapathy S
Honored Contributor

Re: Java and/or ftp problem

Tomek, I am echoing Paddy's comments here.

The NullPointer exception is for the input stream (or that input) and java is finding as null.

Might be after connecting, it is crashing.

-Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Tomek Gryszkiewicz
Trusted Contributor

Re: Java and/or ftp problem

Sorry i dont think i can put the source, it is not mine :(
But the fragments with connection are:

// source is args[0]
URL sourceURL = new URL(source);
if (sourceURL == null)
{ [report error]; return false }
URLConnection urlc = sourceURL.openConnection();
m_in = urlc.getInputStream();
--- and at this place is throwing sun.net.ftp.FtpProtocolException: PORT

I am sure that user, pass, path, server is correct.
Another thing: i am using the sam class to retrieve files via HTTP, and it is working...